Notice: This forum has been recovered from an old backup, so some content, links, and dates may be outdated. The forum is currently read-only while we restore sign-in and registration functionality. Details

If you find this forum valuable and would like to help keep it online, donations to help cover hosting and domain costs are greatly appreciated, but never expected. You can support the forum through Buy Me a Coffee or Ko-fi. Thank you for helping preserve the EventGhost community.

[solved] if window exists do A else B

Got a good idea? You can suggest new features here.
Post Reply
XkFnHLgSVDl7
Posts: 22
Joined: Wed Mar 28, 2007 12:10 pm

[solved] if window exists do A else B

Post 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).
Bartman
Plugin Developer
Posts: 881
Joined: Sun Feb 12, 2006 9:03 am

Post 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.
scat
Posts: 31
Joined: Sat May 05, 2007 12:55 pm

please post example

Post by scat »

could someone please post a example of your usage of this.

Thanks
Scat
XkFnHLgSVDl7
Posts: 22
Joined: Wed Mar 28, 2007 12:10 pm

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

Post 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
User avatar
Bitmonster
Site Admin
Posts: 2239
Joined: Mon Feb 06, 2006 10:28 pm

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

Post 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.
Please post software-related questions in the forum - PMs will only be answered, if really private, thanks!
Post Reply