Using sendkeys to simulate key presses |
Top Previous Next |
You can use the special alias command "paste" to have an alias result paste text into the last application window.
For example you could use the following alias result to paste in your signature:
paste signature | paste Sincerely, your pal Albert Einstein
Sometimes you may want to use an alias to simulate more advanced keys being pressed (such as function keys or ctrl+alt+shift combinations); you can do this by using the sendkeys command. sendkeys can also be useful in cases where the normal paste command fails because a window won't accept Ctrl+V paste (for example a dos box).
Use the pushkeys in an alias like:
send some keys | sendkeys 1111{TAB}2222{TAB}3333{f2}
Special strings that you can use in a {sendkeys} clip, from the TPushKeys help file:
Function key definitions are enclosed within braces, keys from F1 to F24 are represented by:
{F1}...{F24}
State Modifiers
Shift Key + Ctrl Key ^ Left Alt Key % Right Alt Key (Alt Gr) !
Prefix any key definition with the appropriate modifier to affect the key press immediately following it e.g. +ab will result in the key strokes Ab being directed to the application.
To extend the modifier to affect a group of characters enclose them in parentheses e.g !(ab) will result in AB being simulated. Parentheses may be nested so that !(+(ao)) will give ÁÓ.
Note: State Modifiers need not be used with standard keys as they can be entered directly. See example
IMPORTANT: When you want to trigger normal letter keys in combination with Ctrl Alt Shift, you *MUST* use lowercase versions of the letters, or a SHIFT key will be simulated.
To simulate the press and release of a modifier key then the key symbol must be the only character in the Keys string. See example
Numeric Keypad
Numeric keypad keys are enclosed within braces.
0 to 9 {NUMPAD0}...{NUMPAD9} - {NUMPAD-} or {NUMPADSUBTRACT} + {NUMPAD+} or {NUMPADADD} / {NUMPAD/} or {NUMPADDIVIDE}
* {NUMPAD*} or {NUMPADMULTIPLY} . {NUMPAD.} or {NUMPADDECIMAL}
Navigation Keys
Navigation keys are enclosed within braces.
Enter {ENTER} or {RETURN} or ~ Newline {NL} or {NEWLINE} Cursor Down {DOWN} Cursor Up {UP} Cursor Left {LEFT} Cursor Right {RIGHT} Page Up {PGUP} or {PAGEUP} or {PRIOR} Page Down {PGDN} or {PAGEDOWN} or {NEXT} Delete {DEL} or {DELETE} Backspace {BS} or {BKSP} or {BACKSPACE} Home {HOME}
End {END} Tab {TAB} Formfeed {FF}
Delay
A delay may be introduced into the key stream by using:
{SLEEP n}
where n is a numeric value representing a number of milli-seconds to wait. Note: the KeyDelay pause is ignored following a {SLEEP} key. See example
Direct Entry
A key code may be entered directly in the form:
{\nnnn}
where nnnn represents the Alt-Numeric keypad keys used to generate the character.
Note: Normally this option is not needed as characters may be entered directly into the Keys string. See example
Other Keys
This section includes the method to send reserved keys: !,%,^,+,~. See example
Bell {BELL} Break {BREAK} Caps lock {CAPS} or {CAPSLOCK} Escape {ESC} or {ESCAPE} Help {HELP} Insert {INS} or {INSERT} Number lock {NUMLOCK} Printscreen {PRINTSCREEN} or {PRTSC}
Scroll lock {SCROLLLOCK} or {SCRLK} Pause {PAUSE} Cancel {CANCEL} Left Windows key {LEFTWIN} or {START} Right Windows key {RIGHTWIN} Applications key {APPS} or {CONTEXT} Left brace {{} ~ {~} + {+} % {%} ^ {^} ! {!}
This new functionality is provided by the TPushKeys component by Alan Warriner which encapsulates, and extends, Christopher Latta's PushKeys code ([email protected], www.alan-warriner.co.uk)
|