Page 1 of 1

Start Application - Ignore if already running option

Posted: Sun May 25, 2008 5:21 pm
by katana80
I use the Start Application action to start an app. Sometimes I start the app when it is already running or would like to use the same button to start the app as well as get focus back to the app when it is already running. Depending on the application, if you run an app already running it might display an error or message ("instance already running", etc).

My feature suggestion is to provide a check box (just like the "wait till app is terminated before proceed") for the option to "ignore if application is already running".

I'm sure there is a simple way to do this using python script and conditional jumps with find window function (if possible can you provide an example?)

But I think the feature is also basic and standard enough to be in future releases.

Thanks.
katana80

Re: Start Application - Ignore if already running option

Posted: Sun May 25, 2008 7:00 pm
by bskchaos
Try playing with this... Action -> Window -> Find a window

Re: Start Application - Ignore if already running option

Posted: Sun May 25, 2008 9:21 pm
by katana80
bskchaos:

Thx for the reply. Yeah I tried playing around with the already existing Find Window action.
That action works nice when you already expect the window (application) to be up and running.
And you can specify to 'ABORT if window is NOT FOUND'.

But it doesn't provide the inverse option of 'ABORT if the window IS FOUND' or 'CONTINUE if window is NOT FOUND' ... which is basically what I want.

Re: Start Application - Ignore if already running option

Posted: Mon May 26, 2008 3:47 pm
by topix
Or you could use Task.(created|activated|deactivated...) to enable/disable different macros for the same event.

Re: Start Application - Ignore if already running option

Posted: Tue May 27, 2008 1:09 am
by User
In my case, I just use this:

+Macro: Green - Start
  • Event: HID.Button.15
  • Action: Find Window: MediaPortal.exe
  • Action: Jump - if (above action) sucessful jump to "Green - MediaPortal Home"
  • Action: Jump - if (above action) unsucessful jump to "Green - Run MediaPortal"
+Macro: Green - MediaPortal Home
  • Action: Find Window: MediPortal.exe
  • Emulate Keystroke: h
+Macro: Green - Run MediaPortal
  • Start Program: MediaPortalLoader.bat
    *Where this bat is where I configure to disable the monitor shutdown timeout, etc.

Or, in xml style:

Code: Select all

<?xml version="1.0" encoding="UTF-8" ?>
<EventGhost Version="1399">
    <Macro Name="Green - Start">
        <Event Name="HID.Button.15" />
        <Action>
            Window.FindWindow(u'MediaPortal.exe', None, None, None, None, None, False, 0.0, 2)
        </Action>
        <Action>
            EventGhost.NewJumpIf(XmlIdLink(74), 0, False)
        </Action>
        <Action>
            EventGhost.NewJumpIf(XmlIdLink(77), 1, False)
        </Action>
    </Macro>
    <Macro Name="Green -  MediaPortal Home" id="74">
        <Action>
            Window.FindWindow(u'MediaPortal.exe', None, None, None, None, None, False, 0.0, 2)
        </Action>
        <Action>
            Window.SendKeys(u'h', False)
        </Action>
    </Macro>
    <Macro Name="Green - Run MediaPortal" id="77">
        <Action>
            System.Execute(u'C:\\Program Files\\Team MediaPortal\\MediaPortalLoader.bat', u'', 3, False, 2, u'')
        </Action>
    </Macro>
</EventGhost>

PS: I just love this software =D

Re: Start Application - Ignore if already running option

Posted: Tue May 27, 2008 7:46 am
by katana80
User:

Thanks so much! Yes that is exactly what I wanted! I can't believe I overlooked such a useful feature. The more I familiarize myself with what's possible with EventGhost the more I love this software. Time to go reconfigure my macros again!

Re: Start Application - Ignore if already running option

Posted: Sun May 03, 2009 6:00 pm
by mfsav2
User wrote:In my case, I just use this:

+Macro: Green - Start
  • Event: HID.Button.15
  • Action: Find Window: MediaPortal.exe
  • Action: Jump - if (above action) sucessful jump to "Green - MediaPortal Home"
  • Action: Jump - if (above action) unsucessful jump to "Green - Run MediaPortal"
+Macro: Green - MediaPortal Home
  • Action: Find Window: MediPortal.exe
  • Emulate Keystroke: h
+Macro: Green - Run MediaPortal
  • Start Program: MediaPortalLoader.bat
    *Where this bat is where I configure to disable the monitor shutdown timeout, etc.
I've done exactly the same but it hangs on the Find Window.
It does not go on.

can you help me ?

Re: Start Application - Ignore if already running option

Posted: Sun May 03, 2009 10:27 pm
by jinxdone
You probably have the "stop macro if target is not found" checkbox turned on in the find window acition's config

Re: Start Application - Ignore if already running option

Posted: Mon May 04, 2009 8:13 am
by mfsav2
jinxdone wrote:You probably have the "stop macro if target is not found" checkbox turned on in the find window acition's config
I have not seen that flag in the config... where is it ?

Re: Start Application - Ignore if already running option

Posted: Mon May 04, 2009 9:58 am
by jinxdone
+Macro: Green - Start

* Event: HID.Button.15
* Action: Find Window: MediaPortal.exe <---- here
* Action: Jump - if (above action) sucessful jump to "Green - MediaPortal Home"
* Action: Jump - if (above action) unsucessful jump to "Green - Run MediaPortal"
Configure the "find window" action. The checkbox is in the top portion of the config window.

Re: Start Application - Ignore if already running option

Posted: Fri Oct 31, 2014 5:33 am
by eyal670
Hi
here an example of what you need with tow different apps running based on autoremote and tasker app from android phone

Code: Select all

<?xml version="1.0" encoding="UTF-8" ?>
<EventGhost Version="1669">
    <Folder Name="web development">
        <Macro Name="check if running" Expanded="True">
            <Event Name="AutoRemote.Message.web" />
            <Action>
                Window.FindWindow(u'AptanaStudio3.exe', None, None, None, None, None, False, 0.0, 2)
            </Action>
            <Action>
                EventGhost.NewJumpIf(XmlIdLink(34), 1, True)
            </Action>
            <Action>
                EventGhost.NewJumpIf(XmlIdLink(26), 0, True)
            </Action>
            <Action>
                Window.FindWindow(u'navicat.exe', None, None, None, None, None, False, 0.0, 2)
            </Action>
            <Action>
                EventGhost.NewJumpIf(XmlIdLink(30), 1, False)
            </Action>
        </Macro>
        <Macro Name="maximaiz aptana" id="26" Expanded="True">
            <Action>
                Window.FindWindow(u'AptanaStudio3.exe', None, None, None, None, None, False, 0.0, 0)
            </Action>
            <Action>
                Window.Maximize()
            </Action>
            <Action>
                Window.BringToFront()
            </Action>
        </Macro>
        <Macro Name="start navicat" id="30" Expanded="True">
            <Action>
                System.Execute(u'C:\\Program Files (x86)\\Navicat Lite 8.2\\navicat.exe', u'', 0, False, 2, u'', False, False)
            </Action>
            <Action>
                EventGhost.Wait(3.0)
            </Action>
            <Action>
                Window.Minimize()
            </Action>
        </Macro>
        <Macro Name="start aptana" id="34" Expanded="True">
            <Action>
                System.Execute(u'C:\\Users\\Eyal\\AppData\\Local\\Aptana Studio 3\\AptanaStudio3.exe', u'', 0, False, 2, u'', False, False)
            </Action>
        </Macro>
    </Folder>
</EventGhost>