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.

TriggerEvent a variable time

If you have a question or need help, this is the place to be.
Post Reply
Diabl0570
Posts: 30
Joined: Sun Feb 28, 2010 6:05 pm

TriggerEvent a variable time

Post by Diabl0570 »

i want a triggerEvent to trigger the event after a variable time ( seconds)
here is my code

Code: Select all

eg.shutD = eg.timeLeft /60
eg.tappen = eg.timeLeft  - 600
eg.TriggerEvent(u'altTap', 30:0)
so i want to do some like this

Code: Select all

eg.TriggerEvent(u'altTap', {eg.tappen})

i try'd a lot of thing, non of them worked
any one how has any idees?

thanks in advanced
User avatar
jinxdone
Plugin Developer
Posts: 443
Joined: Tue Jan 02, 2007 4:08 pm

Re: TriggerEvent a variable time

Post by jinxdone »

The "Trigger Event" -action is a bit different from eg.TriggerEvent as it includes an option for a time delay. Actually, the action is defined in EventGhost\plugins\EventGhost\__init__.py and it internally it uses the eg.scheduler.AddTask to delay the triggering of the event.

So, what you are really looking for something to run a command after a set time.

Using eg.Utils.threading.Timer.

Code: Select all

def test():
    eg.TriggerEvent(u'test')

t = eg.Utils.threading.Timer(30.0, test)
t.start()
You can read more about threading.Timer at python docs.


EventGhost also has a custom scheduler thread which is a bit easier to use.

Code: Select all

eg.scheduler.AddTask(5, eg.TriggerEvent, 'hello', 'payload')
The first parameter is the number of seconds after which the command will be run. Notice how the parameters starting from 'hello' are being passed to eg.TriggerEvent
Diabl0570
Posts: 30
Joined: Sun Feb 28, 2010 6:05 pm

Re: TriggerEvent a variable time

Post by Diabl0570 »

Thanks! this worked great for me:

Code: Select all

eg.scheduler.AddTask(eg.timeLeft, eg.TriggerEvent, 'hello')
Post Reply