About
Sendkey is a program for system administrators mainly. With it
you can create real powerful batch files, even with calling control
panels and submitting keystrokes to the active window. You can
easily automate installations or create configuration
batchfiles.
Features
- works in every Win32 Windows envirnment (NT4+, 9x,
Millenium, 2000, XP)
- command line driven (for batchfiles)
- emulates keypresses and keycombinations
- can delay batch processing
- wait function that pauses the batch processing
until a window with a certain title appears
- execution of programs processwise, so you can even
open a control panel per batch
- allows setting/getting of registry keys
Updates in Version 1.6
- Added the ### to send 3 keys at once (f.e.
CTRL-ALT-DEL)
Updates in Version 1.5
- Added the # key within the normal strings to send
some chars that wouldn't be sent otherwise (be careful doh)
- Now you can set a time for the window waiting
feature and it sets an errorlevel
Updates in Version 1.4
- Finishing Space bug fixed
- Code rewritten, now faster and easier
- The full special charset (all VK_ commands) now
suported
- Keycombinationsend fixed
- Pausing rewritten, works on every system now
- Registry read/write rewritten, now really
works
- pipe.exe utility added
- new examples
Usage Notes
SendKey [*][}][{][%][@][#][##][!][~][string][$]
#Xkey Send single key X .. how often (also special VK_...)
##Xkey+key2 same as above only with keycombinations
!key start pressing a key (also VK)
~key release key (also VK)
string Send string
* ms wait for ms Milliseconds
{ root reg key put a value from root eg key to stdout
} rt rg ky val set a key in the registry with val
% window wait til a window with that caption appears
@ cmd apram execute program (also http, ... using shellexecute)
? ms windowname wait for a certain window for ms milliseconds
(errorlevel 1 if it doesn't show up)
$ ???
Usage of the also included pipe.exe utility:
Piper V1.0
----------
prints out any piped text,
and puts any text as parameter in front of the piped one.
example: echo a Test!|pipe This is
this prints: This is a Test!
Tips:
To extract the default entry in a registry key just dont use a name
f.e.
sendkey {
HKEY_LOCAL_MACHINESoftwareCLASSESmailtoDefaultIcon
To put a registry value into a enviromental variable use it in
compinaton with the also in the zip (since Version 1.4) included
pipe utility. Example which puts the productId into the
enviromental var test:
sendkey {
HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersion
ProductID|pipe set test=>t.bat
call t.bat
del t.bat
With the ~, !, # and ## parameter you can send special keys.
Supported keys are:
- VK_LBUTTON
- VK_RBUTTON
- VK_CANCEL
- VK_MBUTTON
- VK_BACK
- VK_TAB
- VK_CLEAR
- VK_RETURN
- VK_SHIFT
- VK_CONTROL
- VK_MENU
- VK_PAUSE
- VK_CAPITAL
- VK_KANA
- VK_HANGUL
- VK_JUNJA
- VK_FINAL
- VK_HANJA
- VK_KANJI
- VK_ESCAPE
- VK_CONVERT
- VK_NONCONVERT
- VK_ACCEPT
- VK_MODECHANGE
- VK_SPACE
- VK_PRIOR
- VK_NEXT
- VK_END
- VK_HOME
- VK_LEFT
- VK_UP
- VK_RIGHT
- VK_DOWN
- VK_SELECT
- VK_PRINT
- VK_EXECUTE
- VK_SNAPSHOT
- VK_INSERT
- VK_DELETE
- VK_HELP
- VK_LWIN
- VK_RWIN
- VK_APPS
- VK_ALT
- VK_NUMPAD0
- VK_NUMPAD1
- VK_NUMPAD2
- VK_NUMPAD3
- VK_NUMPAD4
- VK_NUMPAD5
- VK_NUMPAD6
- VK_NUMPAD7
- VK_NUMPAD8
- VK_NUMPAD9
- VK_MULTIPLY
- VK_ADD
- VK_SEPARATOR
- VK_SUBTRACT
- VK_DECIMAL
- VK_DIVIDE
- VK_F1
- VK_F2
- VK_F3
- VK_F4
- VK_F5
- VK_F6
- VK_F7
- VK_F8
- VK_F9
- VK_F10
- VK_F11
- VK_F12
- VK_F13
- VK_F14
- VK_F15
- VK_F16
- VK_F17
- VK_F18
- VK_F19
- VK_F20
- VK_F21
- VK_F22
- VK_F23
- VK_F24
- VK_NUMLOCK
- VK_SCROLL
Everything is case insensitve!
Examples
Copy the following text into a batch file and start it. This
will only work
in english version of Win9x. But it shows how easy it is to
automate a process.
Example 1
In this example the Network Control Panel is being
opened, and the computer name is being changed.
After it is done, just click on cancel, so no changes on the
system are being made.
While the batch is running, dont touch the keyboard or click with
the mouse, this
would screw everything up.
Since you cant just call rundll32 by batch, you have to use the @
parameter. you can
try it without, i assure you it wont work .
netchange.bat
---------------------- copy from here -------------------
@echo off
REM Open network control panel
Sendkey @ C:WINDOWS undll32.exe shell32.dll,Control_RunDLL
c:windowssystem etcpl.cpl
rem Wait until its open (the panel has the caption 'Network')
Sendkey %% Net
rem Wait another second, just to make sure its really open
Sendkey * 1000
rem Move the selection to the top tabs
Sendkey #6VK_TAB
rem once right - Identification
Sendkey #1VK_RIGHT
rem go down to the Computer description field
sendkey #3VK_TAB
rem Insert a description
sendkey This is a test!
REM done
------------------------- done ----------------------
Example 2
This is one of my favorite batch files. It shows how powerful
sendkey is. All it does is wait until you open notepad. as soon as
that happened, the batch will start to act. It will write a text
into the notepad window andopens the file save dialog.
---------- cut here ----------
@echo off
rem Wait until a window with the caption: "Untitled -.." appears
rem this is notepad with a new file
rem there are two %% because in batch files only one % is for
variables
rem using two is the actual %
sendkey %% Untitled
rem wait a sec just to make sure
sendkey * 1000
rem now send some text to write
sendkey This is a test
rem next open the save as dialog
sendkey #1VK_ALT
sendkey F
sendkey A
rem if you would do a sendkey #1VK_RETURN it would save the file
rem NOW open notepad and see whats happening
rem if you have a different language of win (f.e. german)
rem make sure to edit the Sendkey %% Untitled to whatever
rem it says in your windows (f.e. Sendkey %% Unbenannt)
----------- cut here ----------
Example 3
This example shows the two key sending feature to open a print
dialog in microsoft word
---------- cut here ----------
@echo off
rem Wait until a window with the caption: "Document1-.." appears
rem this is notepad with a new file
rem there are two %% because in batch files only one % is for
variables
rem using two is the actual %
sendkey %% Document1
rem wait a sec just to make sure
sendkey * 1000
rem now send some text to write
sendkey This is a test
rem next open the print as dialog
sendkey ##1VK_CONTROL+P
rem if you have a different language of win (f.e. german)
rem make sure to edit the Sendkey %% Untitled to whatever
rem it says in your windows (f.e. Sendkey %% Unbenannt)
----------- cut here ----------
Example 4
This example demonstrates the new escape characters since
V1.5
---------- cut here ----------
@echo off
sendkey %% Document1
sendkey hello, world#h!#h
---------- cut here ----------
Why does sendkey always put out a ; instead of a colon : ?
Sendkey puts keyboard events in the keyboard buffer to be read
from windows (keystrokes). They are then read by windows and sent
to the current open window. This is also the reason why a colon is
always misprinted, because a colon is in real a ;+shift (or on
german keyboard a .+shift). If you want to send a colon or a ! or
something like that you have to tell the program to hold the shift
key. Since version 1.5 I included a little workaround for these
kind of problems:
if you want to send c: empsomefile.txt use: s#h:#h
empsomefile.txt the #h sets the shift state.
|