## C.60. `$world->macro`

Abstract

$world->macro function: creates a MACRO

`void $world->macro(` | `keycode` ,
| `action` ,
| [`attributes`] `)`;

`void $world->macro(` | `number` ,
| [`keycode` ,
| [`action`]] ,
| [`attributes`] `)`;

Creates a new macro, or edits the macro identified by number. `keycode` represents a key such as "`KP_Home`" or "`<Control>F12`". The format is the one accepted by the GTK+ function `gtk_accelerator_parse()`, but most of the time you will want to use the `$world->getkeycode` function to retrieve the keycode for a given key. `action` is what will be executed when the key (or keys) is pressed.

Atributes is a reference to a hash defining attributes for the macro. Generally the call works like this:

    $world->macro("keycode", "action", { attribute1 => value1,
                                         attribute2 => value2, ... })

Possible attributes:

- `key`: The key code.

- `action`: The action to be executed.

- `enabled`: If value evaluates to true, the macro is enabled, if false, it is disabled and is not run if the key is pressed.

- `name`: Assigns a name to the macro, so that it can be referenced by name.