Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords: sendkeys sendkeysto
Here are some pointers on sending keystrokes using WinBatch:
MouseClickBtn(parent-windowname, child-windowname, button-text)which works quite well if you have a dialog window that has an underlined key letter in the dialog button text. You may have to fiddle with the child-windownames - perhaps set it to nul ("") to get it to work with some applications.
To set your DOS program to a windowed rather than full-screen mode, set the _Default.pif file to run in a windowed state and close on exit. If the program has its own .pif file, make the changes in that .pif.
In addition, the following special characters, enclosed in curly braces, may be sent:
Key SendKey equivalent ~ {~} ! {!} ^ {^} + {+} Alt {ALT} Backspace {BACKSPACE} or {BS} Caps Lock {CAPSLOCK} Clear {CLEAR} Delete {DELETE} or {DEL} Down Arrow {DOWN} End {END} Enter {ENTER} or ~ Escape {ESCAPE} or {ESC} F1 through F16 {F1} through {F16} Help {HELP} Home {HOME} Insert {INSERT} or {INS} Left Arrow {LEFT} Num Lock {NUMLOCK} Page Down {PGDN} Page Up {PGUP} Print Screen {PRTSC} Right Arrow {RIGHT} Space {SPACE} or {SP} Tab {TAB} Up Arrow {UP}
To enter an Alt, Control, or Shift key combination, precede the desired character with one or more of the following symbols: Alt ! Control ^ Shift + To enter Alt-S: SendKeysto("~Notepad", "!s")
Note: You should use lower-case letters to represent Alt-key combinations and other menu shortcut keys.
To enter Ctrl-Shift-F7:
SendKeysto("~Notepad", "^+{F7}")You may also repeat a key by enclosing it in braces, followed by a space and the total number of repetitions desired.
To type 20 asterisks: SendKeysto("~Notepad", "{* 20}")
To move the cursor down 8 lines: SendKeysto("~Notepad", "{DOWN 8}")It is possible to use SendKeysto to send keystrokes to a DOS application, but only if you are running Windows in 386 Enhanced mode. You would then transfer the keystrokes to the DOS application via the Clipboard. It is only possible to send standard ASCII characters to DOS applications; you cannot send function key or Alt-key combinations.
Examples:; start Notepad, and use *.* for filenames Run("notepad.exe", "") SendKeysto("~Notepad", "!fo*.*~") ; run DOS batch file which starts our editor Run("edit.bat", "") ; wait 15 seconds for editor to load Delay(15) ; send string (with carriage return) to the clipboard crlf = StrCat(Num2Char(13), Num2Char(10)) ClipPut("Hello%crlf%") ; paste contents of clipboard to DOS window SendKeysto("~Notepad", "!{SP}ep")In those cases where you have an application which can accept text pasted in from the clipboard, it will often be more efficient to use the ClipGet function:
Run("notepad.exe", "") crlf = StrCat(Num2Char(13), Num2Char(10)) ; copy some text to the clipboard ClipPut("Dear Sirs:%crlf%%crlf%") ; paste the text into Notepad (using Shift-Ins) SendKeysto("~Notepad", "+{INSERT}")
If your SendKeysto statement doesn't seem to be working (e.g., all you get are beeping noises), you may need to recheck the name of the window to which you're trying to send keystrokes. In addition, if it's a Child window, see the function, SendkeysChild.
See Also:
ClipGet, SnapShot, WinActivate, SendkeysChild everything works perfectly except no sendkey! SendKeysto("~Notepad", "!(SP)EP")
The stuff around the SP must be the special CURLY BRACES rather than the normal parenthesis.
More info:
SendKeysto("~Notepad", "!{SP}EP")Actually the following will also work:
;when you just type a space for a space SendKeysto("~Notepad", "! EP")Also as a point of nitpicking:
SendKeysto("~Notepad", "! EP") is the same as ALT SPACE SHIFTDOWN e p SHIFTUPI don't really think you do it that way. So try:
SendKeysto("~Notepad", "! ep")
Article ID: W13834
Filename: Sending Keystrokes to Win and DOS apps.txt
File Created: 2001:01:31:10:38:16
Last Updated: 2001:01:31:10:38:16