Send - Sends keystrokes and windows messages to applications

======================================================================

Usage:    send [-rcflwdhna] [-n NewName] [-s "Class"] "application" "keys" [time]

"application" is a case-insensitive string that matches part of a window
caption.  For example, if you are running notepad, its title bar will be
something similar to "MyFile.txt - Notepad".  You could have send.exe type
the text "Hello" by using the following command:

    send notepad Hello

Spaces in the key string need to be quoted, as in:

    send notepad "Hello everyone!"
    
[time] is a string representation of a time at which you want the keys to
be sent to the application.  The application window need not exist until
that time.  For example, to send the F6 key to VirtualDub at 4:55 PM, use
the following syntax:

    send virtualdub \{F6} 4:55pm

The time string accepts several different time formats (it uses the Windows
function VarDateFromStr), including dates.  Dates with spaces must be
quoted, as in:

    send virtualdub \{F6} "April 1, 2001 10:55am"

Options:

    -r  Uses a regular expression for the search string.  For example,
        "^notepad$" would match only a window titled exactly "Notepad" and
        not one name "Untitled - Notepad".

    -c  Uses a case-sensitive search, so that "notepad" will not match
        "Notepad"

    -l  Lists all of the window captions that "send" finds before
        matching the search string.  Useful for discoving the precise
        titles of windows.

    -f  Sends the specified string to the window repeatedly.  This is most
        useful when the keystrokes you are sending will cause the window to
        close, and you want to send the same keystrokes to the window again
        when it reappears (with the -w options).
        
    -g  Sends the specified string to whichever window happens to be in
        the foreground.  Useful for arbitrary mouse movements that do not
        need a particular window to be focused.  If you specify the "-g"
        option, you must still specify a window caption, but it is ignored.
    
    -b  Does not bring the specified window to the foreground.  Keystrokes
        will still be sent to whatever window is in the foreground, but
        you may send windows messages and position/size commands to a
        background window (useful for moving a window without bringing it
        to the foreground first).  Using this option implies -d.
    
    -w  Waits for the window to exist before sending the keystrokes.

    -d  Disables switching back to the process that launched send.exe
        after sending the input string.

    -h  Includes hidden windows in the search.  Normally, a nonvisible
        window is not a desired target for input operations.

    -n  Gives the found window a new caption.  This can be useful when you
        want to send an input string that will take some time to process,
        and then use another "send" command to wait for the new window
        caption to exist.
        
    -a  Sends the commands to every window matching the expression, not
        just the first one.
        
    -s  The window must also match the class name provided.
        

======================================================================

If you want to send a special key, such as F6 or Escape, use the following
tables (examples are for notepad or other such edit controls):

----------------------------------------------------------------------

Keyboard Modifiers:
    \a      Press the ALT key
    \A      Release the ALT key
    \s      Press the SHIFT key
    \S      Release the SHIFT key
    \c      Press the CONTROL key
    \C      Release the CONTROL key
    \p      Press the APPLICATIONS key
    \P      Release the APPLICATIONS key
    \w      Press the WINDOWS key
    \W      Release the WINDWOS key

For example, "\shello\S" would send "shift, h, e, l, l, o, unshift" and
create the word "HELLO"

----------------------------------------------------------------------

Arrow Keys:
    \u      UP arrow       
    \d      DOWN arrow       
    \l      LEFT arrow       
    \r      RIGHT arrow       

For example, "hllo\l\l\le" would write "hello" by writing "hllo,"
moving left three characters, and inserting the "e" last.

----------------------------------------------------------------------

Special Keys:
    \b      Backspace
    \e      Escape
    \t      Tab
    \n      Enter/Return

For example, "Username\tPassword\n" would type a username, push tab,
type a password, and hit enter.

----------------------------------------------------------------------

Named Keys:

    \{F1}       F1 key
    \{F2}       F2 key
    ...
    \{F24}      F24 key
    \{Delete}   Delete
    \{End}      End
    \{Home}     Home
    \{Insert}   Insert
    \{PgUp}     PageUp
    \{PgDn}     PageDown
    \{PrSc}     PrintScreen
    \{Pause}    Pause
    \{ScLk}     ScrollLock

Keys may be abbreviated when unambiguous; delete = "\{d}" etc.
For example, "\{pd}\{pd}\{e}" would send PageDown twice, then the "End" key.

----------------------------------------------------------------------

Numeric Keypad:

    \{n0}       Keypad Zero
    \{n1}       Keypad One
    ...
    \{n9}       Keypad Nine
    \{n*}       Keypad *
    \{n+}       Keypad +
    \{n-}       Keypad -
    \{n/}       Keypad /
    \{n.}       Keypad .

----------------------------------------------------------------------

Mouse Commands:

Mouse commands may be given as the special key "m" followed by button index,
event, coordinates, and modifiers.  For example, to click the left
mouse button at client-local coordinates (200,100), use this syntax:

    \{m,l,click,200,100,local}

This could also be abbreviated to "\{m,l,c,200,100,l}"

"click" can be replaced with "down" or "up" if desired.  If the specified
button index is "wheel" (or simply "w"), then up/down means to roll the wheel
up or down, and "click" has no meaning (the wheel as a button is usually
the middle button).  To move the mouse without pressing a button,
specify "none" (or "n") as the action.  The buttons may be any of the
predefined buttons "l," "m," "r," "1," "2" (left, middle, right, extra 1,
extra 2).

The last option can be "local" or "screen" ("l" or "s"), and makes the given
coordinates either local to the client window, or global (to the desktop).

Some more examples:

    Press and hold the right mouse button at screen coordinates (100,50):

       \{m,r,d,100,50,s}

    Scroll the mouse wheel up at local coordinates (0,0):

       \{m,w,u,0,0,l}

    Move the mouse to screen coordinates (400,300):

       \{m,n,n,400,300,s}
       
Relative movement:
       
    Move the mouse 100 pixels to the right of its current position:
    
       \{m,n,n,100r,0r,s}

    Move the mouse 100 pixels up and click the left button:
    
       \{m,l,c,0r,-100r,s}

Note:  The mouse cursor is always moved to the selected location prior
       to executing any actions.

----------------------------------------------------------------------

Window Positioning:

The active window's size and position may be changed as shown in the
following examples:

    Move the active window to absolute position (200,100) and resize
    it to 640x480:
    
       \{wp,200,100}\{ws,640,480}
       
    Move the active window four pixels to the right and two pixels up
    
       \{wp,4r,-2r}
       
    Resize the current window to 320x240
    
       \{ws,320,240}
       
    Expand the current window by 100 pixels horizontally
    
       \{ws,100r,0}
       
Note that a zero window size is simply ignored.  A zero position,
however, indicates the top or left side of the screen.  You may also
place a position and size command in the same string, if you like
(this causes only one MoveWindow call to be made, which may or may
not be important).

    \{wp,200,100,640,480}
    
You may use the letters 'h' and 'w' in the numeric portion of the call
to represent the current height and width, respectively, of the Windows
desktop.  The following call would move the window to position (1500,800)
if your desktop resolution is 1600x1200:

    \{wp,w-100,h-400}
    
If you use the capital versions of 'H' or 'W' then the value used will be
the "work area" dimensions (those of the screen minus the task bar or
other toolbars.
    
(Do not attempt complex mathematics; what you see is about all you get.)

----------------------------------------------------------------------

Windows Messages:

You may send arbitrary windows messages to the active window during
playback.  the wParam and lParam may be omitted if '0' is desired for their
values.  For example:

    send notepad "\[WM_SYSCOMMAND,SC_MINIMIZE]"

will minimize the notepad window.  Note that this will take focus away
from this window and further keystrokes may not be recognized. 
Further windows messages, however, will be sent.  Windows message
sending is generally for advanced users, but a few common ones are
listed here for convenience:

    \[WM_CLOSE]                     Will close the active window
    \[WM_SYSCOMMAND,SC_MINIMIZE]    Minimizes the active window
    \[WM_SYSCOMMAND,SC_MAXIMIZE]    Maximizes the active window
    \[WM_SYSCOMMAND,SC_RESTORE]     "Un-minimizes" the active window

You may specify decimal or hexadecimal numbers (with the "0x" prefix), such
as in the following example:

    \[WM_COMMAND,1,0x4007]

----------------------------------------------------------------------

Pausing during sending of keystrokes.

You may have the program pause for a user-specified number of milliseconds
during playback of keystrokes by including \{sX} in the send string, where
X is an integer.  For example:

    send notepad "A\{s500}B\{s1000}C"

would send the "A" key, wait half a second, send the "B" key, wait 1
second, and then send the "C" key.

<end of help text>
======================================================================


"Send" is copyright 2001-2003 by Eric VanHeest (edv_ws@vanheest.org). 
Feel free to modify this program to suit your needs.

