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.

Trigger order

If you have a question or need help, this is the place to be.
Post Reply
vuego
Experienced User
Posts: 69
Joined: Wed Jan 17, 2007 9:22 pm
Location: Sweden

Trigger order

Post by vuego »

I've placed an event in several different folders and want them all to be triggered when a button on the remote is pressed. I thought that EventGhost would process all events from top to bottom but it looks like they get triggered in a random order. I later found out that they will be triggered in the order they were added.

Is this a feature, is it configurable or is it just me? :)
User avatar
Bitmonster
Site Admin
Posts: 2239
Joined: Mon Feb 06, 2006 10:28 pm

Post by Bitmonster »

Well, to make it even more complicated:
If you save the file and reload it, EG will use them in a top-down order. And if you use wildcard-events, they will be used last. :)

It is not really defined how they are processed. But currently you can assume that they are used in top-down order if your file is unaltered loaded. I may fix this sometime, so that added and moved events get in the right processing order.
vuego
Experienced User
Posts: 69
Joined: Wed Jan 17, 2007 9:22 pm
Location: Sweden

Post by vuego »

Ah thanks save and reload did the trick. I will have to remember that every time I move or add events.
vuego
Experienced User
Posts: 69
Joined: Wed Jan 17, 2007 9:22 pm
Location: Sweden

Post by vuego »

I've got one more related problem.

I've got three macros, with the same event, in a group. The same event is supposed to first trigger an Enable exclusive earlier and then when EventGhost processes these macros only one should be enabled. I can see in the log that this works but still the macro that was enabled before the run (which is now disabled) is triggered.

It looks like the Enable exclusive does not get applied until after the event is finished (even though it says so in the log). Is it possible to somehow change this behavior?

My goal is to control different programs with the same remote buttons in a particular order if more than one of them is running. And all this even if they are out of focus. I have it set up and running in Girder but I'd much more like to use EventGhost.

I'll attach my xml file if it helps seeing what I'm talking about

Code: Select all

<?xml version="1.0" encoding="UTF-8" ?><EventGhost Name="Configuration Tree" Version="809"><Autostart Name="Autostart"><Plugin File="Tira" Identifier="Tira">gAJLAoVxAC4=</Plugin></Autostart><Macro Name="If MP"><Event Name="Tira.060000000000"></Event><Action>Window.FindWindow(u'MediaPortal.exe', None, None, None, None, None, False, 0.0, 0)</Action><Action>EventGhost.EnableExclusive(XmlIdLink(28))</Action></Macro><Macro Name="If ZP" id="9"><Event Name="Tira.060000000000"></Event><Action>Window.FindWindow(u'zplayer.exe', None, None, None, None, 1, False, 0.0, 0)</Action><Action>EventGhost.EnableExclusive(XmlIdLink(23))</Action></Macro><Macro Name="If QCD"><Event Name="Tira.060000000000"></Event><Action>Window.FindWindow(u'QCDPlayer.exe', None, None, None, None, None, False, 0.0, 0)</Action><Action>EventGhost.EnableExclusive(XmlIdLink(18))</Action></Macro><Folder Name="Context Folder"><Folder Name="Quintessential" id="18"><Macro Name="Close"><Event Name="Tira.060000000000"></Event><Action>Window.FindWindow(u'QCDPlayer.exe', None, None, None, None, None, False, 0.0, 0)</Action><Action>Window.Close()</Action></Macro></Folder><Folder Name="ZoomPlayer" id="23" Enabled="False"><Macro Name="Exit Zoom Player"><Event Name="Tira.060000000000"></Event><Action>Window.FindWindow(u'zplayer.exe', None, None, None, None, 1, False, 0.0, 0)</Action><Action>Window.Close()</Action></Macro></Folder><Folder Name="MediaPortal" id="28" Enabled="False"><Macro Name="Close"><Event Name="Tira.060000000000"></Event><Action>Window.FindWindow(u'MediaPortal.exe', None, None, None, None, None, False, 0.0, 0)</Action><Action>Window.Close()</Action></Macro></Folder></Folder></EventGhost>
User avatar
Bitmonster
Site Admin
Posts: 2239
Joined: Mon Feb 06, 2006 10:28 pm

Post by Bitmonster »

Yes, EnableExclusive will only apply its work after the event has finished. I currently don't know why, but because I had to use a special trick to accomplish this, I'm sure I had a reason. :)

Looking at your configuration, I currently don't get the clue what you want to accomplish. Even if EnableExclusive would work directly, only one of your if-macros would be successful (the last successful one). Then it would close the application that it successfully found, leaving a "context" that points to a not running program group.
vuego
Experienced User
Posts: 69
Joined: Wed Jan 17, 2007 9:22 pm
Location: Sweden

Post by vuego »

Hehe yes I could've been more clear.
I'm sure most people would just create a "switch button" on their remote and then manually choose which program to control. But I always know which program should be controlled based on which programs are running. I don't find invisible switch buttons WAF friendly. :)

If only Mediaportal is running then keys should be sent there obviously. If I've also started Zoomplayer (from within MP, then ZP would be placed in front but might not be in focus) then keys should be sent to ZP but not MP. When I press Power on the remote ZP should close and I will end up in MP. Press Power again and MP will shut down.
That's why I need to trigger an Enable exclusive first and then trigger again in the enabled group. I do leave an enabled group of a program that's just been shut down but it doesn't matter since the next event would Enable exclusive another group.

Maybe I could've used Task Create/Switch Event but I wouldn't wanna disable all other groups when a new program is started. Sometimes I listen to music while watching tv and then I would like play/pause, next/prev track and power to be sent to QCD and all other buttons to MP.

This is the way it had to be done in Girder and maybe there's a much easier way to do it in EventGhost that I haven't thought of...? :oops:
User avatar
Bitmonster
Site Admin
Posts: 2239
Joined: Mon Feb 06, 2006 10:28 pm

Post by Bitmonster »

vuego wrote:Press Power again and MP will shut down.
Possibly this was the reason why I have made EnableExclusive with delayed execution. If I have a Zoom Player group for example enabled and then close the program, I would enable another group to take control (maybe generic keyboard context). If EnableExclusive would do it immediately, the event would go to the fresh enabled keyboard group and execute an Alt+F4 also.

Back to your problem:
Actually most people use the task plugin to switch groups. This also has the benefit, that the state would also be right if you started the program outside EG (with the mouse for example).

Your goal is a bit more complicated, as you want to have states that take more then one application into account. But it could be done with context folders inside context folders. A folder structure like this:

Code: Select all

Context Folder
    TV
        Music context
            with music
            without music
    Music
    Zoom Player
 
Now you have to take care, that if your music application starts, you have to EnableExclusive "Music" and also "TV/Music context/with music" and if it terminates to EnableExclusive "TV/Music context/without music".
If now your TV app is starting, it will enable the TV context but the music context inside it is already set. So play/pause macros inside "with music" will take care of the music app. If your music app was not started, the "without music" folder will take care of the events and do something else.

Do you basically get the point I'm talking about?
Last edited by Bitmonster on Thu Jan 18, 2007 10:48 pm, edited 1 time in total.
User avatar
Bitmonster
Site Admin
Posts: 2239
Joined: Mon Feb 06, 2006 10:28 pm

Post by Bitmonster »

Another way is to use scripting and decide what to do with some variables. You can for example build task.created/task.destroyed macros with a PythonCommand setting a variable:

Code: Select all

Macro
    Event: Task.Created.zplayer
    Action: PythonCommand: ZP_isRunning = True

Macro
    Event: Task.Destroyed.zplayer
    Action: PythonCommand: ZP_isRunning = False
And so on for every application you want to take into account.
Now you can build a single macro for your Play button:

Code: Select all

Macro
    Event: Tira.Play
    Action: PythonCommand: ZP_isRunning
    Action: Jump (on success, without return): (to a macro that processes play for ZP)
    Action: PythonCommand: TV_isRunning and QCD_isRunning
    Action: Jump (on success, without return): (to a macro that processes play for QCD)
    # nothing matches so we do the default action
    Action: FindWindow: MediaPortal.exe
    Action: EmulateKeystrokes: {Whatever key is used for Play in MediaPortal}
So this is more based on the event. Actually it could also be done with FindWindow decisions. but I don't like it. FindWindow is a relative "expensive" action as it has to do a lot of computation. To do it on every keypress for every application would waste a lot CPU cycles.
vuego
Experienced User
Posts: 69
Joined: Wed Jan 17, 2007 9:22 pm
Location: Sweden

Post by vuego »

This is great!
I went for option #1. Also made a "Startup" group which enables the program group I desire when EG launches based on which programs are running. This means that I may restart EG at any time and it will return to an updated state even if it missed some Task Create/Switch Events. I also trigger the "Startup event" when closing any of my programs to enable exclusive the next running program. If none of them are running a "None" group will be enabled which contains a Run MediaPortal command triggered by the Power button :)

Anyway I just wanted to say thanks for a great product and the first class support here at the forums. EventGhost beats Girder in every aspect i can think of.
Keep up the good work :!:
User avatar
Bitmonster
Site Admin
Posts: 2239
Joined: Mon Feb 06, 2006 10:28 pm

Post by Bitmonster »

Btw: The new betas maintain the right processing order even if items are added or moved.
Post Reply