|
|
Q: How to send keystrokes to window that is not active
A: In Windows it is not basically possible to send keystrokes to a window that is not active.
However, it is possible to make a window active while it does not overlap window that is currently
active and showing on top of other windows on the computer screen. The example here
activates "Notepad" window and sends "Hello Notepad!" text to it while the currently
active window is still showing on top and Notepad window does not overlap it.
The macro expects that Notepad is running. The macro was developed and tested in Windows 7.
<cmds>
<#> Remeber what window is currently active
<varset>("vActiveWnd=_vActiveWindow_HWND","")
<#> Make the active window "always on top"
<winstate>("_vActiveWindow_HWND","ALWAYS_TOP")
<#> Activate Notepad window...
<actwin>("Notepad",0,0,"no")
<#> ... and send the keystrokes
<keys>Hello to Notepad!<cmds>
<#> Then activate the originaly active window again...
<actwin>("vActiveWnd",0,0,"no")
<#> ... and make it "not always on top"
<winstate>("vActiveWnd","NOT_ALWAYS_TOP") |
IP Logged
|
|
Last Edited On: 17-09-2010 12:30:07 By petr for the Reason |