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.

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 »

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 »

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 »

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 »

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 »

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