another issue has been reported. I modified the Trigger Event action to have some extra abilities. and during that process i goof something. if you specify an event without a dot "." in it then the Main prefix will be added. and if you have a dot in it then the Main is not added.
I will be adding a check box to turn the addition of the Main on or off. it will be defaulted to on so it will not break the current API. I am sorry for this oversight. the problem was reported a long while ago. I simply forgot about it.
I do want to give a little bit of instruction as to what the whole Trigger Event changes are and do.
Event String
______
Events are separated by "."'s, the purpose for this is to group them
together. As an example if you wanted to group events together by a
device type this can be done by using the following example.
Remote.StopButton
So you would be able to group all of the various buttons to a remote.
Plugins use this same grouping mechanism for generating events. You also
have the ability to go one step further and group a group.
Remote.Volume.Up
Remote.Volume.Down
Remote.Volume.Mute
The purpose for this is when you add an event to an action you can
target specific groups by using the * so if you wanted to target all of
the events that take place for Remote.Volume you would add an event to
the macro like this.
Remote.Volume.*
This will run that macro for any event that begins with Remote.Volume.
You also have the ability to set the event string using a python
expression (see below).
Wait Time
______
The amount of time to wait before triggering the event. this has a
resolution of hundredths of a second.
Event Payload
______
When an event occurs you are able to attach a data packet to the
event. This data packet can be any kind of a python object.
Most common ones are:
integers = 1 2 3 4 5
floats = 0.00
lists = []
tuple = ()
dictionaries = {}
unicode strings = u'', u""
and strings = "", ''
When there is an attached payload you will see the payload in the log.
You also have the ability just like the Event String to attach a
python expression (see below).
Add to Queue
______
If the wait time is set to 0.00 this option will appear. Adding the
event to the queue means that the event will get triggered after the
event that caused this action to run has been fully processed. that means that all macros with the event in it have to be processed, if there any pending events to be run then those will get run before this one does.
If unchecked the event will get triggered right away Not being added
to the queue and not waiting until the event that started this action
has finished processing.
A little more detail. as an example if you add a Trigger Event action with the queue checked off. then you add a Wait action of say 5.0 seconds.
Then run the macro. you will see that the event does not get triggered until after the wait period is over and the macro has finished running.
This is not an ideal mechanism in some cases. one of them being the use of jumps from python code (which cannot be done) so if you wanted to run another macro at specifically that time. you cannot do it.
Restore eg.event
______
If add to queue has not been checked this option will appear. This
relates more to the scripting portions of EventGhost. What this done is
each and every time an event gets triggered there are 2 variables that
get set into place. Those 2 variables are eg.event and eg.eventString.
When you trigger an event while the current event is running those 2
variables will get changed to the new event. Upon completion of the new
event if you would like to change those variables back to the event that
ran this action then check this box.
Using a Python Expression
______
You can use a python expression in several ways. The expression
**MUST** be wrapped in curly braces {}. This is the identifier that
tells EventGhost that it needs to do some work.
You can pass global variables which are stored in eg.globals by
wrapping the variable name in the curly braces.
{eg.globals.some_variable}
If you want to transfer the results of another action you can do this
as well.
{eg.plugins.SomePlugin.SomeAction()}
***Or maybe you want to do something a little more complex.***
A different value passed based on if a global is True or False.
{"TV.On" if eg.globals.tv_power else "TV.Off"}
Or checking a global for a specific value and passing True or False.
{eg.plugins.SomePlugin.SomeAction() == 100}
When using a python expression in a payload the curly braces are the
same thing that is used in a dictionary but our crafty programmers have
accounted for this so don't worry.
These expressions get run when the TriggerEvent Action gets run. So if you
have a programmed wait time (see below) the data may be different at the
start of the wait time then at the end.
Now here is a really crafty bit.
If you say wanted to use this action from inside of a python script you can. and if you wanted to trigger the event to run a macro right away you can do that as well..
now here is the crazy piece. what if you wanted to have that second macro return data to the first... well we can do that as well.
this would be the example of a python script that triggers an event immediately.
Code: Select all
payload = dict(results=None)
eg.plugins.EventGhost.TriggerEvent(
eventString='Some.Test.Event',
waitTime=0,
payload=payload,
queueEvent=False,
restoreEvent=True
)
print payload
and say this is another python script that is in a macro with the event 'Some.Test.Event'
Code: Select all
eg.event.payload['result'] = 'This is a successful test'
when the payload gets printed out by the first script after the event it triggered has completed. you will see the text that was set in place by the second script get printed.
You can only do this with mutable objects. which are lists, dictionaries (dict), and class instances.
It is a nice thing to be able to do if you do not want to store a bunch of variables in eg.globals.
These additions are for keeping your configuration tree nice and tidy. so if you have common code that needs to be shared between more then one macro but the information it would need changes. this is the mechanism that will make it easier to pass that information. so you do not have to have duplicate macros.