# AdvControl

The AdvControl function provides access to FAR services and allows to query information. It can be called from anywhere: panels, viewer or editor.

    INT_PTR WINAPI AdvControl(
      int ModuleNumber,
      int Command,
      void *Param
    );

### Parameters

ModuleNumber
Number of the plugin module. It is passed to the plugin in the SetStartupInfo function.
Command
Control command type. Can be one of the following values (`ADVANCED_CONTROL_COMMANDS` enum):

Command | Description
--- | ---
ACTL_COMMIT | "Commits" the results of the last operation with FAR windows (for example, ACTL_SETCURRENTWINDOW). Param is ignored (set to zero). The function returns `TRUE` on success or `FALSE` in case of failure.
ACTL_CONSOLEMODE | Retrieves or sets console mode (FullScreen <-> Windowed). Param can be one of the following constants:
Constant | Description
--- | ---
FAR_CONSOLE_GET_MODE | returns current console mode
FAR_CONSOLE_SET_FULLSCREEN | sets the console to fullscreen mode
FAR_CONSOLE_SET_WINDOWED | sets the console to windowed mode
FAR_CONSOLE_TRIGGER | toggles console mode
The returned value is the current console mode. Can be one of the following constants:
Constant | Description
--- | ---
FAR_CONSOLE_WINDOWED | windowed mode
FAR_CONSOLE_FULLSCREEN | fullscreen mode
ACTL_EJECTMEDIA | Allows to programmatically eject media from removable drives (CD-ROM/USB/SUBST). Param points to an ActlEjectMedia structure. This command returns `TRUE` if the media was succesfully ejected, otherwise `FALSE` is returned.
ACTL_KEYMACRO | Various actions with macro commands. Param points to an ActlKeyMacro structure. The return value is `TRUE` if the command was executed successfully or `FALSE` if the execution failed (not enough memory, a macro command is currently being executed or played).
ACTL_GETARRAYCOLOR | Allows to get an array of all FAR colors. Param points to an array of bytes to receive the current FAR colors. Each FAR color is stored in one byte - high 4 bits is the background color, low 4 bits is the foreground color. If Param is equal to `NULL`, the size of the FAR color array is returned. FAR color indexes defined in farcolor.hpp can be used for accessing this array. This command always returns the size of the FAR color array.
ACTL_GETCOLOR | Allows to get the FAR color with the specified index. Param must contain one of the COL_* color indexes defined in `farcolor.hpp`. The return value is the color if a correct index was specified,
ACTL_GETFARVERSION | Gets the FAR version. Param either points to a variable of type DWORD, or it can be NULL. Version format:
    HIWORD:         = build number  (FAR 1.70.387 = 0x0183)
    LOWORD:  HIBYTE = major version (FAR 1.70.387 = 0x01)
             LOBYTE = minor version (FAR 1.70.387 = 0x46)
Param can be set to `NULL`. This command returns the FAR version.
ACTL_GETFARHWND | Returns the window handle (`HWND`) of the current FAR Manager window. Param is ignored (set to 0).
ACTL_GETCONFIRMATIONS | Returns information about the confirmation settings. Returns a `DWORD` with the `FarConfirmationsSettings` flags set according to options in the "Confirmations" dialog. Param is ignored (set to 0).
ACTL_GETDESCSETTINGS | Returns information about the file description settings. Returns a `DWORD` with the `FarDescriptionSettings` flags set according to options in the "File descriptions" dialog. Param is ignored (set to 0).
ACTL_GETDIALOGSETTINGS | Returns information about the dialog settings. Returns a `DWORD` with the `FarDialogSettings` flags set according to options in the "Dialog Settings" dialog. Param is ignored (set to 0).
ACTL_GETINTERFACESETTINGS | Returns information about the interface settings. Returns a `DWORD` with the `FarInterfaceSettings` flags set according to options in the "Interface settings" dialog. Param is ingoner (set to 0).
ACTL_GETPANELSETTINGS | Returns information about the panel settings. Returns a DWORD with the `FarPanelSettings` flags set according to options in the "Panel settings" dialog. Param is ignored (set to 0).
ACTL_GETPLUGINMAXREADDATA | Returns the maximum data size that can be passed to OpenFilePlugin. Returns a DWORD of any value from 0x1000 to 0x80000 (4KB to 512KB), but you should be ready to receive any other value. Param is ignored (set to 0)
ACTL_GETSYSTEMSETTINGS | Returns information about the system settings. Returns a `DWORD` with the flags `FarSystemSettings` set according to options in the "System settings" dialog. Param is ignored (set to 0).
ACTL_GETSYSWORDDIV | Retrieves a string containing the word delimiter characters. Param points to a string buffer in which the word delimiters will be copied. Set Param to `NULL` to get string length (without the terminating null character). The maximum length of the buffer is 260 characters, including the terminating null.
ACTL_GETWCHARMODE | Returns the FAR console working mode Param is ingnored (set to 0). Returns TRUE, is the FAR console mode is set to Unicode. Returns FALSE, if it set to 8-bit mode.
ACTL_GETWINDOWCOUNT | Returns the count of open windows in FAR Manager. Param is ignored (set to 0). There is always at least 1 open window (file panels, or an editor or a viewer if FAR was started with a command line parameter `-e` or `-v`)
ACTL_GETWINDOWINFO | Retrieve information about a FAR Manager window. Param - Param points to a WindowInfo structure. You must initialize the member WindowInfo.Pos before calling the function. If WindowInfo.Pos is equal to -1, information about the current window is returned. The return value is TRUE if the window with the index WindowInfo.Pos exists and FALSE if there is no such window (in the latter case, the WindowInfo structure is not filled).
ACTL_GETSHORTWINDOWINFO | Retrieve information about a FAR Manager window. Param - Param points to a WindowInfo structure. You must initialize the member WindowInfo.Pos before calling the function. If WindowInfo.Pos is equal to -1, information about the current window is returned. The return value is TRUE if the window with the index WindowInfo.Pos exists and FALSE if there is no such window (in the latter case, the WindowInfo structure is not filled). In oppose to the ACTL_GETWINDOWINFO command the WindowInfo.TypeName and WindowInfo.Name members are not filled and so this command can be called from any thread.
ACTL_POSTKEYSEQUENCE | Post a sequence of internal key codes to the FAR keyboard queue. Param Param points to a KeySequence structure. The return value is `TRUE` if the keys have been posted successfully and `FALSE` in case of an error. The keys will be interpreted as soon as the plugin returns control to FAR.
ACTL_REDRAWALL | Redraw all FAR windows. Param is ignored (set to 0).
ACTL_SETARRAYCOLOR | Allows to change a specified range of the FAR color scheme. Param points to a FarSetColors structure. The return value is `TRUE` if the range was successfully changed or `FALSE` if the parameters in the FarSetColors structure were specified incorrectly.
ACTL_SETCURRENTWINDOW | Allows to switch to a specific FAR Manager window. Param is an integer specifying the index of the window to switch to (the numbering starts at 0). The function returns `TRUE` if the switch was successful or `FALSE` in case of failure (the window to switch to does not exist). Attention! The switching will not occur untill ACTL_COMMIT is called or FAR Manager receives control.
ACTL_WAITKEY | Allows to wait for a keystroke. If Param is set to -1 or `NULL` - waits for any key If Param is set to the internal key code - waits for that key. Returns value is always zero.

Param
Points to data dependent on the command type. See the command descriptions for specific information.

### Return value

Return value depends on the command type. See the command descriptions for specific information.
See also:
Control, EditorControl