Core Function SendKeys

From Sputnik Wiki
Revision as of 00:41, 23 August 2013 by UberFoX (Talk | contribs)
Jump to: navigation, search
SendKeys( <keydef>, <flag> )

Contents

Description

Sends simulated keystrokes to the active window.

keydef

Optional; Changes how "keys" is processed:

flag

The sequence of keys to send.

Return Value

None.

Remarks

Since Sputnik uses { } as physical code inside strings you must either escape it like \{ } or place it inside a string type that is not parsed such as 'Test{ }Test' or @"Test{ }Test" etc.

Sputnik can send all ASCII and Extended ASCII characters (0-255), to send UNICODE characters you must use the "ASC" option and the code of the character you wish to send (see {ASC} at the bottom of the table below).

The "SendKeys" command syntax is similar to that of ScriptIt and the Visual Basic "SendKeys" command. Characters are sent as written with the exception of the following characters:

'!' This tells Sputnik to send an ALT keystroke, therefore SendKeys("This is text!a") would send the keys "This is text" and then press "ALT+a".

N.B. Some programs are very choosy about capital letters and ALT keys, i.e. "!A" is different to "!a". The first says ALT+SHIFT+A, the second is ALT+a. If in doubt, use lowercase!

'+' This tells Sputnik to send a SHIFT keystroke, therefore SendKeys("Hell+o") would send the text "HellO". Sputnik("!+a") would send "ALT+SHIFT+a".

'^' This tells Sputnik to send a CONTROL keystroke, therefore SendKeys("^!a") would send "CTRL+ALT+a".

N.B. Some programs are very choosy about capital letters and CTRL keys, i.e. "^A" is different to "^a". The first says CTRL+SHIFT+A, the second is CTRL+a. If in doubt, use lowercase!

'#' The hash now sends a Windows keystroke; therefore, SendKeys("#r") would send Win+r which launches the Run dialog box.

You can set SendCapslockMode to make CAPS LOCK disabled at the start of a Send operation and restored upon completion. However, if a user is holding down the Shift key when a Send function begins, text may be sent in uppercase. One workaround is to SendKeys(@"{SHIFTDOWN}{SHIFTUP}") before the other Send operations.

Certain special keys can be sent and should be enclosed in braces:

Send Command (if zero flag) Resulting Keypress 
{!} 					! 
{#} 					# 
{+} 					+ 
{^} 					^ 
{{} 					{ 
{}} 					} 
{SPK command} 				Execute Sputnik code (See example below)
{SPACE} 				SPACE 
{ENTER} 				ENTER key on the main keyboard 
{ALT} 					ALT 
{BACKSPACE} or {BS} 			BACKSPACE 
{DELETE} or {DEL} 			DELETE 
{UP} 					Cursor up 
{DOWN} 					Cursor down 
{LEFT} 					Cursor left 
{RIGHT} 				Cursor right 
{HOME} 					HOME 
{END} 					END 
{ESCAPE} or {ESC}			ESCAPE 
{INSERT} or {INS} 			INS 
{PGUP} 					PageUp 
{PGDN} 					PageDown 
{F1} - {F12} 				Function keys 
{TAB} 					TAB 
{PRINTSCREEN} 				Print Screen key 
{LWIN} 					Left Windows key 
{RWIN} 					Right Windows key 
{NUMLOCK on} 				NUMLOCK (on/off/toggle) 
{CAPSLOCK off} 				CAPSLOCK (on/off/toggle) 
{SCROLLLOCK toggle} 			SCROLLLOCK (on/off/toggle) 
{CTRLBREAK} 				Ctrl+Break 
{PAUSE} 				PAUSE 
{NUMPAD0} - {NUMPAD9} 			Numpad digits 
{NUMPADMULT} 				Numpad Multiply 
{NUMPADADD} 				Numpad Add 
{NUMPADSUB} 				Numpad Subtract 
{NUMPADDIV} 				Numpad Divide 
{NUMPADDOT} 				Numpad period 
{NUMPADENTER} 				Enter key on the numpad 
{APPSKEY} 				Windows App key 
{LALT} 					Left ALT key 
{RALT} 					Right ALT key 
{LCTRL} 				Left CTRL key 
{RCTRL} 				Right CTRL key 
{LSHIFT} 				Left Shift key 
{RSHIFT} 				Right Shift key 
{SLEEP} 				Computer SLEEP key 
{ALTDOWN} 				Holds the ALT key down until {ALTUP} is sent 
{SHIFTDOWN} 				Holds the SHIFT key down until {SHIFTUP} is sent 
{CTRLDOWN} 				Holds the CTRL key down until {CTRLUP} is sent 
{LWINDOWN} 				Holds the left Windows key down until {LWINUP} is sent 
{RWINDOWN} 				Holds the right Windows key down until {RWINUP} is sent 
{ASC nnnn} 				Send the ALT+nnnn key combination 
{BROWSER_BACK} 				Select the browser "back" button 
{BROWSER_FORWARD} 			Select the browser "forward" button 
{BROWSER_REFRESH} 			Select the browser "refresh" button 
{BROWSER_STOP} 				Select the browser "stop" button 
{BROWSER_SEARCH} 			Select the browser "search" button 
{BROWSER_FAVORITES} 			Select the browser "favorites" button 
{BROWSER_HOME} 				Launch the browser and go to the home page 
{VOLUME_MUTE}				Mute the volume 
{VOLUME_DOWN} 				Reduce the volume 
{VOLUME_UP} 				Increase the volume 
{MEDIA_NEXT} 				Select next track in media player 
{MEDIA_PREV} 				Select previous track in media player 
{MEDIA_STOP} 				Stop media player 
{MEDIA_PLAY_PAUSE} 			Play/pause media player 
{LAUNCH_MAIL} 				Launch the email application 
{LAUNCH_MEDIA} 				Launch media player 
{LAUNCH_APP1} 				Launch user app1 
{LAUNCH_APP2} 				Launch user app2 
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox