# ActlKeyMacro

The ActlKeyMacro structure is used in the AdvControl function for operations with macro-commands.

    struct ActlKeyMacro {
      int Command;
      union{
        struct {
          char *SequenceText;
          DWORD Flags;
        } PlainText;
        DWORD Reserved[3];
      } Param;
    };

### Elements

Command
One of the following commands (FARMACROCOMMAND enum):

Command | Description
--- | ---
MCMD_LOADALL | Read all macros from the registry into FAR memory. Previous values are erased.
MCMD_POSTMACROSTRING | Pass a macro in text form to FAR (in the same format as macros are stored in the registry). The AdvControl function returns TRUE if the macro is analyzed and placed into the queue (the macro will start running when FAR gets control). FALSE is returned if the macro contains any error.
MCMD_SAVEALL | Forces FAR to immediately save all macros from memory to the registry.
MCMD_GETSTATE | Get macro execution status. Returns one of the following values (enum FARMACROSTATE):
Value | Description
--- | ---
MACROSTATE_NOMACRO | no macro is being executed
MACROSTATE_EXECUTING | a macro is being executed without sending key strokes to plugins
MACROSTATE_EXECUTING_COMMON | a macro is being executed; key strokes are sent to plugins
MACROSTATE_RECORDING | a macro is being recorded without sending key strokes to plugins
MACROSTATE_RECORDING_COMMON | a macro is being recorded; key strokes are sent to plugins
Param is ignored. The value is returned by AdvControl.

Param.PlainText.SequenceText
Pointer to a zero-terminated string containing a macro sequence in text form. OEM-encoding should be used to store macros. This member is used in the MCMD_POSTMACROSTRING command.
Param.PlainText.Flags
Combination of the following macro execution flags (FARKEYSEQUENCEFLAGS enum):

Flag | Description
--- | ---
KSFLAGS_DISABLEOUTPUT | Disable screen output during macro playback.
KSFLAGS_NOSENDKEYSTOPLUGINS | Don't send keystrokes to editor plugins (plugins, that export ProcessEditorInput function).
KSFLAGS_REG_MULTI_SZ | The Param.PlainText.SequenceText parameter is represented in the REG_MULTI_SZ format. REG_MULTI_SZ in the registry:
    line 1\x00
    line 2\x00
    ...
    line N\x00
    \x00

This member is used in the MCMD_POSTMACROSTRING command.
Reserved
Reserved for future use.

### Remarks

1. The MCMD_LOADALL and MCMD_SAVEALL commands won't execute during macro recording or playback.
2. The KSFLAGS_REG_MULTI_SZ flag can be discarded, if Param.PlainText.SequenceText contains '\n' instead of 0x00.

### Example

MCMD_POSTMACROSTRING usage in FARCmds plugin:

    command.Command=MCMD_POSTMACROSTRING;
    command.Param.PlainText.SequenceText=(char *)malloc(strlen(pCmd)+1);
    if(command.Param.PlainText.SequenceText)
    {
      command.Param.PlainText.Flags=KSFLAGS_DISABLEOUTPUT;
      strcpy(command.Param.PlainText.SequenceText,pCmd);
      Info.AdvControl(Info.ModuleNumber,ACTL_KEYMACRO,&command);
      free(command.Param.PlainText.SequenceText);
    }

MCMD_LOADALL usage in FARCmds plugin:

    command.Command=MCMD_LOADALL;
    Info.AdvControl(Info.ModuleNumber,ACTL_KEYMACRO,&command);

MCMD_SAVEALL usage in FARCmds plugin:

    command.Command=MCMD_SAVEALL;
    Info.AdvControl(Info.ModuleNumber,ACTL_KEYMACRO,&command);

See also:
Structures | KeySequence | TActlKeyMacro