Technical details - Macros

Far Manager

Technical details

Storing macro commands

FAR macro commands are located in Windows registry under [HKEY_CURRENT_USER\Software\Far\[Users\USERNAME\]KeyMacros] registry key in a text form.

Macro commands are divided into 16 areas of execution and 2 areas to store global variables and constants. Area name corresponds to the registry key:

Area Purpose
"Shell" File panels
"Viewer" Internal file viewer
"Editor" Internal file editor
"Dialog" Dialog boxes
"Search" Quick file search
"Disks" Drive selection menu
"MainMenu" Main menu
"Menu" Other menus
"Help" Help system
"Info" Informational panel
"QView" Quick view panel
"Tree" Folder tree panel
"FindFolder" Folder search panel
"UserMenu" User menu
"Other" Screen capturing mode
"Common" Common area. Macros created in this area can be used everywhere. This area has the lowest priority while processing macros.
"Vars" Global variables area read by FAR during startup. Variables can be string (REG_SZ) and numeric (REG_QWORD). One can write to this area using msave() function.
"Consts" Global constants area read by FAR during startup. Constants can be string (REG_SZ) and numeric (REG_QWORD).

Every macro command is stored in a separate sub key of the certain area of execution, which name is assigned to a new shortcut name and contains a set of values that define the macro command behaviour.

Name Type Default Description
Sequence REG_SZ
REG_MULTI_SZ
  Contains the sequense of the keystrokes.
DisableOutput REG_DWORD 0 Disable screen output while executing the macro. When user creates new macro FAR sets this parameter to 1 (disable screen output). If this parameter is omitted FAR uses its default value and enables screen output.
RunAfterFARStart REG_DWORD 0 Execute macro command after FAR startup. This flag applies only to macros that start in the Shell area.
EmptyCommandLine REG_DWORD 0 Execute this macro only if command line is empty.
NotEmptyCommandLine REG_DWORD 0 Execute this macro only if command line is not empty.
NoFilePanels REG_DWORD 0 Do not execute this macro for a file panel.
NoFilePPanels REG_DWORD 0 Do not execute this macro for a passive file panel.
NoPluginPanels REG_DWORD 0 Do not execute this macro for a plugin panel.
NoPluginPPanels REG_DWORD 0 Do not execute this macro for a passive plugin panel.
NoFolders REG_DWORD 0 Do not execute this macro if the current element is a folder.
NoPFolders REG_DWORD 0 Do not execute this macro if the current element is a folder for a passive panel.
NoFiles REG_DWORD 0 Do not execute this macro if the current element is a file.
NoPFiles REG_DWORD 0 Do not execute this macro if the current element is a file for an inactive panel.
Selection REG_DWORD 0 Execute only if there are any selected elements on the panel.
PSelection REG_DWORD 0 Execute only if there are any selected elements on the passive panel.
NoSelection REG_DWORD 0 Execute only if there are no selected elements on a panel.
NoPSelection REG_DWORD 0 Execute only if there are no selected elements on a passive panel.
EVSelection REG_DWORD 0 Execute if there is a selected text block in the viewer, editor or dialog text boxes.
NoEVSelection REG_DWORD 0 Execute if there is no selected text block in the viewer, editor or dialog text boxes.
NoSendKeysToPlugins REG_DWORD 0 Special mode: don't send keystrokes to the plugins during recording and executing.
Description REG_SZ   Macro command description.

There's only one mandatory parameter "Sequence", other parameters can be omitted and they will have the default values according to their specifications.

The "Sequence" parameter contains literal representation of the command sequence. Every keystroke is represented by its string equivalent delimited by space or tab character.

During startup FAR compiles command sequence for every macro command defined into internal byte code representation. If there is any error during compilation of the macro command then the macro will be ignored.

Execution conditions

Before executing the macro FAR checks the execution conditions in the following order:

  1. NoSendKeysToPlugins
  2. EmptyCommandLine + NotEmptyCommandLine
  3. NoFilePanels + NoPluginPanels
  4. NoFilePPanels + NoPluginPPanels
  5. NoFolders + NoFiles
  6. NoPFolders + NoPFiles
  7. Selection + NoSelection (outside Viewer, Editor and Dialog)
  8. PSelection + NoPSelection (outside Viewer, Editor and Dialog)
  9. EVSelection + NoEVSelection (inside Viewer, Editor and Dialog)
See also: