How to prevent multiple event triggers within brief timeframe?

If you have a question or need help, this is the place to be.
Post Reply
wysocki
Experienced User
Posts: 70
Joined: Mon Nov 23, 2015 9:23 pm
Location: Los Angeles area

How to prevent multiple event triggers within brief timeframe?

Post by wysocki » Fri Feb 21, 2020 7:40 pm

I use EG to control my HTPC. I use a remote control to create an IR event which runs a macro to start Plex, start my projector, etc. On subsequent IR events, the macro checks to see if Plex is active, and if so, shuts it down along with the projector, etc.

The problem is, sometimes I will inadvertently fire off multiple IR blasts when I press the button on the remote, which does what it's supposed to do, but obviously not what I want. How can I prevent the event from triggering the macro more than once per minute (or other timeframe)?

jachin99
Experienced User
Posts: 646
Joined: Sat Feb 13, 2016 8:39 pm

Re: How to prevent multiple event triggers within brief timeframe?

Post by jachin99 » Sat Feb 22, 2020 3:31 am

I don't know if its the best way to do this but maybe you could use disable an item at the end of your powerup sequence, then tell EG to wait some time, then at the end of said time, re-enable your item. So the IR blasts would fire, then disable their own macro, count to sixty for example, then the macro would re-enable itself. Of course if your stuff gets turned off during that minute wait, you will have to turn it all on manually. You can also look at jump to if duplicate event where you would have to press your button twice in a given time frame (I think I used .5 seconds) in order for your macro to fire. This will make it a little more difficult to fire off the macro accidently. There are others you could look at as well like enable exclusively, which enables a given macro or folder by itself, and disables all others.

wysocki
Experienced User
Posts: 70
Joined: Mon Nov 23, 2015 9:23 pm
Location: Los Angeles area

Re: How to prevent multiple event triggers within brief timeframe?

Post by wysocki » Sat Feb 22, 2020 7:18 pm

Thanks for the great idea! I actually did the disable as the very first action to prevent ANY duplicate from re-running then put the wait and enable at the end of the macro. Perfect!

wysocki
Experienced User
Posts: 70
Joined: Mon Nov 23, 2015 9:23 pm
Location: Los Angeles area

Re: How to prevent multiple event triggers within brief timeframe?

Post by wysocki » Sat Feb 29, 2020 2:00 am

NOT SOLVED!!! Sorry, but I hadn't tested the above idea well enough before that post! It actually doesn't work. I have the following macro:

Code: Select all

USB_UIRT.eventxxx
Disable: thismacro
Run Application: zzzzz
If xxxxxx ELSE yyyyy
Wait: 10.0 sec(s)
Close
Enable: thismacro
The problem is that if I trigger the IR event a few times rapidly within that 10 seconds, they just queue up and each take their turn once the macro is enabled! Any other ideas?

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

Re: How to prevent multiple event triggers within brief timeframe?

Post by kgschlosser » Sat Feb 29, 2020 2:15 am

DO NOT DO THIS!!
Wait: 10.0 sec(s)

No more then a 2 - 2.5 second wait total for a whole macro.

If you want to filter out duplicate events I posted how to do that in a graceful way that does not require the use of any wait actions. you can read about it HERE

Filtering duplicate events can be handled in one of 2 ways. If the number of repeat events is a constant we can use that. If it is not we can use a timeout period instead.
If you like the work I have been doing then feel free to Image

wysocki
Experienced User
Posts: 70
Joined: Mon Nov 23, 2015 9:23 pm
Location: Los Angeles area

Re: How to prevent multiple event triggers within brief timeframe?

Post by wysocki » Mon Mar 02, 2020 1:44 am

DO NOT DO THIS!!
Wait: 10.0 sec(s)

No more then a 2 - 2.5 second wait total for a whole macro.
Don't quite understand the point there, but it's now irrelevant. Although your post on filtering events was informative, I found an easy solution: Just place a "Clear Pending Events" action at the end of the macro and it doesn't get re-triggered automatically when it's done! SOLVED!

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

Re: How to prevent multiple event triggers within brief timeframe?

Post by kgschlosser » Mon Mar 02, 2020 3:35 pm

The reason why you do not want to have an excess of 3 seconds worth of waits for any event is because of the Windows notification system. EG receives a lot of notifications about various things happening in Windows. If one of these events happens to trigger while the waits are taking place it causes the Windows notification system to stall. There ends up being a cascading failure in EG that will cause EG to crash.

This problem can be seen if you use the Find Window action coupled to a Monitor On or Monitor Off event. Because the Find Window action takes so long to run (the more apps open the longer it takes). This is a setup that people do quite often actually. This is the single largest reason why I like the threaded events system I wrote because these events coming in from windows are able to be processed along side other events. so the issue with the wait becomes a non issue.
If you like the work I have been doing then feel free to Image

Post Reply