Pergunta

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.

Foi útil?

Solução

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)

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top