Send Command line parameters to a Macro Program?

If you have a question or need help, this is the place to be.
Post Reply
RandomEGUser
Posts: 18
Joined: Sun Jul 19, 2009 7:58 pm

Send Command line parameters to a Macro Program?

Post by RandomEGUser » Sun Jul 19, 2009 8:05 pm

I've just started using EventGhost, and want to know if I can send command line parameters to a macro program's command line?

So something like this:

Eventghost -e Program1 [COMMANDLINEPARAMS]

would trigger my Program1 event, which launches the program with the attached [COMMANDLINEPARAMS]

is there a wildcard I can put under Command line Parameters in the Start Program Application that would pass these along?

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

Re: Send Command line parameters to a Macro Program?

Post by jinxdone » Sun Jul 19, 2009 8:46 pm

From EG documentation
-event <eventname> [<payload> ...]
Issues the event <eventname> in the currently running EventGhost instance. Optionally you can specify one or more <payload> strings, that will be added to the event in the eg.event.payload field.
-e <eventname> [<payload> ...]
Shorter alias for the -event option.
So this means that you can access the parameters in EG with the eg.event.payload variable in your macros and actions.

Example: (copy & paste into EG to test)

Code: Select all

<?xml version="1.0" encoding="UTF-8" ?>
<EventGhost Version="851">
    <Macro Name="Show OSD: Message of the day is: {eg.event.payload}" Expanded="True">
        <Event Name="myevent" />
        <Action>
            EventGhost.ShowOSD(u'Message of the day is: {eg.event.payload[0]}', u'0;-24;0;0;0;700;0;0;0;1;0;0;2;32;Arial', (255, 255, 255), (0, 0, 0), 0, (0, 0), 0, 3.0, False)
        </Action>
    </Macro>
</EventGhost>
Then in cmdline run a command:
EventGhost.exe -e myevent "Hello World!"

I am referencing eg.event.payload[0] instead of eg.event.payload because the payload is a tuple containing all the parameters, so if you run:
EventGhost.exe -e myevent Hello World! <---- note, Parameters not in quotes

Then you will get eg.event.payload[0] = 'Hello' and eg.event.payload[1] = 'World!'
Eventghost -e Program1 [COMMANDLINEPARAMS]

would trigger my Program1 event, which launches the program with the attached [COMMANDLINEPARAMS]

is there a wildcard I can put under Command line Parameters in the Start Program Application that would pass these along?
You lost me there on what you are trying to do, but if I understood you correctly just stick the {eg.event.payload[0]} in your start application action parameters and it should work.

Hopefully this helped..

-jinxdone

RandomEGUser
Posts: 18
Joined: Sun Jul 19, 2009 7:58 pm

Re: Send Command line parameters to a Macro Program?

Post by RandomEGUser » Mon Jul 20, 2009 5:01 pm

That seems to work, but I'm running into another problem:

I have an emulator in eventghost, say nes.exe (with event called nes)

If I run eventghost -e nes "C:\file.ext"

it works perfectly.

If I move the file to a complex directory, say Program Files, and run

eventghost -e nes "C:\Program Files\file.ext"

it doesn't work.

If I run the executable by itself, with the same params

nes.exe "C:\Program Files\file.ext"

it works without a problem.


Any reason why complex directories wouldn't work?

RandomEGUser
Posts: 18
Joined: Sun Jul 19, 2009 7:58 pm

Re: Send Command line parameters to a Macro Program?

Post by RandomEGUser » Mon Jul 20, 2009 5:13 pm

Disregard the last post, I merely had to put quotes around the {eg.event.payload[0]}, everythings working fine now, thanks for the help!

Chaemelion
Posts: 9
Joined: Tue Jul 28, 2009 4:53 am

Re: Send Command line parameters to a Macro Program?

Post by Chaemelion » Fri Jul 31, 2009 7:48 pm

Yeah, some programs require a directory containing a space (Program Files) to be put into string format by using quotes.

steve@rpad
Posts: 48
Joined: Sat May 25, 2013 12:10 pm
Location: Toronto, Canada

Re: Send Command line parameters to a Macro Program?

Post by steve@rpad » Wed Jul 22, 2020 7:59 pm

From EG documentation:

Updated Link: http://wiki.eventghost.net/docs/scripting.html
Thanx,

Steve

Win10 Pro - 2004 - 64bit i7-4771 3.50GHz 32GB RAM 60TB Storage
EG - 0.5.0rc6, FileBot - 4.9.1.0, VidCoder 5.21
USBIRT, O-MEGA, DirWatcher, Keyboard, VLC
MediaPortal ...et al.

Post Reply