Page 1 of 1

[solved] if window exists do A else B

Posted: Tue Jun 19, 2007 9:58 pm
by XkFnHLgSVDl7
Hi,
just trying to figure out how to do this (guess it's in and I just can't find it):
If test.exe is running it should be closed, if it isn't it should be started.
I can make the "if" check work, but can't figure out how to do the "else" part.

Thanks in advance,
Lars

EDIT: just figured it out: create 2 macros (1+2) with the same event, and one without (3) an event. set (1) to find window and make it jump to (3). if the window isn't found (2) is run. don't forget to enable (1) and (2) in (3).

Posted: Wed Jun 20, 2007 7:09 am
by Bartman
You can do the if part with a conditional jump which does not return to the original macro and just place the else part after the conditional jump.

please post example

Posted: Tue Jun 26, 2007 9:21 am
by scat
could someone please post a example of your usage of this.

Thanks
Scat

Re: [solved] if window exists do A else B

Posted: Sun Jul 08, 2007 4:37 pm
by XkFnHLgSVDl7
this detects whether DScaler.exe is running, if yes it closes it, if not it starts D:\Media\DScaler\DScaler.bat

Code: Select all

<Macro Name="Close DScaler" id="88">
<Action>Window.Close()</Action>
</Macro>

<Macro Name="DScaler running?" id="92">
<Event Name="Keyboard.LShift+LCtrl+LAlt+M"></Event>
<Action>Window.FindWindow(u'DScaler.exe', None, None, None, None, None, False, 0.0, 2)</Action>
<Action>EventGhost.NewJumpIf(XmlIdLink(88), 0, False)</Action>
<Action>System.Execute(u'D:\\\\Media\\DScaler\\DScaler.bat', u'', 3, False, 2, u'')</Action>
<Action>EventGhost.AutoRepeat(1.0, 1.0, 0.01, 3.0)</Action>
</Macro>
edit: oops, had a small bug in there, fixed now

Re: [solved] if window exists do A else B

Posted: Tue Jul 10, 2007 2:01 pm
by Bitmonster
The code above is not suitable for pasting. You need to stuff the macros into a folder, then copy this folder and paste it here unmodified.