How do include payload as part of the trigger?

If you have a question or need help, this is the place to be.
Post Reply
aldi13
Posts: 25
Joined: Wed Jan 01, 2014 3:35 pm

How do include payload as part of the trigger?

Post by aldi13 » Wed May 20, 2015 11:31 pm

I am using Pako's Eventghost Forwarder for Growl. It forwards Growl for windows notifications to Eventghost. Only issue I am am having is that the created event's have a payload

Example of event: Main.Growl.EventGhost@App (u'Payload',)

When I drag the event to trigger a macro only this part is included: Main.Growl.EventGhost@App

How do I make it so I can trigger the macro based on what is included inside the payload: (u'Payload',)

Thanks in advance.

jonib
Plugin Developer
Posts: 1280
Joined: Thu Mar 26, 2009 9:33 pm
Location: Sweden

Re: How do include payload as part of the trigger?

Post by jonib » Thu May 21, 2015 8:49 am

aldi13 wrote:How do I make it so I can trigger the macro based on what is included inside the payload: (u'Payload',)
You can't use the payload directly to trigger a macro, you need to access the payload with for example a Python script.

Search the forum for "payload" and "trigger" (or just payload) and you should find some examples.

jonib
XBMC2 plugin to control XBMC. If you want to flatter me Image

aldi13
Posts: 25
Joined: Wed Jan 01, 2014 3:35 pm

Re: How do include payload as part of the trigger?

Post by aldi13 » Thu May 21, 2015 4:52 pm

Thanks for getting me started. I am having trouble figuring out how to write my script. I have been doing a lot of searching. Here is what I have which doesn't quite work:

Code: Select all

if eg.event.string = ("Main.Growl.EventGhost@App")
and eg.event.payload = ("Payload from event string")
then eg.TriggerEvent("My Event Name")

Sem;colon
Experienced User
Posts: 600
Joined: Sat Feb 18, 2012 10:51 am
Location: Germany

Re: How do include payload as part of the trigger?

Post by Sem;colon » Fri May 22, 2015 9:15 am

Try it like this :

Code: Select all

if eg.event.string == "Main.Growl.EventGhost@App" and eg.event.payload == "Payload from event string":
eg.TriggerEvent("My Event Name")

Dragon470
Experienced User
Posts: 202
Joined: Thu Feb 10, 2011 2:16 am

Re: Including payload as part of a trigger

Post by Dragon470 » Fri May 22, 2015 11:54 am

After the event triggers your script: my example from log SchedulGhost.TempEvent u"test"

Code: Select all

if eg.event.string == "SchedulGhost.TempEvent":
    if eg.event.payload == "test":
        eg.TriggerEvent("My Event Name")
this results in: Main.My Event Name

z3us
Posts: 32
Joined: Fri Jul 29, 2011 2:35 am

Re: How do include payload as part of the trigger?

Post by z3us » Thu May 24, 2018 5:11 am

Hi.
What I´m doing wrong here? No event is created
Image

Code: Select all

if eg.event.string == "TaskMonitorPlus.Activated.chrome":
                if eg.event.payload == "<title=u'Pleco Chinese Dictionary', window_class=u'Chrome_WidgetWin_1',...>":
                                eg.TriggerEvent("My Event Name")


Thx!

EDIT: SOLVED! with eg.event.payload.title

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

Re: How do include payload as part of the trigger?

Post by kgschlosser » Thu May 24, 2018 7:42 pm

@z3us


if you click on the help drop down in EG. then click on python shell. this is going to load a console for EG.

in that console is you look at the lower left you are going to see a tree control. this control contains all of the bits that are currently running in EG. you can navigate your way through this to see all of the different things.


but specifically we want to load the help for what gets set as the payload.

so in the pane at the top you will need to type in help(eg.UserPluginModule.TaskMonitorPlus.WindowInfo) when you are typing it will suggest auto complete options.

once you have that typed in press enter. the help information for that item is going to get printed out. what you are seeing is all of the available properties (variables that contain data) and methods (blocks of code that can be run) for a payload of an event that was generated by the Task Monitor Plus plugin. In this case it was very well documented on it's use. so you can read through and see what you have to do.

as an example i am going to show you one section of the output

Code: Select all

Flash(self, caption=True, tray=False, until_active=False, continuous=False, times=10, speed=250)
 |      Flashes the caption or tray button for a duration.
 |      :param caption: Flash the caption
 |      :type caption: bool
 |      :param tray: Flash the tray
 |      :type tray: bool
 |      :param until_active: Flash until window is activated
 |      :type until_active: bool
 |      :param continuous: Keep flashing until stopped. To stop the
 |          flashing you need to call this method with caption and tray
 |          set to False
 |      :type continuous: bool
 |      :param times: The number of time to flash (not used if until_active
 |          or continuous is set)
 |      :type times: int
 |      :param speed: The duration of time between flashes in milliseconds
 |      :type speed: int
 |      :return: None
 |      :rtype: None
 |  
 
the first line is the name of the method and the parameters that can be passed to it along with their default values.

the next line is a description of what the method does

then you will see a list if :param NAME: description

here you will see every parameter listed. the param is for parameter and the NAME will match one of the parameters used when you call the method and the description is a description of what that parameter does.

the line right after each one of those :param lines will be a :type NAME: line. this line tells you what kind of data the parameter takes. so bool would be a True/False and int would be an integer 1, 2, 3, 4, float is a decimal number str is a string "test string" and so on and so forth.

so if we used this command

eg.event.payload.Flash(self, caption=False, tray=True, times=10, speed=250)
this will not flash the window but it will flash the button on the start bar. it will flash it 10 times with 250 milliseconds between flashes

eg.event.payload.Flash(self, caption=True, tray=True, until_active=True)
this will flash the button and the window until you bring the window to the front

eg.event.payload.Flash(self, caption=False, tray=True, continuous=True)
this will flash the button until you call this command again with caption and tray set to False



this command will return (width, height) of the window
eg.event.payload.GetSizeTuple()

where as this one will return an object that you can access my using .Width and .Height the purpose for this one is you can pass the value returned by this directly to a wxPython control object or back to a different task monitor plus payload.
eg.event.payload.GetSize()


The payloads can be stored into eg.globals and can be used to check to see if the window is still open at a later point in time

Code: Select all

eg.globals.some_window = eg.event.payload
and to check it later on

Code: Select all

some_window = eg.globals.some_window

if some_window.IsAlive():
    some_window.BringToTop()
    some_window.Maximize()
    some_window.Focus()
the task monitor plus plugin is a very powerful tool in the EG arsenal. you can control a vast amount of things with it.
If you like the work I have been doing then feel free to Image

z3us
Posts: 32
Joined: Fri Jul 29, 2011 2:35 am

Re: How do include payload as part of the trigger?

Post by z3us » Thu May 24, 2018 10:18 pm

Lots of thanks for your answer

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

Re: How do include payload as part of the trigger?

Post by kgschlosser » Fri May 25, 2018 4:17 am

no worries m8. its good information to have and the task monitor plus is an extremely powerful plugin.
If you like the work I have been doing then feel free to Image

Post Reply