Is it possible to make a macro work only on a specific window and alow me to use the computer freely?
I want the code to press a few keys every 10 sec while i do something else.
Make Macros work on a specific window
Moderators: Dorian (MJT support), JRL, Phil Pendlebury
Re: Make Macros work on a specific window
Hi, you could possibly use ObjectSendKeys> which allows you to send keystrokes without the object being in focus. Eg, The following will send text to Notepad even though I am doing something else (Notepad needs to be open). Check the Code Builder Wizard.
Code: Select all
GetWindowHandle>Untitled - Notepad,hWndParent
FindObject>hWndParent,Edit,,1,hWnd,X1,Y1,X2,Y2,result
ObjectSendKeys>hWnd,{"This is a test"}
Re: Make Macros work on a specific window
Will it work with keys like F1, F2, TAB and Shift?
That seems to work with text only
That seems to work with text only
Re: Make Macros work on a specific window
You can send both, check this link for codes: http://www.mjtnet.com/vkcodes.htm
I modified the previous example. Depending on what/where you send you may need to add some Wait>x (eg after pressing F1 below). As you see you can send one or more items (comma separated) per ObjectSendKeys> - you can play with it and see what works best in your case.
I modified the previous example. Depending on what/where you send you may need to add some Wait>x (eg after pressing F1 below). As you see you can send one or more items (comma separated) per ObjectSendKeys> - you can play with it and see what works best in your case.
Code: Select all
GetWindowHandle>Untitled - Notepad,hWndParent
FindObject>hWndParent,Edit,,1,hWnd,X1,Y1,X2,Y2,result
//Text Keys
Let>Mess1={"This is text 1"}
Let>Mess2={"Text 2"}
Let>Mess3={"The End!"}
//Other Keys
Let>strTab=VK9
Let>strReturn=VK13
Let>strF1=VK112
ObjectSendKeys>hWnd,Mess1
ObjectSendKeys>hWnd,strTab,strTab
ObjectSendKeys>hWnd,Mess2
ObjectSendKeys>hWnd,strReturn,strReturn
ObjectSendKeys>hWnd,Mess3,strReturn
ObjectSendKeys>hWnd,strF1