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.
I'm a novice in coding, but I've figured out a few simple Python scripts to keep EventGhost doing most of what I want it to do. I got stumped at my attempts in timing the running of scripts from event triggers.
What I would like to do is take this below code and make it so that once its called from an event trigger that it can only be triggered again after a specific amount of time like 60 seconds. I don't want the script to use Python's sleep function since that keeps EventGhost from doing anything else during the sleep timer period.
Provided you have that python script in a macro do as follows:
Put the following in the macro in this order
- the event that shall trigger
- your script
- an action from SchedulGhost to start an egg timer 60 sec
- an action that disables the macro 'itself'
Make a second macro and put in
- the event that is generated by the egg timer after 60 sec
- an action that enables the previous macro
timeout = 60
if not "myFilterVariableString" in eg.globals.__dict__:
eg.globals.myFilterVariableString = 0
pld = eg.event.payload
if pld and isinstance(pld, (list, tuple)) and len(pld) > 1 and "string" in pld[1]:
new = eg.event.time
if new - eg.globals.myFilterVariableString > timeout:
eg.globals.myFilterVariableString = new
eg.TriggerEvent("event")
krambriw wrote:- an action from SchedulGhost to start an egg timer 60 sec
Dear Walter,
I think it is totally unnecessary to use SchedulGhost for this purpose.
Look at EventGhost plugin and action TriggerEvent.
There you can set the desired timeout.
Otherwise, of course, your solution is correct.
Would it be possible to use a non-global variable instead. And, if so, would that mean that you don't have to worry about using different variable names in each new Macro?