Skip to main content
Version: 20 R7 BETA

POST KEY

POST KEY ( code {; modifiers {; process}} )

ParameterTypeDescription
codeIntegerCharacter code or function key code
modifiersIntegerState of modifier keys
processIntegerDestination process reference number, or Application event queue, if omitted, or 0

This command is not thread-safe, it cannot be used in preemptive code.

Description

The POST KEY command simulates a keystroke. Its effect is as if the user actually entered a character on the keyboard.

You pass the code of the character in code.

If you pass the modifiers parameter, you pass one or a combination of the Events (Modifiers) constants:

ConstantTypeValueComment
Activate window bitInteger0
Activate window maskInteger1
Caps lock key bitInteger10Windows and OS X
Caps lock key maskInteger1024Windows and OS X
Command key bitInteger8Ctrl key under Windows, Command key under OS X
Command key maskInteger256Ctrl key under Windows, Command key under OS X
Control key bitInteger12Ctrl key under OS X, or right click under Windows and OS X
Control key maskInteger4096Ctrl key under OS X, or right click under Windows and OS X
Mouse button bitInteger7
Mouse button maskInteger128
Option key bitInteger11Alt key (also called Option under OS X)
Option key maskInteger2048Alt key (also called Option under OS X)
Right control key bitInteger15
Right control key maskInteger32768
Right option key bitInteger14
Right option key maskInteger16384
Right shift key bitInteger13
Right shift key maskInteger8192
Shift key bitInteger9Windows and OS X
Shift key maskInteger512Windows and OS X

For example, to simulate the Shift key, pass Shift key mask. If you do not pass modifiers, no modifiers are simulated.

If you specify the process parameter, the keystroke is sent to the process whose process number you pass in process. If you pass 0 (zero) or if you omit the parameter, the keystroke is sent at the application level, and the 4D scheduler will dispatch it to the appropriate process.

Example

See example for the Process number command.

See also

ASCII Codes
Function Key Codes
POST CLICK
POST EVENT