請問如何擷取輸入法視窗內的文字與鍵入的code |
尚未結案
|
neoaj23
一般會員 發表:35 回覆:7 積分:8 註冊:2003-09-12 發送簡訊給我 |
|
hello
初階會員 發表:64 回覆:68 積分:31 註冊:2004-05-08 發送簡訊給我 |
Hi neoaj23 你好
這是我截取一段文字內每一個中文字注音輸入法的第一個注音碼,你參考看看. function Tform1.ime_str(stringword:string):string;
var
iHandleCount: integer;
pList: array[1..nHKL_LIST] of HKL;
szImeName: array[0..254] of char;
i,j,k : integer;
sFound: string;
temp_str : string;
temp_str1 : string;
temp_char : char;
temp_str2 : string;
len : integer;
begin
temp_str1 := '';
// lstComposition.Items.Clear;
// 取得目前系統已安裝輸入法之各個鍵盤配置(Keyboard Layout)
len := length(stringword);
j := 0;
while j < len do begin
j := j 1;
temp_char := stringword[j];
if ord(temp_char) >= 150 then begin
temp_str2 := copy(stringword,j,2);
j := j 1;
end
else begin
temp_str2 := copy(stringword,j,1);
end; if length(temp_str2) > 1 then begin iHandleCount := GetKeyboardLayoutList(nHKL_LIST, pList);
for i := 1 to iHandleCount do begin
if ImmEscape(pList[i], 0, IME_ESC_IME_NAME, @szImeName) > 0 then begin
sFound := QueryCompStr(pList[i], temp_str2);
if sFound <> '' then begin
if strpas(szImeName) = '注音' then begin
temp_char := sFound[1];
k := ord(temp_char);
temp_str := copy(sFound,1,2);
if k = 161 then begin
temp_char := sFound[3];
k := ord(temp_char);
temp_str := copy(sFound,3,2);
if k = 161 then begin
temp_str := copy(sFound,5,2);
end;
end;
if temp_str = 'ㄅ' then temp_str := '1';
if temp_str = 'ㄆ' then temp_str := 'q';
if temp_str = 'ㄇ' then temp_str := 'a';
if temp_str = 'ㄈ' then temp_str := 'z';
if temp_str = 'ㄉ' then temp_str := '2';
if temp_str = 'ㄊ' then temp_str := 'w';
if temp_str = 'ㄋ' then temp_str := 's';
if temp_str = 'ㄌ' then temp_str := 'x';
if temp_str = 'ㄍ' then temp_str := 'e';
if temp_str = 'ㄎ' then temp_str := 'd';
if temp_str = 'ㄏ' then temp_str := 'c';
if temp_str = 'ㄐ' then temp_str := 'r';
if temp_str = 'ㄑ' then temp_str := 'f';
if temp_str = 'ㄒ' then temp_str := 'v';
if temp_str = 'ㄓ' then temp_str := '5';
if temp_str = 'ㄔ' then temp_str := 't';
if temp_str = 'ㄕ' then temp_str := 'g';
if temp_str = 'ㄖ' then temp_str := 'b';
if temp_str = 'ㄗ' then temp_str := 'y';
if temp_str = 'ㄘ' then temp_str := 'h';
if temp_str = 'ㄙ' then temp_str := 'n';
if temp_str = 'ㄚ' then temp_str := '8';
if temp_str = 'ㄛ' then temp_str := 'i';
if temp_str = 'ㄜ' then temp_str := 'k';
if temp_str = 'ㄝ' then temp_str := ',';
if temp_str = 'ㄞ' then temp_str := '9';
if temp_str = 'ㄟ' then temp_str := 'o';
if temp_str = 'ㄠ' then temp_str := 'l';
if temp_str = 'ㄡ' then temp_str := '.';
if temp_str = 'ㄢ' then temp_str := '0';
if temp_str = 'ㄣ' then temp_str := 'p';
if temp_str = 'ㄤ' then temp_str := ';';
if temp_str = 'ㄥ' then temp_str := '/';
if temp_str = 'ㄦ' then temp_str := '-';
if temp_str = 'ㄧ' then temp_str := 'u';
if temp_str = 'ㄨ' then temp_str := 'j';
if temp_str = 'ㄩ' then temp_str := 'm';
if not null_str(temp_str) then temp_str1 := temp_str1 temp_str;
end;
end;
end;
end;
end
else begin
if not null_str(temp_str2) then temp_str1 := temp_str1 temp_str2;
end;
end; result := temp_str1;
end;
|
max5020
資深會員 發表:29 回覆:277 積分:321 註冊:2003-06-04 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |