Skip to main content

Named constants

A builtin parameter with a fixed set of choices takes an Integer from one of these namespaces. The names are replaced by their numbers when the script compiles, so they cost nothing at run time, and the editor completes them after you type the namespace and a dot, showing each one's value and what it means. They're case-sensitive, and a misspelled one is a compile error. The number itself also works (VirtualKey.A is 65 is 0x41), but the name says what it means. A Steps field that takes a whole number takes the same names.

NamespaceMembers = valueUsed by
MouseButtonLeft=0 Right=1 Middle=2 X1=3 X2=4 Primary=5 Secondary=6MouseClick, MouseButtonDown/Up, MouseDoubleClick, MouseIsButtonDown; also what ContextGetStrokeButton returns (-1 when there's no button context, or the gesture was drawn with the draw key). Primary is the button Windows treats as a left click and Secondary the one it treats as a right click, following Windows' "Primary mouse button" setting, so use them for an ordinary click or right-click. Left and Right are the physical buttons: with the primary and secondary buttons swapped in Windows' mouse settings, a MouseButton.Left click is the physical left button, which Windows treats as a right click. ContextGetStrokeButton reports the button after the swap as Primary or Secondary, so a right-button gesture reports Secondary whichever physical button drew it, and passing the value to MouseClick presses that same button. Recorded macros use Primary and Secondary.
FileNotifyFileName=0x1 DirName=0x2 Attributes=0x4 Size=0x8 LastWrite=0x10 LastAccess=0x20 Creation=0x40 Security=0x100FolderWatchCreate's filterMask. These are bit flags, so combine them with |.
AudioEndpointPlayback=0 Capture=1 Communications=2Multimedia* volume and mute builtins
WindowStyleNormal=0 Minimized=1 Maximized=2 Hidden=3ShellRunProgram
ShellVerbOpen=0 Edit=1 Print=2 RunAs=3 Properties=4 Explore=5 Find=6ShellRunProgram's verb, which also accepts any other verb as Text
LocationTopLeft=0 TopCenter=1 TopRight=2 MiddleLeft=3 MiddleCenter=4 MiddleRight=5 BottomLeft=6 BottomCenter=7 BottomRight=8UIShowDisplayMessage's location, which also accepts a Text "x,y" screen point
TextAlignLeft=0 Center=1 Right=2UIShowDisplayMessage/UIUpdateDisplayMessage
LockResultAcquired=0 TimedOut=1 Pinned=2returned by UtilityLockAcquire/UtilityLockAcquirePinned
LockStateFree=0 HeldByMe=1 HeldByOther=2 Pinned=3returned by UtilityLockGetState
SerialParityNone=0 Odd=1 Even=2 Mark=3 Space=4SerialOpenPort, SerialMonitorCreate
SerialStopBitsOne=0 OnePointFive=1 Two=2SerialOpenPort, SerialMonitorCreate
DateTimeStyleShortDate=0 LongDate=1 ShortTime=2 LongTime=3 ShortDateTime=4 LongDateTime=5 FileStamp=6DateTimeFormat. All but FileStamp follow the user's Windows region settings, in that region's own calendar; FileStamp is always 20261001-140509, which sorts by time and is safe in a file name.
DateTimePartYear=0 Month=1 Day=2 Hour=3 Minute=4 Second=5 Weekday=6DateTimeGetPart. Gregorian, local time. Weekday is ISO: 1 is Monday, 7 is Sunday.
VirtualKeythe Win32 virtual-key codes, named after .NET's Keys enum (listed below)every Keyboard* builtin that takes an Integer key

VirtualKey members​

The Oem* keys are named by the symbol they produce on a US keyboard. The physical key varies with the layout.

LButton RButton Cancel MButton XButton1 XButton2 Back Tab Clear Enter ShiftKey ControlKey Menu Pause CapsLock Escape Space PageUp PageDown End Home Left Up Right Down Select Print Execute PrintScreen Insert Delete Help D0 D1 D2 D3 D4 D5 D6 D7 D8 D9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z LWin RWin Apps Sleep NumPad0 NumPad1 NumPad2 NumPad3 NumPad4 NumPad5 NumPad6 NumPad7 NumPad8 NumPad9 Multiply Add Separator Subtract Decimal Divide F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 F16 F17 F18 F19 F20 F21 F22 F23 F24 NumLock Scroll LShiftKey RShiftKey LControlKey RControlKey LMenu RMenu BrowserBack BrowserForward BrowserRefresh BrowserStop BrowserSearch BrowserFavorites BrowserHome VolumeMute VolumeDown VolumeUp MediaNextTrack MediaPreviousTrack MediaStop MediaPlayPause LaunchMail SelectMedia LaunchApplication1 LaunchApplication2 OemSemicolon Oemplus Oemcomma OemMinus OemPeriod OemQuestion Oemtilde OemOpenBrackets OemPipe OemCloseBrackets OemQuotes Oem8 Oem102

Key-combo text (KeyboardPressKeyCombo)​

KeyboardPressKeyCombo takes Text, not a constant: any number of modifier prefixes, then exactly one key. One combo per call, with no repeat counts. Nothing may follow the key: "^cx" or "Control+V" is an error, not a press of the first key.

Prefix^+%@
ModifierCtrlShiftAltWin

The key is a single letter or digit (either case), or one of these names in braces, in any letter case: {ENTER} {ESC} {TAB} {DEL} {BS} {SPACE} {HOME} {END} {PGUP} {PGDN} {LEFT} {RIGHT} {UP} {DOWN} {INSERT} {F1}…{F24} {PRTSC} {CAPSLOCK} {NUMLOCK} {SCROLLLOCK} {BREAK} {HELP} {CLEAR} {NUMPAD0}…{NUMPAD9} {MULTIPLY} {ADD} {SEPARATOR} {SUBTRACT} {DECIMAL} {DIVIDE}. {ESCAPE}, {DELETE}, {BACKSPACE}, {BKSP} and {INS} also work.

Examples: "^c" Ctrl+C · "^+{ESC}" Ctrl+Shift+Esc · "%{F4}" Alt+F4 · "@d" Win+D · "^{HOME}" Ctrl+Home · "{enter}" Enter.

Coming from .NET's SendKeys? The prefixes and the names in braces follow Microsoft's SendKeys syntax. This text adds @ for the Windows key and {NUMPAD0}…{NUMPAD9}, {SEPARATOR} and {DECIMAL} for the numeric keypad's own keys. For several keys in one text, use KeyboardSendKeys, below.

Key sequences (KeyboardSendKeys)​

KeyboardSendKeys takes a whole sequence in Microsoft's SendKeys format, with @ for the Windows key as above, so every key combo is also a sequence.

WriteSends
abcthe characters, typed as they are on any keyboard layout
^ + % @ before a keyCtrl, Shift, Alt or Windows held for that key: "^a" is Ctrl+A
~Enter
{TAB}, {F5}, …a key by name, the names above
{LEFT 5}, {a 3}the key or character that many times, 1 to 1000
+(abc)Shift held for every key in the parentheses
{+} {^} {%} {~} {@} {(} {)} {{} {}}that character itself

Examples: "{TAB 3}^a" Tab three times, then Ctrl+A · "^s{ENTER}" Ctrl+S, then Enter · "%(fx)" Alt+F, then Alt+X · "me{@}example.com~" the address, then Enter.

The whole text is checked before any key is pressed. A mistake anywhere in it, such as an unknown name in braces or a { with no }, stops the action with an error that names the character, and nothing is sent. A sequence is at most 4096 characters and 10000 keystrokes, repeats counted. Each keystroke waits the Typing delay setting, as KeyboardTypeText does, except that a repeated arrow, Home, End, Page Up or Page Down key goes out all at once.

With Ctrl, Alt, Shift or Windows held, a letter, a digit or a space is the same key on every keyboard layout. Any other character is looked up on the layout of the window in front: "^;" is a different key on a German layout than on a US one, and a character that layout can't type with a modifier is an error.

A letter after a modifier is its key, capital or not: "^A" is Ctrl+A, the same as "^a". To press Ctrl+Shift+A, write "^+a". Microsoft's SendKeys adds Shift for a capital, so a StrokesPlus.net import writes the Shift out for you.

Send plain text with KeyboardTypeText, not KeyboardSendKeys. Here + ^ % ~ @ ( ) { } are commands, not characters: "50% off" presses Alt+Space, and in "[email protected]" the @ holds the Windows key for the e. Text you didn't write yourself, such as the clipboard or a variable, can hold any of them, so never pass it to KeyboardSendKeys.