Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TTouchKeyboard: send keystroke to other program?

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.

like image 478
user Avatar asked Sep 22 '11 04:09

user


1 Answers

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)

like image 142
Whiler Avatar answered Oct 08 '22 13:10

Whiler