/
setHotKey

setHotKey

Description

Assigns a hot key to a script or command.

If the hot key combination is already assigned to another command, it will be reassigned to this new one.

Windows does not provide a way to individually remove hot keys for an application (it only provides a way to replace the list of hot keys). Therefore, Shogun Post keeps an internal list of all hot keys, until the -final flag is specified, when it copies the internal list to the application's list. This is done to speed up execution of the command.

The second argument (key) requires some special handling:

  • For letters, use the letter itself (e.g. "s" for the S key).
  • For numbers and other single character keys (e.g. =), use the character itself, but be sure to enclose it in quotes (e.g. "=").

Here is a table of all other special keys, and the string that is expected for the second argument:

KeyString
Backspace"BACK"
Tab"TAB"
Enter"ENTER" or "RETURN"
Pause/Break"PAUSE"
Caps Lock"CAPS"
Escape"ESC"
Page Up"PAGEUP"
Page Down"PAGEDOWN"
Home"HOME"
End"END"
Left Arrow"LEFT"
Right Arrow"RIGHT"
Up Arrow"UP"
Down Arrow"DOWN"
Select"SEL"
Execute"EXECUTE"
Print Screen"PRINTSCREEN"
Insert"INSERT"
Delete"DELETE"
Help"HELP"
Num Lock"NUMLOCK"
Scroll Lock"SCROLLLOCK"
F1–F12"F1" - "F12"

Functional area

System

Command syntax

Syntax

setHotKey ["commandName" "key"] [-ctrl] [-shift] [-numPad] [-final]

Arguments

NameTypeRequiredComments
commandNamestringyesName of a native command or script which will execute when the Hot Key is pressed. If a script, the script must exist in the scripts directories specified in the Preferences.
keystringyesKey on the keyboard specifying the hot key. See Description above for valid values.

Flags

NameFlag argumentsArgument typeExclusive toComments
ctrl0Specifies that the CTRL key must also be depressed for the command to execute. The default is no modifier.
shift0Specifies that the Shift key must also be pressed for the command to execute. The default is no modifier.
numPad0Certain keys are repeated on the number pad portion of keyboards (e.g. 19, +, , etc). Specifies that the key is the one on the number pad.
final0Specifies that this call to setHotKey is the last in a series. This flag should always be provided if only one call to setHotKey is being made. This is to reduce allocation and reallocation of hot keys in the system.

Return value

void

Examples

// Set some hot keys. Be sure to specify the -final
// flag on the last one.
setHotKey "cutKeys" "x" -ctrl;
setHotKey "fillGaps" "f" -shift;
setHotKey "step" "RIGHT";
setHotKey "play" "TAB";
setHotKey "stop" "TAB" -ctrl;
setHotKey -final;

Additional information

Related commands