User interface(n) 0.1 "Windows and user input"
User interface - Functions related to windows and input management
package require twapi
This package provides procedures related to user input and window management
on Windows platforms.
Windows are identified using window handles. A window handle consisting
of an empty string represents an invalid or non-existent window.
The commands get_toplevel_windows, get_descendent_windows and
get_child_windows enumerate the windows on the system.
get_desktop_window and get_shell_window return handles to
the desktop window and the shell window respectively. find_windows
returns a list of windows that satisfy matching multiple matching criteria.
The command
window_exists can be used to check if a specific window exists.
The commands get_parent_window, get_owner_window,
get_first_child, get_next_sibling_window,
get_prev_sibling_window, get_first_sibling_window,
get_last_sibling_window,
retrieve handles to windows with the appropriate relationship to the
specified window. The command window_is_child can be used to check
parent-child relationships between windows.
The commands get_window_process and get_window_thread retrieve
the process and thread respectively that own the specified window.
get_window_application returns the application instance for the specified
window.
The commands
get_foreground_window, set_foreground_window,
set_window_zorder
deal with the position of windows in the display Z-order.
The commands show_window, hide_window, restore_window,
minimize_window, maximize_window,
show_owned_popups and hide_owned_popups control the visibility
of windows. The commands window_minimized, window_maximized,
window_visible check the visibility state of a window.
The commands get_window_style, set_window_style,
get_window_class, get_window_real_class,
get_window_long and set_window_long,
get_window_userdata and set_window_userdata,
retrieve and modify
various attributes associated with windows.
The command get_window_id returns the window id of the specified window.
redraw_window and redraw_window_frame cause the window and
the frame of a window to be redrawn respectively.
The commands move_window, resize_window and arrange_icons
can be used to for positioning and resizing windows. The commands
get_window_client_area_size and get_window_coordinates can be
used to get window location and size. The command get_window_at_location
returns the window at a given screen location.
The commands
set_active_window_for_thread, get_active_window_for_thread,
get_focus_window_for_thread, get_active_window_for_current_thread
deal with the active window state and focus for a particular thread.
The commands enable_window_input, disable_window_input and
set_focus deal with controlling input to windows. The command
window_input_enabled can be used to check if input to a window is
enabled or not.
window_unicode_enabled checks if a window is Unicode-enabled or not.
The commands flash_window_caption and beep can be used to
grab the user's attention by flashing a window or generating a sound.
The commands get_window_text and set_window_text retrieve
and modify the title bar of a window or the text associated with a
control. In the latter case, only controls in the same application
are supported.
The commands get_caret_blink_time, set_caret_blink_time,
hide_caret, show_caret, get_caret_location and
set_caret_location allow manipulation of the caret and its position.
The commands send_input, send_keys,
send_input_text, move_mouse,
click_mouse_button and turn_mouse_wheel can be used
to simulate user input. The mouse position can be retrieved using
get_mouse_location
The commands play_sound and stop_sound provide basic
functionality for generating sound.
- get_toplevel_windows ?-pid PID?
-
Returns a list of handles to toplevel windows in the system. If no options
are specified, this includes all toplevel windows. If the -pid option
is specified with a numeric value of PID, then only toplevel windows
owned by the process with id PID are returned. If PID is
non-numeric, it is treated as a process name. In this case, the toplevel
windows owned by all processes whose name is PID are returned.
- find_windows ?options?
-
Returns a list of handles corresponding to all windows that match the
specified criteria. The following options control the matching
criteria:
- -single
- Returns the first window found without looking
for additional windows.
- -pids PIDLIST
- The window must be owned by a process
whose id is in PIDLIST.
- -toplevel
- The window must be a toplevel window.
- -text PATTERN
- The text associated with the window
(generally the window title) must match PATTERN. The matching is
done based on the -match option.
- -match MATCHTYPE
- Specifies the method used for
matching PATTERN in the -text option. This may be one of
string for an straight character match, glob for matching
as in the string match command or regexp for regular
expression based matching. In all cases, the comparisons are
case-insensitive.
- -class CLASS
- The window must belong to the specified
class.
- -ancestor HWIN
- The window must have the window
with handle HWIN as an ancestor.
- -style STYLE
- The window must have the specified style.
STYLE must be specified as a list of two integer values corresponding
to the style and extended style for the window. See get_window_style.
- -visible BOOLEAN
- The window must be visible if
BOOLEAN is true and hidden if it is false.
- -overlapped BOOLEAN
-
The window must or must not be an overlapped window
depending on whether BOOLEAN is true or false.
- -popup BOOLEAN
-
The window must or must not be an popup window
depending on whether BOOLEAN is true or false.
- -child BOOLEAN
-
The window must or must not be an child window
depending on whether BOOLEAN is true or false.
- -caption BOOLEAN
-
The window must or must not have a caption/title bar
depending on whether BOOLEAN is true or false.
- -minimize BOOLEAN
-
The window must or must not be minimized
depending on whether BOOLEAN is true or false.
- -maximize BOOLEAN
-
The window must or must not be maximized
depending on whether BOOLEAN is true or false.
- -minimizebox BOOLEAN
-
The window must or must not have a minimize box on the title bar
depending on whether BOOLEAN is true or false.
- -maximizebox BOOLEAN
-
The window must or must not have a maximize box on the title bar
depending on whether BOOLEAN is true or false.
- get_descendent_windows HWIN
-
Returns a list of handles to all descendent windows of the specified window.
- get_child_windows HWIN
-
Returns a list of handles to all windows that are immediate child windows
of the specified window.
- get_parent_window HWIN
-
Returns a handle to the parent window of the specified window.
- get_owner_window HWIN
-
Returns a handle to the owner window of the specified window or null handle
if the window does not have a owner.
- get_first_child HWIN
-
Returns a handle to the child window of the specified window that is the
first (highest) in the display Z-order.
- get_next_sibling_window HWIN
-
Returns a handle to a sibling window (ie. having the same parent)
of the specified window that is next in the display Z-order.
- get_prev_sibling_window HWIN
-
Returns a handle to a sibling window (ie. having the same parent)
of the specified window that is previous (immediately higher)
in the display Z-order.
- get_first_sibling_window HWIN
-
Returns a handle to a sibling window (ie. having the same parent)
of the specified window that is the highest
in the display Z-order.
- get_last_sibling_window HWIN
-
Returns a handle to a sibling window (ie. having the same parent)
of the specified window that is the lowest (least visible)
in the display Z-order.
- get_desktop_window
-
Returns a handle to the desktop window.
- get_shell_window
-
Returns a handle to the Windows shell process' window.
- get_window_process HWIN
-
Returns the id of the process that owns the specified window.
- get_window_thread HWIN
-
Returns the id of the thread that owns the specified window.
- get_window_style HWIN
-
Returns a list containing the style and the extended
style bits respectively followed by symbolic window style attributes
corresponding to the style bits. The window styles attributes that may be
returned are shown below.
Refer to the Windows
SDK documentation for the meaning of these styles.
- overlapped
-
The window is an overlapped window - this is a toplevel window without a
parent. This attribute is mutually exclusivce with popup
and child.
- popup
-
The window is popup window like a dialog box.
This attribute is mutually exclusivce with overlapped
and child.
- child
-
The window is the child of some other window.
This attribute is mutually exclusivce with popup
and overlapped.
- caption
-
The window has a caption or title bar and a border.
- border
-
The window has a normal border and no title bar.
- dlgframe
-
The window has a double border as used for dialogs and no title bar.
- dlgmodalframe
-
The window has a double border as used for a dialog and may have a caption
as well.
- minimize
-
The window is minimized. Windows with neither minimize or
maximize attributes are normal windows.
- maximize
-
The window is maximized. Windows with neither minimize or
maximize attributes are normal windows.
- visible
-
The window is visible. If this border is not present, the window is hidden.
- disabled
-
The window is disabled and does not accept input.
- clipsiblings
-
Indicates that the screen area occupied by
sibling windows that overlap will not be overwritten when the window is drawn.
- clipchildren
-
Indicates that the screen area occupied by
child windows will not be overwritten when the window is drawn.
- vscroll
-
The window displays a vertical scrollbar.
- hscroll
-
The window displays a horizontal scrollbar.
- sysmenu
-
The window displays a system menu.
- thickframe
-
The window has a thick border that allows for resizing.
- noparentnotify
-
The window is a child window that does not send WM_PARENTNOTIFY messages
to its parent.
- topmost
-
The window is a topmost window that is displayed above all non-topmost
windows even when it is not active.
- acceptfiles
-
The window accepts files that are dragged and dropped into it.
- transparent
-
The window is transparent and does not obscure windows below it.
- mdichild
-
The window is an MDI child window.
- toolwindow
-
The window is a floating toolbar. The title bar and caption are shrunk.
The window does not appear in the task bar and will not show up
with the ALT-TAB hotkey.
- windowedge
-
The window has a border with a raised edge.
- clientedge
-
The window has a border with a sunken edge.
- contexthelp
-
The window has a context help button in the caption bar.
- controlparent
-
The window allows navigation between child windows using the TAB key.
- staticedge
-
The window has a 3-D border.
- appwindow
-
The window is forced on the task bar when visible. Note that this does not
mean that windows without this attribute will not show up on the task bar. It
does mean that windows with this attribute will definitely show up on the
task bar.
- set_window_style HWIN style exstyle
-
Sets the style and extended style bits for the specified window.
style and exstyle are bitmasks. Refer
to the Windows SDK documentation for details.
- get_window_long HWIN INDEX
-
This is a direct call to the GetWindowsLong function. Refer to Windows
SDK documentation for details. Several other TWAPI functions act as wrappers
provide more straightforward access to the values retrieved by this function.
- set_window_long HWIN INDEX VALUE
-
This is a direct call to the SetWindowsLong function. Refer to Windows
SDK documentation for details. Several other TWAPI functions act as wrappers
provide more straightforward access to the values set by this function.
- get_window_id HWIN
-
Returns the window id of the specified window. Note that this is different
than the window handles.
- get_window_application HWIN
-
Returns the application instance associated with the specified window.
- get_foreground_window
-
Returns the current foreground window on the desktop.
- set_foreground_window HWIN
-
Sets the specified window to be the foreground window. Returns
1 if successful,
and 0 otherwise.
- set_active_window_for_thread HWIN
-
Sets the specified window to be the active window for its owning thread.
The window is brought to the foreground if the owning thread belongs to
the foreground application.
Returns the handle of the window that was previously active.
- get_active_window_for_thread TID
-
Returns the current active window for the thread with id TID. If the
thread does not have a active window, returns $twapi::null_hwin.
- get_focus_window_for_thread TID
-
Returns the window which has the focus the thread with id TID. If the
thread does not have a active window, returns $twapi::null_hwin.
- get_active_window_for_current_thread TID
-
Returns the current active window for the current thread. If the
thread does not have a active window, returns $twapi::null_hwin.
- get_window_class HWIN
-
Returns the class of a window. This is simple wrapper around
the GetClassName Windows function.
- get_window_real_class HWIN
-
Returns the real class of a window for classes that are wrapped by applications
into their own set of classes. This is simple wrapper around the
RealGetWindowClass Windows function.
Windows function.
- get_window_userdata HWIN
-
Returns the longword associated as user data with the specified window. This
maps to the Windows GetWindowLong call with an argument of
GWL_USERDATA.
- get_window_userdata HWIN
-
Sets the longword associated as user data with the specified window.
This maps to the Windows SetWindowLong call with an argument of
GWL_USERDATA.
- redraw_window HWIN ?-force?
-
This command causes the invalidate regions of the
specified window to be redrawn. If -force is specified, the entire
window is redrawn.
- redraw_window_frame HWIN
-
This command causes the frame of the specified window to be redrawn.
- move_window HWIN X Y
-
Moves the specified window such that it's left side is at position X
and its top side is at position Y.
- resize_window HWIN W H
-
Resizes the specified window to be W pixels in width and H pixels
in height.
- set_window_zorder HWIN POS
-
Sets the position of the specified window in the Z-order. POS may be
either a window handle or a keyword. In the former case, the window is
placed right after the window specified by POS. Otherwise, POS
must be one of the following keywords:
- top
- Places the window at the top of the Z-order.
- bottom
- Places the window at the bottom of the Z-order.
- toplayer
- Refer to explanation of HWND_TOPMOST in
the documentation of the function SetWindowsPos in the Windows SDK.
- bottomlayer
- Refer to explanation of HWND_NOTOPMOST in
the documentation of the function SetWindowsPos in the Windows SDK.
- show_window HWIN ?options?
-
Makes the specified window visible. Note that a visible window may still
be obscured by other windows or clipped.
The command returns 1 if the window was previously visible, else 0.
The return value is valid only if the -sync option is specified.
- -sync
- If specified, the command will execute synchronously
and only return when the window procedure of the target window has handled
the request. Note that if the target window is hung, the command will never
return in this case.
- -activate
- In addition to being shown, the window is
also activated.
- -normal
- If a window is minimized or maximized, restores
it to its original position.
- -startup
- Shows the window based on the contents of the
STARTUPINFO structure when the process was created.
If both -normal and -startup are specified, -startup takes
precedence. If neither is specified, the window is shown in its current form,
which may be minimized, maximized or normal.
- hide_window HWIN ?-sync?
-
Hides the specified window so it does not appear on the display or as an icon.
If option -sync is specified, the command will execute synchronously
and only return when the window procedure of the target window has handled
the request. Note that if the target window is hung, the command will never
return in this case.
Returns 1 if the window was previously visible, else 0. The return value is
valid only if the -sync option is specified.
- restore_window HWIN ?options?
-
Restores a window to its original size and position if it is maximized
or minimized.
The command returns 1 if the window was previously visible, else 0.
The return value is valid only if the -sync option is specified.
- -sync
- If specified, the command will execute synchronously
and only return when the window procedure of the target window has handled
the request. Note that if the target window is hung, the command will never
return in this case.
- -activate
- In addition to being shown, the window is
also activated.
- minimize_window HWIN ?options?
-
Minimizes the specified window.
- -sync
- If specified, the command will execute synchronously
and only return when the window procedure of the target window has handled
the request. Note that if the target window is hung, the command will never
return in this case.
- -activate
- If specified, in addition to being shown,
the window is also activated.
- -shownext
- If specified, the next window in the Z-order is
activated.
The command returns 1 if the window was previously visible, else 0.
The return value is valid only if the -sync option is specified.
- maximize_window HWIN ?-sync?
-
Maximizes the specified window.
If option -sync is specified, the command will execute synchronously
and only return when the window procedure of the target window has handled
the request. Note that if the target window is hung, the command will never
return in this case.
The command returns 1 if the window was previously visible, else 0.
The return value is valid only if the -sync option is specified.
- hide_owned_popups HWIN
-
Hides all popup windows that are owned by the specified window.
- show_owned_popups HWIN
-
Shows all popup windows owned by the specified window that were hidden
by a previous call to hide_owned_popups. Note that popups that were
hidden using other functions such as hide_window will not be shown
by this call.
- enable_window_input HWIN
-
Enables mouse and keyboard input to the specified window. Returns 1 if the
window was previously disabled, else 0.
- disable_window_input HWIN
-
Disables mouse and keyboard input to the specified window. Returns 1 if the
window was previously disabled, else 0.
- close_window HWIN ?options?
-
Closes the specified window by sending it a WM_CLOSE message.
The following options may be specified:
- -block
- If this option is specified, Windows will block the
calling thread from processing any other requests until the command returns.
- -wait TIMEOUT
- Specifies the number of milliseconds to
wait for the windows to process the message. This is 20 milliseconds by
default.
- window_minimized HWIN
-
Returns 1 if the specified window has been minimized, else 0.
- window_maximized HWIN
-
Returns 1 if the specified window is maximized, else 0.
- window_visible HWIN
-
Returns 1 if the specified window is visible, else 0. Note that visible does
not imply user can actually see the window (it may be obscured or clipped).
- window_exists HWIN
-
Returns 1 if the specified window exists, else 0.
- window_unicode_enabled HWIN
-
Returns 1 if the specified window is a native Unicode window, else 0.
- window_input_enabled HWIN
-
Returns 1 if the specified window has mouse and keyboard input enabled, else 0.
- window_is_child PARENTHWIN CHILDHWIN
-
Returns 1 if the window CHILDHWIN is a child of the
window PARENTHWIN, else 0.
- set_focus HWIN
-
Sets the focus to the specified window. The window, or its parent, is also
activated.
- beep ?options?
-
Generates a sound on the system speaker.
The following options may be specified:
- -frequency FREQUENCY
- The frequency of the sound
to be produced. This is 1000Hz by default.
- -duration MILLISECONDS
- The duration of the sound
to be produced. This is 100 milliseconds by default.
- -type SOUNDIDENTIFIER
- Specifies the type of sound to
produce. SOUNDIDENTIFIER may be one of ok, hand,
question, exclaimation or asterisk. These will
produce the corresponding sounds configured in the Windows control panel.
If this option is specified, the options
-duration and -frequency are ignored.
- flash_window_caption HWIN ?-toggle?
-
Flashes the window's title bar. If -toggle is not specified, the window's
title bar reverts back to the original state. If -toggle is specified,
the title bar stays in the new state.
- arrange_icons ?HWIN?
-
Arranges all the minimized (iconized) child windows of the specified window.
If HWIN is not specified, it defaults to the desktop window.
The command returns the height of one row of icons.
- get_window_text HWIN TEXT
-
Gets the title of a window or the text associated with a control. In the latter
case, the control must belong to the same application.
- set_window_text HWIN TEXT
-
Sets the title of a window or the text associated with a control. In the latter
case, the control must belong to the same application.
- get_window_client_area_size HWIN
-
Returns a list of two integers containing
the width and height in pixels of the client area of the window.
- get_window_client_area_size HWIN
-
Returns a list of two integers containing
the width and height in pixels of the client area of the window.
- get_window_coordinates HWIN
-
Returns the screen coordinates of the window as a list of four integers
corresponding to the left, top, right and bottom sides
of the window.
- get_window_at_location X Y
-
Returns the highest window in the X-order that contains the
screen coordinates (X,Y). Windows that are disabled or hidden
are not ignored.
- invalidate_screen_region ?options?
-
Marks a region of the screen as invalid. If no options are specified, all
windows are marked invalid, forcing them to be redrawn.
The following options may be used with the command:
- -hwin HWIN
- Indicates the specific window whose
client region is to be invalidated.
- -rect RECT
- If specified, this should be a list of
four integers indicating the coordinates of the left, top, right, bottom
sides of the region in the window's client area that is to be invalidated.
If unspecified or an empty list, the entire client region is marked invalid.
- -bgerase
- If specified, the background within the invalidated
region is erased. Otherwise, it remains unchanged.
- get_caret_blink_time
-
Returns the blink time of the caret in milliseconds.
- set_caret_blink_time MILLISECONDS
-
Sets the blink time of the caret to MILLISECONDS milliseconds.
- hide_caret
-
Hides the caret. Note that calls to hide_caret or twapi::HideCaret
must be matched by an equivalent number of calls to
show_caret or twapi::ShowCaret.
- show_caret
-
Shows the caret. Note that calls to hide_caret or twapi::HideCaret
must be matched by an equivalent number of calls to
show_caret or twapi::ShowCaret to make the caret visible.
- get_caret_location
-
Returns a list of two integers specifying the caret's coordinates. These
are always with respect to the client area of the window that owns the
caret.
- get_caret_location POINT
-
Sets the caret's location to POINT which must
be a list of two integers specifying the caret's coordinates.
- send_input INPUTLIST
-
Simulates user input by generating keyboard and mouse events based on
INPUTLIST. This must be in the form of a list of sublists, each sublist
being a keyboard or mouse input event specification.
A keyboard input specification takes the form
"KEYTYPE VK SCANCODE ?keyopts?".
KEYTYPE may have one of the following values:
- key
- Specifies a virtual key being pressed and released.
This is a more convenient form of specifying consecutive keydown,
keyup events.
VK should be an integer in the range 1-254 and specifies the virtual key.
SCANCODE specifies a hardware scancode for the key. If -usescan
is specified in keyopts, the specified scan code is used
and VK will be ignored by the system. If -extended is specified
in keyopts, the key is treated as an extended key with the scan code
being preceded by a byte that has value 0xE0.
- keydown
- Specifies a virtual key being pressed. VK
should be an integer in the range 1-254 and specifies the virtual key.
SCANCODE specifies a hardware scancode for the key. keyopts may
have the same values as specified for vkey.
- keyup
- Specifies a virtual key being released. VK
should be an integer in the range 1-254 and specifies the virtual key.
SCANCODE specifies a hardware scancode for the key. keyopts may
have the same values as specified for vkey.
- unicode
- Specifies a unicode character. SCANCODE should
contain the integer corresponding to the unicode character. VK and
any keyopts are ignored if specified.
For more detailed information, refer the the documentation of the
KEYBDINPUT structure in the Windows SDK.
send_input should generally be used only for the most low level
input sequences involving both keyboard and mouse input.
If only simulating user input of text, use send_input_text as a more
more convenient alternative. If the input includes non-text keys in addition
to text (eg. function keys), use send_keys.
A mouse input specification takes the form
"mouse XPOS YPOS ?mouseopts?".
Arguments XPOS and YPOS specify the position of the mouse in
absolute (default) or relative coordinates. In the former case, the values
range from 0 to 65535 and are in mouse coordinates. In the latter case,
the values are in pixels. Note when relative mode is used, the system will
take into account the mouse speed and acceleration settings. The command
move_mouse is much simpler to use unless you have a need to
send complex mouse input sequences.
mouseopts may contain
one or more of the following options:
- -relative
- Indicates that XPOS and YPOS should
be treated as relative to the last reported position, and not as absolute
coordinates.
- -ldown
- Indicates that the left mouse button has been
pressed since the last reported event.
- -lup
- Indicates that the left mouse button has been
released since the last reported event.
- -rdown
- Indicates that the right mouse button has been
pressed since the last reported event.
- -rup
- Indicates that the right mouse button has been
released since the last reported event.
- -mdown
- Indicates that the middle mouse button has been
pressed since the last reported event.
- -mup
- Indicates that the middle mouse button has been
released since the last reported event.
- -x1down
- Indicates that the first X button has been
pressed since the last reported event.
- -x1up
- Indicates that the first X button has been
released since the last reported event.
- -x2down
- Indicates that the second X button has been
pressed since the last reported event.
- -x2up
- Indicates that the second X button has been
released since the last reported event.
- -moved
- Indicates that the mouse has moved since the last
reported event.
- -wheel WHEELUNITS
- Indicates that the mouse wheel was
rotated by WHEELUNITS. This may be a positive integer for
forward rotation, or a negative integer for backward rotation. This option
may not be used with any of the X button options.
For more detailed information, refer the the documentation of the
MOUSEINPUT structure in the Windows SDK.
The commands move_mouse, click_mouse_button and
turn_mouse_wheel may be more convenient for simple cases.
- send_input_text TEXT
-
Simulates user input by generating keyboard events corresponding to TEXT.
- send_keys KEYSEQUENCE
-
Simulates user input of keyboard events. This function differs from
send_input_text in that the keys generated may include non-text
keys such as function keys, modifier keys etc.. KEYSEQUENCE indicates
the keys to be generated and is specified with the syntax defined below. This
syntax is a superset of the syntax used by the Visual Basic SendKeys command.
All characters in KEYSEQUENCE result in the corresponding keystroke
being generated except for the following characters which have a special
meaning:
The ~ character stands for the ENTER key.
The +, ^ and % characters are used as key modifiers
for the following character or character groups.
The + character is used to indicate the following character should be
entered as though the SHIFT key was pressed while entering the
character. Similarly, ^ and % indicate the CTRL
and ALT modifiers respectively. For example, the sequence
+ab will result in the following key stroke sequence being generated:
SHIFT is pressed and held down, the a key is pressed
and released, the SHIFT key is released, and finally the b key
is pressed and released.
The ( and ) characters are used to group a set of
characters together. This is used for applying a key modifier to a
sequence of characters. For example, the sequence
+(abc) will result in the following
key stroke sequence being generated:
SHIFT is pressed and held down and then the keys a,
b and c are pressed
and released before the SHIFT key is released.
The { and } keys are used to indicate special keys
such as function keys and to enter the special characters such as
+. Thus, {+} will result in the key +
being pressed and released. Similarly, {(} and {}}
indicate the character ( and } being entered.
As a special case, the form {C N} results
in the character C being entered N times. Note that
the character may be any character, not just a special character that
needs to be escaped.
The other use of the braced escape sequence is to enter special
keys. These special sequences and the corresponding generated keystrokes are:
- {BACKSPACE}
- Backspace
- {BACK}
- (same as {BACKSPACE})
- {BS}
- (same as {BACKSPACE})
- {BKSP}
- (same as {BACKSPACE})
- {TAB}
- Tab
- {CLEAR}
-
- {ENTER}
- Enter key on the main keyboard
- {RETURN}
- (same as {ENTER})
- {SHIFT}
- Shift (see note below on difference
between this and use of the + modifier).
- {CONTROL}
- Shift (see note below on difference
between this and use of the ^ modifier).
- {ALT}
- Shift (see note below on difference
between this and use of the % modifier).
- {MENU}
- (same as {ALT})
- {PAUSE}
- Pause
- {BREAK}
- Break
- {CAPSLOCK}
- Caps Lock
- {CAPITAL}
- (same as {CAPSLOCK})
- {KANA}
-
- {HANGEUL}
-
- {HANGUL}
-
- {JUNJA}
-
- {FINAL}
-
- {HANJA}
-
- {KANJI}
-
- {ESCAPE}
- Escape
- {ESC}
- (same as {ESCAPE})
- {CONVERT}
-
- {NONCONVERT}
-
- {ACCEPT}
-
- {MODECHANGE}
-
- {SPACE}
- Spacebar
- {PGUP}
- Page Up
- {PRIOR}
- (same as {PGUP})
- {PGDN}
- Page Down
- {NEXT}
- (same as {PGDN})
- {END}
- End
- {HOME}
- Home
- {LEFT}
- Left arrow
- {UP}
- Up arrow
- {RIGHT}
- Right arrow
- {DOWN}
- Down arrow
- {SELECT}
-
- {PRTSC}
- Print Scrn
- {PRINT}
- (same as {PRTSC})
- {EXECUTE}
-
- {SNAPSHOT}
-
- {INSERT}
- Insert
- {INS}
- (same as {INSERT})
- {DELETE}
- Delete
- {DEL}
- (same as {DELETE})
- {HELP}
- Help
- {LWIN}
- Left Windows key
- {RWIN}
- Right Windows key
- {APPS}
-
- {SLEEP}
-
- {NUMPAD0}
- Numeric keypad 0
- {NUMPAD1}
- Numeric keypad 1
- {NUMPAD2}
- Numeric keypad 2
- {NUMPAD3}
- Numeric keypad 3
- {NUMPAD4}
- Numeric keypad 4
- {NUMPAD5}
- Numeric keypad 5
- {NUMPAD6}
- Numeric keypad 6
- {NUMPAD7}
- Numeric keypad 7
- {NUMPAD8}
- Numeric keypad 8
- {NUMPAD9}
- Numeric keypad 9
- {MULTIPLY}
- Numeric keypad *
- {ADD}
- Numeric keypad +
- {SEPARATOR}
-
- {SUBTRACT}
- Numeric keypad -
- {DECIMAL}
- Numeric keypad .
- {DIVIDE}
- Numeric keypad /
- {F1}
- Function key F1
- {F2}
- Function key F2
- {F3}
- Function key F3
- {F4}
- Function key F4
- {F5}
- Function key F5
- {F6}
- Function key F6
- {F7}
- Function key F7
- {F8}
- Function key F8
- {F9}
- Function key F9
- {F10}
- Function key F10
- {F11}
- Function key F11
- {F12}
- Function key F12
- {F13}
- Function key F13
- {F14}
- Function key F14
- {F15}
- Function key F15
- {F16}
- Function key F16
- {F17}
- Function key F17
- {F18}
- Function key F18
- {F19}
- Function key F19
- {F20}
- Function key F20
- {F21}
- Function key F21
- {F22}
- Function key F22
- {F23}
- Function key F23
- {F24}
- Function key F24
- {NUMLOCK}
- Numlock
- {SCROLL}
- Scroll lock
- {SCROLLLOCK}
- Scroll lock
- {LSHIFT}
- Left Shift
- {RSHIFT}
- Right Shift
- {LCONTROL}
- Left Control
- {RCONTROL}
- Right Control
- {LALT}
- Left Alt
- {LMENU}
- (same as {LALT})
- {RALT}
- Right Alt
- {RMENU}
- (same as {RALT})
- {BROWSER_BACK}
- Back
- {BROWSER_FORWARD}
- Forward
- {BROWSER_REFRESH}
-
- {BROWSER_STOP}
- Stop
- {BROWSER_SEARCH}
- Search
- {BROWSER_FAVORITES}
- Favorites
- {BROWSER_HOME}
- Web Home
- {VOLUME_MUTE}
-
- {VOLUME_DOWN}
-
- {VOLUME_UP}
-
- {MEDIA_NEXT_TRACK}
-
- {MEDIA_PREV_TRACK}
-
- {MEDIA_STOP}
-
- {MEDIA_PLAY_PAUSE}
-
- {LAUNCH_MAIL}
-
- {LAUNCH_MEDIA_SELECT}
-
- {LAUNCH_APP1}
-
- {LAUNCH_APP2}
-
Note that use of the braced sequences for the modifier keys such as
SHIFT is not the same as the corresponding special characters.
For example, the string {SHIFT}a results in the key sequence
where the SHIFT key is pressed and released before the
a key is pressed. The string +a on the other hand results
in a key sequence where the SHIFT key is released after
the a is pressed and released.
- move_mouse XPOS YPOS ?-relative?
-
Generates input to simulate mouse movement. Movement is in absolute mouse
coordinates unless the option -relative is specified. See description
of send_input for more details.
- click_mouse_button BUTTON
-
Generates input to simulate clicking the specified mouse button. BUTTON
may have one of the values left, right, middle,
x1 or x2 to specify the button that was clicked.
- turn_mouse_wheel WHEELUNITS
-
Generates input to simulate turning the wheel. A positive value of
WHEELUNITS simulates forward rotation by the specified number
of units, a negative value simulates backward rotation.
- get_mouse_location
-
Returns a pair of integers containing the mouse cursor's
X and Y screen coordinates in pixels.
- play_sound NAME ?options?
-
Plays a sound on the system audio device. The sound may either be a WAV
file or a system defined sound (if the -alias option is
specified).
The following options may be specified to control the sound:
- -alias
- By default, NAME is assumed to be the path
of a WAV file.
If -alias is specified, NAME is assumed to be the name of a
system sound.
The following system defined sounds are guaranteed to
be present on all systems: SystemAsterisk, SystemExclamation,
SystemExit, SystemHand, SystemQuestion and
SystemStart. Other system defined names can be located under
the HKEY_CURRENT_USER\AppEvents\EventLabels registry key. Note
that a sound will only be played if a WAV file has been associated with
it through the control panel.
- -async
- If specified, the sound is played asynchronously
and command will return immediately.
By default, the command will return only after the sound
has completed playing.
- -loop
- Specification of this option causes the sound to
be played repeatedly until stopped through a stop_sound command.
This option also automatically enables the -async option.
- -nodefault
- If the system cannot find the specified sound,
it plays a default sound file. If this option is specified, the command
will return without playing any sound if the specified sound file is
not found.
- -nostop
- Normally, the audio device is playing some other file,
the command will attempt to stop the currently playing sound.
If -nostop is
specified, the command will return immediately without attempting to stop
the current sound.
- -wait
- If the audio driver is busy, the command will return
right away. If this option is specified, the command will wait for the driver
to become available.
- stop_sound ?-name NAME?
-
Stops all currently playing sounds. If -name is specified, the
command will only
stop sounds with name (path) NAME.
keyboard input, mouse input, sounds, window attributes, window geometry, window visibility, windows
Copyright © 2003, Ashok P. Nadkarni