delphi

Input multiple byte characters with keybd_event:

knoen 2019. 12. 20. 01:51
procedure InsertText(text:string);
var i:integer;
    j:integer;
    ch:byte;
    str:string;
begin
  i:=1;
  while i<=Length(text) do
  begin
    ch:=byte(text[i]);
    if Windows.IsDBCSLeadByte(ch) then
       begin
         Inc(i);
         str:=inttostr(MakeWord(byte(text[i]), ch));
         keybd_event(VK_MENU, MapVirtualKey(VK_MENU, 0), 0, 0);
         j:=1;
         while j<=Length(str) do
         begin
               keybd_event(96+strtoint(str[j]), MapVirtualKey(96+strtoint(str[j]), 0), 0, 0);
               keybd_event(96+strtoint(str[j]), MapVirtualKey(96+strtoint(str[j]), 0), 2, 0);
               j:=j+1;
         end;
         keybd_event(VK_MENU, MapVirtualKey(VK_MENU, 0), KEYEVENTF_KEYUP, 0);
       end
    else begin
           keybd_event(VkKeyScan(text[i]),0,0,0);
           keybd_event(VkKeyScan(text[i]),0,2,0);
         end;
    Inc(i);
  end;
end;

https://stackoverflow.com/questions/7454417/send-text-to-other-applications


'delphi' 카테고리의 다른 글

fast finding of small image in a bigger image  (0) 2020.02.16
shellexecute  (0) 2020.02.16
How to disable specific global hotkeys in Windows  (0) 2019.11.03
send keys for unicode  (0) 2019.07.22
다른 개발언어용 dll 만들기  (0) 2019.04.24