WPF: How to interact with an inactive window?

Can I interact with an inactive window from another window? I want to focus the text box in the window without making it active, and then send it keystrokes and mouse events. It seems that you can send messages to inactive windows using SendMessage, but is it also possible to focus the text field in the window and send keystrokes to it without starting this window?

+5
source share
2 answers

Look at the same question, which is slightly different from here.

Quote @Kevin Montrose: "Windows assumes that the activation window is the one that receives keyboard input. The correct way to fake keyboard input is SendInput, and you will notice that it only sends messages to the active window."

+1
source

Have you looked UI Automation ?

Getting a template and calling it is not that difficult. The only thing I'm not sure is whether the window will receive focus.

Of course, this will only work in one process.

0
source

All Articles