I am a newby with a very basic question. I have a set of macros that I only want to run when a specific program is in the foreground. I don't want MS to bring it to the foreground then run the macro, I want the macro ended if the program isn't in the foreground, and run only if it's currently in the foreground. How do I do this?? I've tried:
Let>WW_TIMEOUT=1
WaitWindowOpen>Qimage [v2003.277]
If>WW_RESULT=FALSE,End
but the macro still seems to run outside of Qimage. I can put a SetFocus at the top, but I don't want the macro to run when I'm not already in Qimage.
Thanks ... Aaron
windows specific macro, ends if window not in focus
Moderators: Dorian (MJT support), JRL
You have the right idea. Use the "IfWindowOpen" command to see if it's already open.
(It sounds like you don't want to wait until the window opens, you just want to see if it's there or not).
Or, if it's only to check if the window is in the foreground (and not in the background), use the "GetActiveWindow" command to find out which window has focus, which can return the window title. You can then use "Position" command to see if that string contains the substring "Qimage". (If it doesn't, the value will be 0)
You have a lot of options as to exactly what you want... if the window is open, if it's in focus, etc.
(It sounds like you don't want to wait until the window opens, you just want to see if it's there or not).
Or, if it's only to check if the window is in the foreground (and not in the background), use the "GetActiveWindow" command to find out which window has focus, which can return the window title. You can then use "Position" command to see if that string contains the substring "Qimage". (If it doesn't, the value will be 0)
You have a lot of options as to exactly what you want... if the window is open, if it's in focus, etc.
Thanks for the help. I'm only wanting to check if Qimage is in the foreground. In other words, if I'm working in Photoshop and I hit my hotkey by accident, I don't want the macro to run. I don't want the marco to set focus to Qimage and run either, because I need to already be working in Qimage and point to a file with my mouse, then run the macro which effects that file. Seems like there should be an idiot switch during macro record that says " only run this macro while xx window is running and in the foreground"Captive wrote:You have the right idea. Use the "IfWindowOpen" command to see if it's already open.
(It sounds like you don't want to wait until the window opens, you just want to see if it's there or not).
Or, if it's only to check if the window is in the foreground (and not in the background), use the "GetActiveWindow" command to find out which window has focus, which can return the window title. You can then use "Position" command to see if that string contains the substring "Qimage". (If it doesn't, the value will be 0)
You have a lot of options as to exactly what you want... if the window is open, if it's in focus, etc.
But anyway, I can't figure out how to use "GetActiveWindow" and "Position" to get the result I want. The help file doesn't give much of a beginners explanation or examples. In longhand this is what I want.
GetActiveWindow
if the result above is Qimage* then...
run the rest of my macro
if it's not, pop a message that allows me to abort the macro
... Aaron
- Bob Hansen
- Automation Wizard
- Posts: 2475
- Joined: Tue Sep 24, 2002 3:47 am
- Location: Salem, New Hampshire, US
- Contact:
You wrote:
Try something like this:In longhand this is what I want.
GetActiveWindow
if the result above is Qimage* then...
run the rest of my macro
if it's not, pop a message that allows me to abort the macro
A prompt message is not needed, the macro will end automatically.GetActiveWindow>InFront,X,Y
If>%InFront%=Qimage*,DoRest,End
Label>DoRest
.....
.....
.....
.....
Label>End
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!
Bob
A humble man and PROUD of it!
Wow, thanks! It works perfectly. ... Aaronbob hansen wrote:You wrote:Try something like this:In longhand this is what I want.
GetActiveWindow
if the result above is Qimage* then...
run the rest of my macro
if it's not, pop a message that allows me to abort the macroA prompt message is not needed, the macro will end automatically.GetActiveWindow>InFront,X,Y
If>%InFront%=Qimage*,DoRest,End
Label>DoRest
.....
.....
.....
.....
Label>End