TTouchKeyboard: send keystroke to other program?

喜你入骨 提交于 2019-12-07 05:56:55

问题


How do I use TTouchKeyboard in Delphi, so it could send keystrokes to other program. For example, I want to type password in a browser using TTouchKeyboard component. I have no idea how make the browser stay focus while I'm clicking on my keyboard.


回答1:


TTouchKeyboard sends the keys to the current control focused: so if you have a TEdit with the focus, the TEdit will receive the key...

You can create a form which contains the TTouchKeyboard and add this procedure:

  protected
    procedure CreateParams(var Params: TCreateParams); override;

...

procedure TForm1.CreateParams(var Params: TCreateParams);
begin
  inherited CreateParams(Params);
  with Params do
  begin
    ExStyle   := ExStyle or WS_EX_NOACTIVATE;
    WndParent := GetDesktopwindow;
  end;
end;

Your form can't have the focus... so, the key is sent to the previous focused control. (I have just tested it and it works: the key has been sent to this webpage)



来源:https://stackoverflow.com/questions/7509704/ttouchkeyboard-send-keystroke-to-other-program

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!