A simple tutorial: Hello World

From EventGhost
Jump to: navigation, search


We are going to make a simple macro, that when Control and A are pressed together it will open Notepad, enter Hello World and then make Notepad initiate a Save.

Hello World

First lets create a new file. Select File > New (or click the first icon in the toolbar) You should now have something like the following...

HelloWorld 21.png

...you probably have things listed in the panel on the left (the Log panel). I cleared mine for neatness sake. You can do this by right clicking on any of the items in the log and selecting Clear Log.


Plugins give us Input which trigger Events and they also give us Actions for a specified thing that allow us to make that thing do something.

Inputs can be anything like a remote control, keyboard, mouse or other much more exotic inputs. EventGhost comes with a large range of inputs as standard. When a plugin for a device gets input from that device it will trigger an Event for that input (more on this later).

Actions can be anything that makes something happen. Actions that are part of the plugin will be actions that make what the plugin is for, do something. There are plugins to control applications (a large range of media players for instance), so their actions will do things like play next track, mute volume, that sort of thing. Some plugins/actions are for doing things with the system, like open files, change windows, etc. EventGhost comes with alot of actions inbuilt that don't need Plugins and Plugins for a large range of devices.

Adding the Plugin

Out macro is going to respond to keyboard input...when we press Control-A we want to start our macro. So the first thing were going to need to do is add the Plugin.pngKeyboard Plugin so we can respond to its Input Events.

Right click on the Autostart item in the right panel and select Add Plugin. Under Remote Receiver select Keyboard...

HelloWorld 17.png

...you should now have the keyboard plugin listed under Autostart...

HelloWorld 15.png


When EventGhost is started anything under Autostart gets run first. So by adding the keyboard plugin to Autostart, were making that plugin loaded and active when EventGhost starts.


The panel on the left is the Log. Notice how after I added the Keyboard plugin and typed some keys the log is showing that. What it is showing is the Events the Plugins/EventGhost has recognized. Events are what your macro will react to.


A Macro is where we put the Actions we want to happen, its like a script. So now were going to add the Macro that will be run when we press Control-A. Add a Macro by...

Right click on Configuration Tree and selecting Add Macro A dialog is going to pop up asking for what Action to add, select Cancel, we will be adding our Actions later. You should now have something like this...

HelloWorld 18.png

Now the Macro is unnamed, lets change it to something meaningful. Right click on the Macro and select Rename Item... Type Hello World and press Enter.

It should now look like...

HelloWorld 19.png


The first thing our Macro needs to do is know when to run. We want our Macro to run when someone press's Control and A together on the keyboard. As was stated earlier, any Events the Plugins we added see, get outputted in the Log. Well we want the Event of Control and A being pressed, so press the Left Control key and A together and you should see a Event.pngKeyboard.LCtrl+A Event in the Log (to make it a little clearer, you can clear the log first)....

HelloWorld 01.png

Now drag that Event over to and on the Hello World Macro and drop. The Event should now be added to the Macro...

HelloWorld 07.png

Notice how the Events Ctrl (meaning Control) has an L before it? That's because EventGhost can tell the difference between Left Control and Right Control. We want our Event to be either Left or Right Control, so lets add another Event by redoing what you just did, but this time hold the right Control key when pressing A and drag that event to your Macro. You should now have...

HelloWorld 14.png

So now we have added Events to our Macro that says "If they press Ctrl-A then do the rest of this Macro" and now it's time to add the Actions that will execute if this Event happens by adding them to our Macro after the Events.


Actions are what tell EventGhost or its Plugins to do something. EventGhost comes with alot of standard Actions and Plugins add more (usually for one specific thing that their name usually says what for).

Our objective is to open Notepad and add some text to it and initiate a save. So the first Action we need to add is one to open Notepad.

Right click on you Hello World Macro and select Add Action. A dialog will appear showing all the Actions available to you....

HelloWorld 20.png

We want the Action.pngStart Application that can be found under the System option...

HelloWorld 02.png

So select Start Application and click on OK.

You will then be shown a dialog that allows you to enter all the details for that Action...

HelloWorld 06.png

We want to start Notepad, so where you enter the Exectable details there is a button on the right that allows us to browse for the location of the one we want. So click it and go to C Drive > Windows and select notepad.exe...

HelloWorld 09.png

After you click Open it should be added to the the Actions dialog under Executable...

HelloWorld 11.png

Click Ok and your Action to start Notepad should be added...

HelloWorld 10.png

Try it out....Press Ctrl-A and Notepad should load up.

Now we want to send keystrokes to this Notepad typing Hello World. We can add an Action to do that, but before we do were going to add an Action that makes it wait a little bit before doing that. The reason for this is, if we send keystrokes straight away without waiting a bit first, then sometimes you start sending the keys before Notepad is ready to receive them. So lets add a Action.pngWait Action....

Right click on Hello World and select Add Action. Look under EventGhost for 'Wait some time'...

HelloWorld 00.png

...and add it.

A dialog will come up asking for the details for this Action. Enter 0.40 in the input box.

HelloWorld 13.png

0.40 seconds is long enough to wait for Notepad on my computer. If you find it doesn't write all the keys later when you test your Macro then double click on this Action and increase the amount of time to Wait.

Your Macro should now look like this....

HelloWorld 08.png

Now its time to add the Action that will type stuff into the Notepads window.

Right click on your Hello World Macro and find Action.pngSimulate Keystrokes that is under Window...

HelloWorld 03.png

Add the Action and when the dialog to enter options comes up, copy what you see in the following screen shot....

HelloWorld 12.png

Please note that 'Use alternate method to emulate keypresses' is selected. If you don't select that then it will use the normal method that also adds any special keys your holding down to the keystrokes it sends. So if your still holding down control when it gets to that bit then Notepad will actually receive Ctrl-H,Ctrl-e,Ctrl-l,etc. By using the alternate method, this wont happen and Notepad will only receive what the Action sends to it.

Your Macro will now look like....

HelloWorld 05.png

And finally were going to add one more Action of the Emulate Keystrokes to send the key combination to initiate a save in Notepad.

So add another Action.pngEmulate Keystrokes Action as you just did before, but this time when the dialog comes up asking for its settings, type what you see in the following screen shot.

HelloWorld 16.png

Notice that special keys need to be put between curly brackets, the above is {Ctrl+S} , so we are telling EventGhost to send the keys Control and S together to Notepad. An explanation of this can be found by clicking on the Description tab of that dialog. We also could of just added this keyboard combination to the previous Action, but I find the Macros easier to read if its in a separate Action.

Now your final Macro should look like this...

HelloWorld 04.png

Now when you press Control-A anywhere in Windows an instance of Notepad will load up, Hello World will be typed into it and up will come a save dialog.

Theres still lots more to learn and explore. EventGhost has many Plugins and Actions you can use and we have only covered the absolute basics to creating a Macro and what they can do. But hopefully you will have learned the basics to how things work in EventGhost and can learn from there.

See Also