Macro Toolworks Products Discussion Forums :: FAQ's
Welcome Guest   
 Subject :Q: How to send keystrokes to window that is not active.. 17-09-2010 12:29:41 
petr
Joined: 15-10-2009 11:48:52
Posts: 152
Location
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
Page # 


Powered by ccBoard


Login and share your experience - send messages to forums and add comments to samples, commands and other resources.



Account is free of charge, easy to setup.