7.3恢复德鲁伊怎么样:向指定HWND发送字符串

来源:百度文库 编辑:偶看新闻 时间:2024/05/06 10:34:37

向指定HWND发送字符串

分类: Delphi 2008-10-04 14:57 98人阅读 评论(0) 收藏 举报  
  1. procedure SendKeys(focushld: hwnd; sSend: string);
  2. var
  3.   i: integer;
  4.   ch: byte;
  5. begin
  6.   if focushld = 0 then Exit;
  7.   i := 1;
  8.   while i <= Length(sSend) do
  9.   begin
  10.     ch := byte(sSend[i]);
  11.     if Windows.IsDBCSLeadByte(ch) then
  12.     begin
  13.       Inc(i);
  14.       SendMessage(focushld, WM_IME_CHAR, MakeWord(byte(sSend[i]), ch), 0);
  15.     end
  16.     else
  17.       SendMessage(focushld, WM_IME_CHAR, word(ch), 0);
  18.     Inc(i);
  19.   end;
  20.   postmessage(focushld, WM_keydown, 13, 0); //按回车键
  21. end;