TTouchKeyboard: send keystroke to other program?
Asked Answered
O

1

5

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.

Organzine answered 22/9, 2011 at 4:50 Comment(0)
S
10

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)

Swinger answered 22/9, 2011 at 7:47 Comment(2)
Bingo! WS_EX_NOACTIVATE is what I need.Organzine
This does not seem to work for me, in that the control loses the focus when I press on a key on the virtual keyboard. What am I missing? I'm using XE2 in this case.Gentoo

© 2022 - 2024 — McMap. All rights reserved.