From EventGhost
Jump to: navigation, search

The action is the second keystone of EventGhost, after events. Without actions, events have nothing to do; without events, nothing can trigger an action.

Adding an Action

You can only add actions to two places in your configuration tree:

  • macros, where the action will execute whenever the macro is run; and
  • the Autostart.pngAutostart tree item, where the action will run whenever EventGhost is started or restarted.

When you create a new macro, you are immediately presented with the option of adding an action to it.

To add an action to an existing macro (or to the Autostart tree), click on it, and then click the Add Action (Action.png) button in the toolbar, or click the Configuration menu and select "Add Action..." You will be shown a dialog listing all the actions available to you, including those built into EventGhost, and those provided by plugins.

Configuring an Action

Some actions require configuration in order to be useful. For example, Action.pngShow OSD requires you to enter the text that it will display on the screen. These actions will present their configuration screens to you when you install them. If you cancel this dialog, then the action will be removed from the macro.

You can reconfigure an existing action by simply double-clicking on it. The configuration dialog will reappear, so you can change the settings as you like. If you cancel this dialog, the action will remain in the macro with its previous settings.

You can put any number of actions in a macro. Actions are run in the order you specify, one at a time.

Dynamic Configuration

Some actions will allow some of their parameters to accept python variable expansion expressions. Some parameters will automatically support this, while others may need you to check a separate checkbox to enable it.

There are two major types of dynamic configuration: based on the triggering event, and based on the result of the previous action.

From Actions

Many actions are able to return a useful result upon completing their tasks. For example, Action.pngGet Boot Timestamp returns the time at which your computer was booted. (You will need to read the documentation of the action you're interested in to see if it returns a useful result.)

To use this result in the next action (as long as it supports python variable expansion), you would enter the text {eg.result} into the action's configuration. To continue our example, if you follow Action.pngGet Boot Timestamp with Action.pngShow OSD, you can enter {eg.result} as the text to display. When you save this action and then run your macro, your computer's boot time will briefly flash on the screen.

From Events

This is covered in detail on the Event page.

Testing an Action

In an action's configuration dialog, you can click the Test button to trigger the action and see if it works as you wish.

However, this will not work if your action is configured using dynamic expressions as described above. For example, if your action would normally be triggered by an event, and you add a python variable expansion such as {} to your action's configuration, then the test will fail, because it was not triggered by an event.

Triggering an Action

If you wish to trigger a specific action in your configuration tree, you can click on it, and then click the Execute Item (Autostart.png) button on the toolbar. The single action you selected will run.

Disabling an Action

You can right-click on an action and select "Disable Item" to cause it to become disabled. Disabled items will have a red "X" over their icon. Disabled actions will never run, even if any associated events trigger their containing macro -- and even if you select the action and click the Execute Item (Autostart.png) button on the toolbar.

In addition, an action is considered to be disabled if its containing macro, or any of its parent folders, is disabled, even if the action itself is not disabled. Actions in disabled folders or macros can still be run by clicking the Execute Item (Autostart.png) button on the toolbar, but they will not run when their event is triggered, nor when called by another action.

You can enable and disable actions (and macros and folders) using any of these actions: Action.pngDisable Item, Action.pngEnable Item, Action.pngEnable Item Exclusively. This can be useful for changing EventGhost's behaviour based on specific events; for example, enabling application-specific hot-keys only when that application is running.

Calling Actions from Python

You can call any action from the Action.pngPython Command or Action.pngPython Script actions by calling it via its Python source code.

To get an action's source code, create the action somewhere in your configuration tree, then right-click on it and select "Copy as Python". You can then paste it into one of the above actions, or simply into Notepad, to see what the function call looks like.

For example, Action.pngWait with a setting of 0.01 seconds looks like this:


Python Arguments to Actions

Calling an action from python allows you to pass variables to the action as arguments, even if the plugin doesn't support python variable expansion. For example, if you wanted Action.pngWait to wait for a number of seconds that you store in the variable `eg.globals.my_delay`, you would change the above call to look like this:


Shortening Python Calls to Actions

When you copy an action in this manner, all of its arugments will be specified, sequentially. Many actions are written so that you can specify the arguments by name, or omit some of them entirely to use a reasonable default value. Consult the plugin's documentation to see if this can work for you.

See Also