SendKey (sk.exe) v1.0.0
SendKey emulates keypresses that are given as start-arguments for sk.exe.
It can also start programs, wait for them and bring them to front.

ARGUMENTS:
sk.exe without arguments - Opens a help-screen
-H or/H or /?            - Opens this help-text
/p <xxx>                 - waits xxx milliseconds before it executes the next command
/S <path\programname>    - Starts a program/script or opens a document
/W <part of window name> - Waits until a window exists who's name, title or handle contains the given string
/F <part of window name> - brings a window who's name, title or handle contains the given string to the front
sk.exe <something else>  - write something else in the application that has the focus

EXAMPLES:
sk.exe a     - sends the character a,
sk.exe Hello - writes Hello

sk.exe Hello World "^a" "^c" {RIGHT}{ENTER} "^v"   (e.g. in notepad)
- writes Hello World,
- marks everything (CTRL+A),
- copies everything (CTRL+C),
- presses the right-cursor-key to desect the text,
- makes a new line (ENTER) and
- pastes a additonal Hello World (CTRL+V)

sk.exe /P 2000 /S Notepad /W itor /F dito Hello /P 1500 {ENTER}World{!} "^s"
- /P 2000 waits 2 seconds (you can click somewhere else to test the bring-to-front function then),
- /S Notepad starts Notepad,
- /W itor waits for a window which has "itor" as part of it's title, which is true in "Editor", (remark: edi will not be found but Edi)
- /F searches a window which has "dito" as part of it's title, which is also true in "Editor" and brings this window to front,
- writes Hello
- /P 1500 waits again 1,5 seconds
- {ENTER} makes a new line
- World{!} writes World! (the command for writing ! is {!}, because ! alone is the command for the ALT-key, as described below)
- "^s" opens the save-dialog (CTRL+S)



SPECIAL COMMANDS/KEYS:

'!'
This tells sk to send an ALT keystroke, therefore "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 from "!a". The first says ALT+SHIFT+A, the second is ALT+a. If in doubt, use lowercase!

'+'
This tells sk to send a SHIFT keystroke; therefore, "Hell+o" would send the text "HellO". "!+a" would send "ALT+SHIFT+a".

'^'
This tells sk to send a CONTROL keystroke; therefore, "^!a" would send "CTRL+ALT+a".

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

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


If a user is holding down the Shift key when a Send() function begins, text may be sent in uppercase.
One workaround is "{SHIFTDOWN}{SHIFTUP}" before the other operations.

Certain keyboards as the Czech keyboard sends different characters when using the Shift Key or with CAPS LOCK enabled while sending a character.
Due to the sendkey implementation the CAPS LOCKed character will be sent as a Shifted character so it will not work.
Certain special keys can be sent and should be enclosed in braces:

N.B. Windows does not allow the simulation of the "CTRL-ALT-DEL" combination!

Send Command (if zero flag)	Resulting Keypress
{!}	!
{#}	#
{+}	+
{^}	^
{{}	{
{}}	}
{SPACE}	SPACE
{ENTER}	ENTER key on the main keyboard
{ALT}	ALT
{BACKSPACE} or {BS}	BACKSPACE
{DELETE} or {DEL}	DELETE
{UP}	Up arrow
{DOWN}	Down arrow
{LEFT}	Left arrow
{RIGHT}	Right arrow
{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)
{BREAK}	for Ctrl+Break processing
{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
{OEM_102}	Either the angle bracket key or the backslash key on the RT 102-key keyboard

To send the ASCII value A (same as pressing ALT+065 on the numeric keypad)
    "{ASC 065}"

(When using 2 digit ASCII codes you must use a leading 0, otherwise an obsolete 437 code page is used).

To send UNICODE characters enter the character code (decimal or hex), for example this sends a Chinese character
    "{ASC 2709}" or "{ASC 0xA95}"


Single keys can also be sent repeated:
    "{DEL 4}"    ;Presses the DEL key 4 times
    "{S 30}"     ;Sends 30 'S' characters
    "+{TAB 4}"   ;Presses SHIFT+TAB 4 times

No key is sent if the count is zero allowing the count to be set programatically:
    "{M " & $iCount & "}"    ;Presses the M key as many times as set in the $iCount variable


To hold a key down
    "{a down}" ;Holds the A key down
    "{a up}"   ;Releases the A key

To set the state of the capslock, numlock and scrolllock keys
    "{NumLock on}"        ;Turns the NumLock key on
    "{CapsLock off}"      ;Turns the CapsLock key off
    "{ScrollLock toggle}" ;Toggles the state of ScrollLock

If you wish to send the ASCII value A four times, then try
    $x = Chr(65)
    "{" & $x & " 4}"

Most laptop computer keyboards have a special Fn key. This key cannot be simulated.


For example, open Folder Options (in the control panel) and try the following:

"{TAB}"	Navigate to next control (button, checkbox, etc)
"+{TAB}"	Navigate to previous control.
"^{TAB}"	Navigate to next WindowTab (on a Tabbed dialog window)
"^+{TAB}"	Navigate to previous WindowTab.
"{SPACE}"	Can be used to toggle a checkbox or click a button.
"{+}"	Usually checks a checkbox (if it's a "real" checkbox.)
"{-}"	Usually unchecks a checkbox.
"{NumPadMult}"	Recursively expands folders in a SysTreeView32.

Use Alt-key combos to access menu items. Also, open Notepad and try the following:
"!f" sends Alt+f, the access key for Notepad's file menu (on english systems). Try other letters!

"{DOWN}"	Move down a menu.
"{UP}"	        Move up a menu.
"{LEFT}"	Move leftward to new menu or expand a submenu.
"{RIGHT}"	Move rightward to new menu or collapse a submenu.