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.

Kill app with key and switch focus

If you have a question or need help, this is the place to be.
Post Reply
martinconroy
Posts: 3
Joined: Tue Apr 12, 2016 8:50 pm

Kill app with key and switch focus

Post by martinconroy »

Hi,
Tried looking at the scripting of this but finding a little daunting so wondering if anyone can help?

I use Kodi and am launching Chrome in Kiosk mode using Advanced launcher. What I would like to do is to press the Esc on my keyboard to kill the Chrome process (i.e. replicate Alt+F4) and then return focus to Kodi.

I'm confused as to:
a) whether I need to use EventGhost to launch Chrome itself
b) whether I can bind a key ONLY when a certain app (Chrome) is running - i.e. so Esc doesn't always replicate Alt+F4
c) how to ensure Kodi is then put in focus

The closer someone can get me to a final solution would be appreciated. I'm better at deciphering a final solution to work things out that put together from scratch!

Really appreciate any help offered.
martinconroy
Posts: 3
Joined: Tue Apr 12, 2016 8:50 pm

Re: Kill app with key and switch focus

Post by martinconroy »

Actually I bizarrely stumbled upon a solution to this and it seems perfect. For those who might find it of use my XML is below

Code: Select all

<?xml version="1.0" encoding="UTF-8" ?>
<EventGhost Version="1722" Guid="{6C9000B6-FD67-403B-A817-238AF3742D68}" Time="1460498954.99">
    <Autostart Name="Autostart" Expanded="True">
        <Plugin Identifier="Task" Guid="{D1748551-C605-4423-B392-FB77E6842437}" File="Task">
            gAIpLg==
        </Plugin>
        <Plugin Identifier="Keyboard" Guid="{59CBD10F-C1D8-4ADB-999B-9B76BA360F1F}" File="Keyboard">
            gAKIhXEALg==
        </Plugin>
    </Autostart>
    <Macro Name="Kill Chrome and switch to Kodi" Expanded="True">
        <Event Name="Keyboard.Escape" />
        <Action>
            Window.FindWindow(u'chrome.exe', None, None, None, None, None, False, 0.0, 0)
        </Action>
        <Action>
            Window.Close()
        </Action>
        <Action>
            Window.FindWindow(u'Kodi.exe', None, None, None, None, None, False, 0.0, 0)
        </Action>
        <Action>
            Window.BringToFront()
        </Action>
    </Macro>
</EventGhost>
martinconroy
Posts: 3
Joined: Tue Apr 12, 2016 8:50 pm

Re: Kill app with key and switch focus

Post by martinconroy »

In fact - have now updated further to only have Chrome killed with Escape when Kodi is running:

Code: Select all

<?xml version="1.0" encoding="UTF-8" ?>
<EventGhost Version="1722" Guid="{67DA3FC9-AE0E-4EBD-827B-FF69A853CC1E}" Time="1460549750.76">
    <Autostart Name="Autostart">
        <Plugin Identifier="Task" Guid="{D1748551-C605-4423-B392-FB77E6842437}" File="Task">
            gAIpLg==
        </Plugin>
        <Plugin Identifier="Keyboard" Guid="{59CBD10F-C1D8-4ADB-999B-9B76BA360F1F}" File="Keyboard">
            gAKIhXEALg==
        </Plugin>
        <Action>
            EventGhost.DisableItem(XmlIdLink(5))
        </Action>
    </Autostart>
    <Macro Name="Enable Chrome killer when Kodi launched">
        <Event Name="Task.Activated.Kodi" />
        <Action>
            EventGhost.EnableItem(XmlIdLink(5))
        </Action>
    </Macro>
    <Macro Name="Disable Chrome killer when Kodi closed" Expanded="True">
        <Event Name="Task.Destroyed.Kodi" />
        <Action>
            EventGhost.DisableItem(XmlIdLink(5))
        </Action>
    </Macro>
    <Macro Name="Kill Chrome and switch to Kodi" id="5">
        <Event Name="Keyboard.Escape" />
        <Action>
            Window.FindWindow(u'chrome.exe', None, None, None, None, None, False, 0.0, 0)
        </Action>
        <Action>
            Window.Close()
        </Action>
        <Action>
            Window.FindWindow(u'Kodi.exe', None, None, None, None, None, False, 0.0, 0)
        </Action>
        <Action>
            Window.BringToFront()
        </Action>
    </Macro>
</EventGhost>
Post Reply