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.

Remap button if application is running

If you have a question or need help, this is the place to be.
Post Reply
User avatar
level20peon
Posts: 24
Joined: Sun Dec 02, 2007 2:58 pm

Remap button if application is running

Post by level20peon »

Hey guys,

I would like to remap specific buttons when a specific application is running.

So if I click the "Up" Button on my JoyPad I would like to send a Keyboard "Cursor up" if the process "test.exe" exists and the process "test2.exe" doesn't exist.

Any ideas how I could realize this ??

Mapping keys to keys on other devices isn't the problem... I know the basics of event-ghost, but I don't know how to script this scenario.

In AutoIt the code looks like this:

Code: Select all

	While JoyMoveUp (1) OR JoyMoveUp (2) OR JoyMoveUp (3) OR JoyMoveUp (4)
		sleep (75)
		If not ProcessExists("testexe") AND not ProcessExists("test2.exe") Then
		send("{UP}")
		EndIf
	WEnd
This emulates a keyboard stroke (UP) everytime I press the "UP" button on one of my four joypads. I wanted to migrate this to EventGhost because looping this script in AutoIt uses quite some CPU time.


Thanks for any suggestions

-level20peon
Bartman
Plugin Developer
Posts: 881
Joined: Sun Feb 12, 2006 9:03 am

Re: Remap button if application is running

Post by Bartman »

You can look for the window if the fiind window and a conditional jump macro or use the task plugin to switch between to folders of macros.
User avatar
level20peon
Posts: 24
Joined: Sun Dec 02, 2007 2:58 pm

Re: Remap button if application is running

Post by level20peon »

Yes this was the way I already tried but there seems to be something wrong with the code. The {Up} is always sent, no matter if or what of the two processes exists. Any clue ?

Code: Select all

<?xml version="1.0" encoding="UTF-8" ?>
<EventGhost Version="908">
    <Macro Name="Remap" Expanded="True">
        <Event Name="PAD 2.Value.15">
        </Event>
        <Action>
            Window.FindWindow(u'test.exe', None, None, None, None, None, True, 0.0, 2)
        </Action>
        <Action Name="gg.exe gefunden">
            EventGhost.NewJumpIf(XmlIdLink(-1), 0, False)
        </Action>
        <Action>
            Window.FindWindow(u'test2.exe', None, None, None, None, None, False, 0.0, 2)
        </Action>
        <Action>
            Window.SendKeys(u'{Up}', False)
        </Action>
        <Action>
            EventGhost.AutoRepeat(0.10000000000000001, 0.10000000000000001, 0.10000000000000001, 0.10000000000000001)
        </Action>
    </Macro>
</EventGhost>
-level20peon
User avatar
level20peon
Posts: 24
Joined: Sun Dec 02, 2007 2:58 pm

Re: Remap button if application is running

Post by level20peon »

I now got what I wanted. I implemented jump markers in a totally wrong way. Thanks anyways :mrgreen:


-level20peon
mfsav2
Posts: 9
Joined: Tue Apr 28, 2009 11:00 pm

Re: Remap button if application is running

Post by mfsav2 »

How did you do that?

I'm now able to have it, find window hangs the sequence if application is not running
User avatar
level20peon
Posts: 24
Joined: Sun Dec 02, 2007 2:58 pm

Re: Remap button if application is running

Post by level20peon »

Here's an excerpt of my current script, maybe it helps:

Code: Select all

<?xml version="1.0" encoding="UTF-8" ?>
  <EventGhost Name="Konfigurations-Baum" Expanded="True" Version="1262" Guid="{910D6DB5-250B-4809-B05D-040807A74088}" Time="1209900693.52">
    <Autostart Name="Autostart" Expanded="True">
	  <Plugin File="HID" Identifier="HID">...</Plugin>
	  <Plugin File="HID" Identifier="HID7">...</Plugin>
	  <Plugin Enabled="False" File="HID" Identifier="HID2">...</Plugin>
	  <Plugin Enabled="False" File="HID" Identifier="HID3">...</Plugin>
	  <Plugin Enabled="False" File="Joystick" Identifier="Joystick">gAIpLg==</Plugin>
	</Autostart>
	
	<Folder Name="{UP}">
	  <Macro Name="{UP}">
	    <Event Name="Joystick.Up"></Event>
		<Action>Window.FindWindow(u'gg.exe', None, None, None, None, None, True, 0.0, 2)</Action>
		<Action Name="gg.exe nicht gefunden">EventGhost.NewJumpIf(XmlIdLink(86), 1, False)</Action>
	  </Macro>
	  <Macro Name="{UP}" id="86">
	    <Action>Window.FindWindow(u'mame.exe', None, None, None, None, None, True, 0.0, 2)</Action>
		<Action Name="mame.exe nicht gefunden">EventGhost.NewJumpIf(XmlIdLink(89), 1, False)</Action>
	  </Macro>
	  <Macro Name="{UP}" id="89">
	    <Action>Window.SendKeys(u'{Up}', False)</Action>
		<Action>EventGhost.AutoRepeat(0.40000000000000002, 0.0, 0.0, 0.0)</Action>
	  </Macro>
	</Folder>
	
  </EventGhost>
Post Reply