Noob macro question re parameters/arguments

Do you have questions about writing plugins or scripts in Python? Meet the coders here.
Post Reply
Posts: 2
Joined: Sun Aug 24, 2008 12:24 am

Noob macro question re parameters/arguments

Post by musical_edmond » Sun Aug 24, 2008 12:54 am

I'm using the Digiguide EPG and want to change my Dbox (cable box) channel when PVR recording. I'm successfully triggering EventGhost (EG) from the Digiguide using the command:

eventghost.exe -e dbox channel channelname

For example:

eventghost.exe -e dbox 25 305 Sky One

I want an EG macro to check if the "channel" is 25 (my PVR's channel for Dbox) and if so, use the first word of the "channelname" to change my Dbox (e.g. to 305) using EG's Dbox plugin.

All sounds reasonable and doable - except I don't know how to use Python and there appears to be scant documentation on EG macros.

I've figured how to do the following in EG:
- Load Dbox plugin after Autostart
- Add macro called "dbox"

Now how do I take in the external parameters, parse them and/or assign them to variables?

Any help appreciated, including being directed to RTFM (if there is a decent one).


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

Re: Noob macro question re parameters/arguments

Post by jinxdone » Mon Aug 25, 2008 5:57 pm


You can access the parameters supplied from the command line with the eg.event.string, eg.event.payload variables.

Copy & paste this little script into EG, put it inside your macro for a little example what you could do.

Code: Select all

<?xml version="1.0" encoding="UTF-8" ?>
<EventGhost Version="1262">
        EventGhost.PythonScript(u'print eg.event.string\nfor var in eg.event.payload:\n        print var\nprint "second parameter: " + eg.event.payload[1]\n')
For a good reading try the python tutorial:
And the EventGhost Wiki, especially the Scripting page:

Google can probably find much more python related stuff than I can remember.. :)

Posts: 2
Joined: Sun Aug 24, 2008 12:24 am

Re: Noob macro question re parameters/arguments

Post by musical_edmond » Tue Aug 26, 2008 8:57 pm

Thanks jinxdone,
You set me off in the right direction and my macro is now working. In case anyone else finds this based on the subject, this is the code I ended up with in EventGhost:
import sys

tvchan = eg.event.payload[0]
if tvchan <> '21':

dboxchan = eg.event.payload[1]
for a in dboxchan:
eg.TriggerEvent("dbox" + a)

It's called using:
eventghost.exe -e dbox tvchannel dboxchannel

This tunes the dbox only when the tvchannel is 21 by calling up an event per keypress, events are named dbox0, dbox1, etc.

I'm now getting the same problem as another user in that EventGhost doesn't stay minimised in the system tray.

Post Reply