开发者

delphi send key into an invisible process [duplicate]

This question already has answers here: 开发者_Go百科 How do I send key strokes to a window without having to activate it using Windows API? (3 answers) Closed 10 years ago.

The goal is to send the Q key press to an invisible process (that does not have focus) : I know the process ID.

I know how to send keys to a visible application. Can this be done to an hidden application ?


I assume, that your invisible process has a window, which just happen to be invisible (it could for example have been hidden through a call to ShowWindow with SW_HIDE als parameter) and that you want to send keystrokes using SendMessage/PostMessage.

I would suggest to try the following:

  1. Enumerate all main windows using EnumWindows.
  2. For each window check if it belongs to your process using GetWindowThreadProcessId.
  3. As soon as you have found the main window of your process, send your Keystrokes using SendMessage or PostMessage.

A hidden window should be able to receive keystokes as good as a visible window and most application probably don't check if they are really visible before reacting, so that there are good chances that it works.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜