Chaining events

If you have a question or need help, this is the place to be.
Post Reply
Mandamus
Posts: 7
Joined: Sat Mar 30, 2019 5:50 pm

Chaining events

Post by Mandamus » Sat Mar 30, 2019 5:58 pm

I've been playing around and I can't figure out how to chain events.

For example, I want to perform and action when I hit 111 on my IR remote control through the Microsoft MCE remote plugin.
I've got the HID service disabled, so the events come through as MceRemote.num1 and that's all fine. I can make it do stuff on one click of the 1. But what about 111?

edit: for purposes of explanation I used 111. But for realsies, the actual incoming events to chain for this example would be
MceRemote.Num1
MceRemote.Num1
MceRemote.Num1

I did a search and it might be called something else, but nothing comes up for "chaining events"

Please help.

PS. Why the heck isn't this program more popular? I've been looking for a "tasker replacement" for windows for quite a while and this program fits the bill perfectly and I just stumbled across it the other day. I've got it hooked up and running and connected to my main server via MQTT and all things considered, should have it dancing and singing in short order. It's perfect. So what's the deal? Is it just poor PR?

Mandamus
Posts: 7
Joined: Sat Mar 30, 2019 5:50 pm

Re: Chaining events

Post by Mandamus » Sun Mar 31, 2019 4:25 pm

Solved my own problem. created a script that sequences events and records the results and triggers one main event when conditions are met.

For example. I have my Microsoft MCE remote setup and the HID disabled. so I get the events as "MceRemote.Num1" or "MceRemote.Num2", etc.

The script strips out the number from the suffix to get "1", "2", etc.
It shows an OSD to display the current status of the reading. (you can delete that if you want)
once it has collected 3 values, it sequences them and fires an event called "Main.3keypress" with the payload being the 3 number sequence.
Which would look like this.

Main.3keypress '123'

which you would then handle like any other event.

Here's the code. I think you should just be able to copy it and paste it into the IDE(are we calling it the IDE, I don't know. I'm new here)
<?xml version="1.0" encoding="UTF-8" ?>
<EventGhost Version="0.5.0-rc6">
<Macro Name="multiple event chain" XML_Guid="{1BEF5C86-23D4-48FF-82B5-3A69C9D6629A}" Expanded="True">
<Event Name="MceRemote.Num1" XML_Guid="{20931D38-35E0-4056-B1C8-B4782DD32103}" />
<Event Name="MceRemote.Num2" XML_Guid="{8EB0757E-AE7E-4F03-BAEE-0FD2EB921DA7}" />
<Event Name="MceRemote.Num3" XML_Guid="{1A806110-7885-4CD0-B8D5-E673C56AAEE1}" />
<Event Name="MceRemote.Num4" XML_Guid="{177223BC-0963-41C4-A58F-808A0C8F329E}" />
<Event Name="MceRemote.Num5" XML_Guid="{47089204-A41F-4A51-BBCF-B42A97361ACD}" />
<Event Name="MceRemote.Num6" XML_Guid="{7DF520D7-A97F-4F24-AEA6-370D1339E9F0}" />
<Event Name="MceRemote.Num7" XML_Guid="{C0EBFF3C-EB67-4C39-9071-80C2F6E0A23B}" />
<Event Name="MceRemote.Num8" XML_Guid="{02FE3596-857D-4964-A62E-CA306856C7AC}" />
<Event Name="MceRemote.Num9" XML_Guid="{FEAF4287-E7F6-4B36-A6FD-7B3BCD282BCE}" />
<Event Name="MceRemote.Num0" XML_Guid="{5FADD73A-3FB0-4FA0-892A-CC3622CBC541}" />
<Action XML_Guid="{7B71C8B7-15EE-488D-8734-A90A700FADA1}">
EventGhost.PythonScript(u'if (eg.globals.first !="") and (eg.globals.second !=""):\n x = str({eg.event.suffix})\n eg.globals.third = x[9]\n eg.globals.setstring = eg.globals.first + eg.globals.second + eg.globals.third \n eg.TriggerEvent(prefix="Main",suffix="3keypress",payload=eg.globals.setstring)\n eg.globals.first = ""\n eg.globals.second = ""\n eg.globals.third = ""\n exit()\n \n \nif (eg.globals.first !="") and (eg.globals.second ==""):\n x = str({eg.event.suffix})\n eg.globals.second = x[9]\n eg.globals.setstring = eg.globals.first + eg.globals.second + eg.globals.third\n exit()\n \nif (eg.globals.first==""):\n x = str({eg.event.suffix})\n eg.globals.first = x[9]\n eg.globals.setstring = eg.globals.first + eg.globals.second + eg.globals.third\n exit()\n\n\n\n\n')
</Action>
<Action XML_Guid="{0471CF64-FD8C-48A4-9ED3-E2E733BC11AC}">
EventGhost.ShowOSD(u'{eg.globals.setstring}', u'0;-24;0;0;0;700;0;0;0;1;0;0;2;32;Arial', (58, 222, 79), (0, 0, 0), 0, (500, 0), 1, 3.0, None)
</Action>
</Macro>
</EventGhost>

User avatar
kgschlosser
Site Admin
Posts: 5508
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Chaining events

Post by kgschlosser » Sun Mar 31, 2019 4:54 pm

there is a plugin called multitap that does exactly what you are looking for.


TIP:
use [ code ] before a code block and [ /code ] after the code block to preserve the formatting of the code (remove the spaces before and after the []'s)
If you like the work I have been doing then feel free to Image

Mandamus
Posts: 7
Joined: Sat Mar 30, 2019 5:50 pm

Re: Chaining events

Post by Mandamus » Sun Mar 31, 2019 5:13 pm

I looked at that. And the page linked in the forum here is just gibberish. I fiddled with it for a bit and got no results so I came up with my own solution.

Mandamus
Posts: 7
Joined: Sat Mar 30, 2019 5:50 pm

Re: Chaining events

Post by Mandamus » Sun Mar 31, 2019 5:58 pm

edit: Call it revision 2.1. Now it won't shit itself if it starts and none of the variables are set. I think.

Here's revision 2 of the code. This puts the results in the event name itself. So instead of Main.3keypress '123' it is now Main.3keypress123 or Main.3keypress345 with no payload. So you can create handlers for each key combination without having to parse for the key sequence.

It now resets after 1 second with no inputs.

Code: Select all

<?xml version="1.0" encoding="UTF-8" ?>
<EventGhost Version="0.5.0-rc6">
    <Macro Name="multiple event chain" XML_Guid="{1BEF5C86-23D4-48FF-82B5-3A69C9D6629A}" Expanded="True">
        <Event Name="MceRemote.Num1" XML_Guid="{20931D38-35E0-4056-B1C8-B4782DD32103}" />
        <Event Name="MceRemote.Num2" XML_Guid="{8EB0757E-AE7E-4F03-BAEE-0FD2EB921DA7}" />
        <Event Name="MceRemote.Num3" XML_Guid="{1A806110-7885-4CD0-B8D5-E673C56AAEE1}" />
        <Event Name="MceRemote.Num4" XML_Guid="{177223BC-0963-41C4-A58F-808A0C8F329E}" />
        <Event Name="MceRemote.Num5" XML_Guid="{47089204-A41F-4A51-BBCF-B42A97361ACD}" />
        <Event Name="MceRemote.Num6" XML_Guid="{7DF520D7-A97F-4F24-AEA6-370D1339E9F0}" />
        <Event Name="MceRemote.Num7" XML_Guid="{C0EBFF3C-EB67-4C39-9071-80C2F6E0A23B}" />
        <Event Name="MceRemote.Num8" XML_Guid="{02FE3596-857D-4964-A62E-CA306856C7AC}" />
        <Event Name="MceRemote.Num9" XML_Guid="{FEAF4287-E7F6-4B36-A6FD-7B3BCD282BCE}" />
        <Event Name="MceRemote.Num0" XML_Guid="{5FADD73A-3FB0-4FA0-892A-CC3622CBC541}" />
        <Action XML_Guid="{7B71C8B7-15EE-488D-8734-A90A700FADA1}">
            EventGhost.PythonScript(u'try:\n    eg.globals.setstring\nexcept :\n    eg.globals.first = ""\n    eg.globals.second = ""\n    eg.globals.third = ""\n    eg.globals.setstring=""\n    eg.globals.keytime = {eg.event.time}\n\nif (eg.event.time-1 &gt; eg.globals.keytime):\n    eg.globals.first = ""\n    eg.globals.second = ""\n    eg.globals.third = ""\n    eg.globals.setstring=""\n    \n   \n\nif (eg.globals.first !="") and (eg.globals.second !=""):\n    x = next(iter({eg.event.suffix}))\n    eg.globals.third = x[3]\n    eg.globals.setstring = eg.globals.first + eg.globals.second + eg.globals.third  \n    eg.TriggerEvent(prefix="Main",suffix="3keypress" + eg.globals.setstring)\n    eg.globals.first = ""\n    eg.globals.second = ""\n    eg.globals.third = ""\n    eg.globals.keytime = ""\n    exit()\n    \n    \nif (eg.globals.first !="") and (eg.globals.second ==""):\n    x = next(iter({eg.event.suffix}))\n    eg.globals.second = x[3]\n    eg.globals.setstring = eg.globals.first + eg.globals.second + eg.globals.third\n    eg.globals.keytime= next(iter({eg.event.time}))\n    exit()\n    \nif (eg.globals.first==""):\n    x = next(iter({eg.event.suffix}))\n    eg.globals.first = x[3]\n    eg.globals.setstring = eg.globals.first  + eg.globals.second + eg.globals.third\n    eg.globals.keytime= next(iter({eg.event.time}))\n    exit()\n\n\n\n\n')
        </Action>
        <Action XML_Guid="{0471CF64-FD8C-48A4-9ED3-E2E733BC11AC}">
            EventGhost.ShowOSD(u'{eg.globals.setstring}', u'0;-48;0;0;0;700;0;0;0;0;3;2;1;34;Arial', (58, 222, 79), (0, 0, 0), 0, (500, 0), 1, 3.0, None)
        </Action>
    </Macro>
</EventGhost>
Last edited by Mandamus on Sun Mar 31, 2019 6:58 pm, edited 1 time in total.

User avatar
kgschlosser
Site Admin
Posts: 5508
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Chaining events

Post by kgschlosser » Sun Mar 31, 2019 6:28 pm

I have never used the multitap plugin But i do know it is supposed to be able to do all of this. I am looking at it right now. and I can't figure out how in the hell to use it. It makes no sense to me at all.

The way it should be set up I think is you drag and drop the events you want to "count" so if you want to have the same event repeat 3 times then do something you would drag and drop the 3 event into the macro. then the "detect" action that has a setting for a timeout and after that any events that you would like to do. that is all that it should be. so if i wanted to use a remote control to emulate an C key i would drag and drop the event for the number 2 button on the remote 3 times into a macro add the detect action and after that add the actions needed to either send an A key. or store the letter A into a global variable. if the thing times out then have it generate a timeout event with an event name that a user can then use to run actions to delete a global if they wanted to.

That makes way more sense to me. it is not limited to the same event being generated more then a single time it can handle event sequences. it can be made to consume all events generated in that sequence if the user wanted to.

each multitap added to the tree would have a single timer associated with it. so for instance if you have 2 remote controls set up they would work independent from one another. if a sequence is started on the first instance instance and the timeout occurs it would produce an event for the end of that sequence and would include the number of events that have taken place. if a sequence is started in another macro for the same instance of multitap then the first sequence would end with the number of events taking place for it and the second sequence would start. this would give better results in terms of speed for things like the old school style SMS entry from a phone except using your remote to do it. or in your case if you wanted to tap a button more then a single time to perform a function.

maybe add an option to the "detect" action that would spit out the original events if the timeout expires.
If you like the work I have been doing then feel free to Image

Mandamus
Posts: 7
Joined: Sat Mar 30, 2019 5:50 pm

Re: Chaining events

Post by Mandamus » Mon Apr 01, 2019 1:56 pm

Okay, last revision. I promise.

This one, I removed the filtering and now it'll take any event you want to group by adding the event itself to the group. Or remove the ones that are there. It will currently group the number pad and star(*) and Pound(#) keys on the MCE remote. And will fire after 3 sequential events within one second of each other.

I had it filtering before so that it would use only a single character from the event title. So it would take MceRemote.Num5 and cut out the 5 from it and use that. But I changed it so that it uses the entire suffix, which in this case is Num5. Or in the case of the star button on the remote it would be MceRemote.Star so it would use the Star in the event title that would be triggered. So you could get events like "Main.3keypressNum1Num2Star" that you could then use as a trigger to create your own handlers by typing 12* on the remote control.

Code: Select all

<?xml version="1.0" encoding="UTF-8" ?>
<EventGhost Version="0.5.0-rc6">
    <Macro Name="multiple event chain" XML_Guid="{1BEF5C86-23D4-48FF-82B5-3A69C9D6629A}" Expanded="True">
        <Event Name="MceRemote.Num1" XML_Guid="{20931D38-35E0-4056-B1C8-B4782DD32103}" />
        <Event Name="MceRemote.Num2" XML_Guid="{8EB0757E-AE7E-4F03-BAEE-0FD2EB921DA7}" />
        <Event Name="MceRemote.Num3" XML_Guid="{1A806110-7885-4CD0-B8D5-E673C56AAEE1}" />
        <Event Name="MceRemote.Num4" XML_Guid="{177223BC-0963-41C4-A58F-808A0C8F329E}" />
        <Event Name="MceRemote.Num5" XML_Guid="{47089204-A41F-4A51-BBCF-B42A97361ACD}" />
        <Event Name="MceRemote.Num6" XML_Guid="{7DF520D7-A97F-4F24-AEA6-370D1339E9F0}" />
        <Event Name="MceRemote.Num7" XML_Guid="{C0EBFF3C-EB67-4C39-9071-80C2F6E0A23B}" />
        <Event Name="MceRemote.Num8" XML_Guid="{02FE3596-857D-4964-A62E-CA306856C7AC}" />
        <Event Name="MceRemote.Num9" XML_Guid="{FEAF4287-E7F6-4B36-A6FD-7B3BCD282BCE}" />
        <Event Name="MceRemote.Num0" XML_Guid="{5FADD73A-3FB0-4FA0-892A-CC3622CBC541}" />
        <Event Name="MceRemote.Star" XML_Guid="{967C30DA-C71B-4AB3-9473-5C0A9D2A0C96}" />
        <Event Name="MceRemote.Pound" XML_Guid="{1899B608-E1DF-4877-AA1B-FB3D9EC71BF7}" />
        <Action XML_Guid="{7B71C8B7-15EE-488D-8734-A90A700FADA1}">
            EventGhost.PythonScript(u'try:\n    eg.globals.setstring\nexcept :\n    eg.globals.first = ""\n    eg.globals.second = ""\n    eg.globals.third = ""\n    eg.globals.setstring=""\n    eg.globals.keytime = {eg.event.time}\n\nif (eg.event.time-1 &gt; eg.globals.keytime):\n    eg.globals.first = ""\n    eg.globals.second = ""\n    eg.globals.third = ""\n    eg.globals.setstring = ""\n    \n   \n\nif (eg.globals.first !="") and (eg.globals.second !=""):\n    x = next(iter({eg.event.suffix}))\n    eg.globals.third = x\n    eg.globals.setstring = eg.globals.first + eg.globals.second + eg.globals.third  \n    eg.TriggerEvent(prefix="Main",suffix="3keypress" + eg.globals.setstring)\n    eg.globals.first = ""\n    eg.globals.second = ""\n    eg.globals.third = ""\n    eg.globals.keytime = ""\n    exit()\n    \n    \nif (eg.globals.first !="") and (eg.globals.second ==""):\n    x = next(iter({eg.event.suffix}))\n    eg.globals.second = x\n    eg.globals.setstring = eg.globals.first + eg.globals.second + eg.globals.third\n    eg.globals.keytime= next(iter({eg.event.time}))\n    exit()\n    \nif (eg.globals.first==""):\n    x = next(iter({eg.event.suffix}))\n    eg.globals.first = x\n    eg.globals.setstring = eg.globals.first  + eg.globals.second + eg.globals.third\n    eg.globals.keytime= next(iter({eg.event.time}))\n    exit()\n\n\n\n\n')
        </Action>
        <Action Enabled="False" XML_Guid="{0471CF64-FD8C-48A4-9ED3-E2E733BC11AC}">
            EventGhost.ShowOSD(u'{eg.globals.setstring}', u'0;-48;0;0;0;700;0;0;0;0;3;2;1;34;Arial', (58, 222, 79), (0, 0, 0), 0, (500, 0), 1, 3.0, None)
        </Action>
    </Macro>
</EventGhost>

User avatar
kgschlosser
Site Admin
Posts: 5508
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Chaining events

Post by kgschlosser » Mon Apr 01, 2019 3:58 pm

what would be great is if you could create a topic for this in Sharing Macros/Configuration Trees this way we keep all of these cook tidbits all in one place. and other users will be able to locate it relatively easy
If you like the work I have been doing then feel free to Image

Mandamus
Posts: 7
Joined: Sat Mar 30, 2019 5:50 pm

Re: Chaining events

Post by Mandamus » Mon Apr 01, 2019 8:50 pm


Post Reply