API Reference for Enthought Tool Suite 3.0.1
DIBSECT_H = _guitest.DIBSECT_H
GWL_EXSTYLE = _guitest.GWL_EXSTYLE
GWL_ID = _guitest.GWL_ID
GWL_STYLE = _guitest.GWL_STYLE
KEYEVENTF_EXTENDEDKEY = _guitest.KEYEVENTF_EXTENDEDKEY
KEYEVENTF_KEYUP = _guitest.KEYEVENTF_KEYUP
LVS_ALIGNLEFT = _guitest.LVS_ALIGNLEFT
LVS_ALIGNMASK = _guitest.LVS_ALIGNMASK
LVS_ALIGNTOP = _guitest.LVS_ALIGNTOP
LVS_AUTOARRANGE = _guitest.LVS_AUTOARRANGE
LVS_EDITLABELS = _guitest.LVS_EDITLABELS
LVS_ICON = _guitest.LVS_ICON
LVS_LIST = _guitest.LVS_LIST
LVS_NOCOLUMNHEADER = _guitest.LVS_NOCOLUMNHEADER
LVS_NOLABELWRAP = _guitest.LVS_NOLABELWRAP
LVS_NOSCROLL = _guitest.LVS_NOSCROLL
LVS_NOSORTHEADER = _guitest.LVS_NOSORTHEADER
LVS_OWNERDRAWFIXED = _guitest.LVS_OWNERDRAWFIXED
LVS_REPORT = _guitest.LVS_REPORT
LVS_SHAREIMAGELISTS = _guitest.LVS_SHAREIMAGELISTS
LVS_SHOWSELALWAYS = _guitest.LVS_SHOWSELALWAYS
LVS_SINGLESEL = _guitest.LVS_SINGLESEL
LVS_SMALLICON = _guitest.LVS_SMALLICON
LVS_SORTASCENDING = _guitest.LVS_SORTASCENDING
LVS_SORTDESCENDING = _guitest.LVS_SORTDESCENDING
LVS_TYPEMASK = _guitest.LVS_TYPEMASK
LVS_TYPESTYLEMASK = _guitest.LVS_TYPESTYLEMASK
SW_FORCEMINIMIZE = _guitest.SW_FORCEMINIMIZE
SW_HIDE = _guitest.SW_HIDE
SW_MAX = _guitest.SW_MAX
SW_MAXIMIZE = _guitest.SW_MAXIMIZE
SW_MINIMIZE = _guitest.SW_MINIMIZE
SW_NORMAL = _guitest.SW_NORMAL
SW_RESTORE = _guitest.SW_RESTORE
SW_SHOW = _guitest.SW_SHOW
SW_SHOWDEFAULT = _guitest.SW_SHOWDEFAULT
SW_SHOWMAXIMIZED = _guitest.SW_SHOWMAXIMIZED
SW_SHOWMINIMIZED = _guitest.SW_SHOWMINIMIZED
SW_SHOWMINNOACTIVE = _guitest.SW_SHOWMINNOACTIVE
SW_SHOWNA = _guitest.SW_SHOWNA
SW_SHOWNOACTIVATE = _guitest.SW_SHOWNOACTIVATE
SW_SHOWNORMAL = _guitest.SW_SHOWNORMAL
TCM_FIRST = _guitest.TCM_FIRST
TCM_SETCURFOCUS = _guitest.TCM_SETCURFOCUS
VK_ACCEPT = _guitest.VK_ACCEPT
VK_ADD = _guitest.VK_ADD
VK_APPS = _guitest.VK_APPS
VK_ATTN = _guitest.VK_ATTN
VK_BACK = _guitest.VK_BACK
VK_CANCEL = _guitest.VK_CANCEL
VK_CAPITAL = _guitest.VK_CAPITAL
VK_CLEAR = _guitest.VK_CLEAR
VK_CONTROL = _guitest.VK_CONTROL
VK_CONVERT = _guitest.VK_CONVERT
VK_CRSEL = _guitest.VK_CRSEL
VK_DECIMAL = _guitest.VK_DECIMAL
VK_DELETE = _guitest.VK_DELETE
VK_DIVIDE = _guitest.VK_DIVIDE
VK_DOWN = _guitest.VK_DOWN
VK_END = _guitest.VK_END
VK_EREOF = _guitest.VK_EREOF
VK_ESCAPE = _guitest.VK_ESCAPE
VK_EXECUTE = _guitest.VK_EXECUTE
VK_EXSEL = _guitest.VK_EXSEL
VK_F1 = _guitest.VK_F1
VK_F10 = _guitest.VK_F10
VK_F11 = _guitest.VK_F11
VK_F12 = _guitest.VK_F12
VK_F13 = _guitest.VK_F13
VK_F14 = _guitest.VK_F14
VK_F15 = _guitest.VK_F15
VK_F16 = _guitest.VK_F16
VK_F17 = _guitest.VK_F17
VK_F18 = _guitest.VK_F18
VK_F19 = _guitest.VK_F19
VK_F2 = _guitest.VK_F2
VK_F20 = _guitest.VK_F20
VK_F21 = _guitest.VK_F21
VK_F22 = _guitest.VK_F22
VK_F23 = _guitest.VK_F23
VK_F24 = _guitest.VK_F24
VK_F3 = _guitest.VK_F3
VK_F4 = _guitest.VK_F4
VK_F5 = _guitest.VK_F5
VK_F6 = _guitest.VK_F6
VK_F7 = _guitest.VK_F7
VK_F8 = _guitest.VK_F8
VK_F9 = _guitest.VK_F9
VK_FINAL = _guitest.VK_FINAL
VK_HANGEUL = _guitest.VK_HANGEUL
VK_HANGUL = _guitest.VK_HANGUL
VK_HANJA = _guitest.VK_HANJA
VK_HELP = _guitest.VK_HELP
VK_HOME = _guitest.VK_HOME
VK_INSERT = _guitest.VK_INSERT
VK_JUNJA = _guitest.VK_JUNJA
VK_KANA = _guitest.VK_KANA
VK_KANJI = _guitest.VK_KANJI
VK_LBUTTON = _guitest.VK_LBUTTON
VK_LCONTROL = _guitest.VK_LCONTROL
VK_LEFT = _guitest.VK_LEFT
VK_LMENU = _guitest.VK_LMENU
VK_LSHIFT = _guitest.VK_LSHIFT
VK_LWIN = _guitest.VK_LWIN
VK_MBUTTON = _guitest.VK_MBUTTON
VK_MENU = _guitest.VK_MENU
VK_MODECHANGE = _guitest.VK_MODECHANGE
VK_MULTIPLY = _guitest.VK_MULTIPLY
VK_NEXT = _guitest.VK_NEXT
VK_NONAME = _guitest.VK_NONAME
VK_NONCONVERT = _guitest.VK_NONCONVERT
VK_NUMLOCK = _guitest.VK_NUMLOCK
VK_NUMPAD0 = _guitest.VK_NUMPAD0
VK_NUMPAD1 = _guitest.VK_NUMPAD1
VK_NUMPAD2 = _guitest.VK_NUMPAD2
VK_NUMPAD3 = _guitest.VK_NUMPAD3
VK_NUMPAD4 = _guitest.VK_NUMPAD4
VK_NUMPAD5 = _guitest.VK_NUMPAD5
VK_NUMPAD6 = _guitest.VK_NUMPAD6
VK_NUMPAD7 = _guitest.VK_NUMPAD7
VK_NUMPAD8 = _guitest.VK_NUMPAD8
VK_NUMPAD9 = _guitest.VK_NUMPAD9
VK_OEM_CLEAR = _guitest.VK_OEM_CLEAR
VK_PA1 = _guitest.VK_PA1
VK_PAUSE = _guitest.VK_PAUSE
VK_PLAY = _guitest.VK_PLAY
VK_PRINT = _guitest.VK_PRINT
VK_PRIOR = _guitest.VK_PRIOR
VK_PROCESSKEY = _guitest.VK_PROCESSKEY
VK_RBUTTON = _guitest.VK_RBUTTON
VK_RCONTROL = _guitest.VK_RCONTROL
VK_RETURN = _guitest.VK_RETURN
VK_RIGHT = _guitest.VK_RIGHT
VK_RMENU = _guitest.VK_RMENU
VK_RSHIFT = _guitest.VK_RSHIFT
VK_RWIN = _guitest.VK_RWIN
VK_SCROLL = _guitest.VK_SCROLL
VK_SELECT = _guitest.VK_SELECT
VK_SEPARATOR = _guitest.VK_SEPARATOR
VK_SHIFT = _guitest.VK_SHIFT
VK_SLEEP = _guitest.VK_SLEEP
VK_SNAPSHOT = _guitest.VK_SNAPSHOT
VK_SPACE = _guitest.VK_SPACE
VK_SUBTRACT = _guitest.VK_SUBTRACT
VK_TAB = _guitest.VK_TAB
VK_UP = _guitest.VK_UP
VK_ZOOM = _guitest.VK_ZOOM
WM_COMMAND = _guitest.WM_COMMAND
WM_LBUTTONDBLCLK = _guitest.WM_LBUTTONDBLCLK
WM_LBUTTONDOWN = _guitest.WM_LBUTTONDOWN
WM_LBUTTONUP = _guitest.WM_LBUTTONUP
WM_MBUTTONDBLCLK = _guitest.WM_MBUTTONDBLCLK
WM_MBUTTONDOWN = _guitest.WM_MBUTTONDOWN
WM_MBUTTONUP = _guitest.WM_MBUTTONUP
WM_MOUSEACTIVATE = _guitest.WM_MOUSEACTIVATE
WM_MOUSEFIRST = _guitest.WM_MOUSEFIRST
WM_MOUSEMOVE = _guitest.WM_MOUSEMOVE
WM_MOUSEWHEEL = _guitest.WM_MOUSEWHEEL
WM_RBUTTONDBLCLK = _guitest.WM_RBUTTONDBLCLK
WM_RBUTTONDOWN = _guitest.WM_RBUTTONDOWN
WM_RBUTTONUP = _guitest.WM_RBUTTONUP
WM_SYSCOMMAND = _guitest.WM_SYSCOMMAND
AttachWin(HWND hwnd, BOOL fAttach) -> BOOL
CheckButton(HWND hwnd)
The names say it. Works on radio buttons and checkboxes. For regular buttons, use IsWindowEnabled.
ClientToScreen(HWND hwnd, int x, int y, int out_x, int out_y)
EnableWindow(HWND hwnd, BOOL fEnable) -> BOOL
Find the check button item specified as either a window id (HWND) or window title and then check it.
Finds the window handles of the windows matching the specified parameters and returns them as a list. The search strings may all be passed as regular expressions.
You may specify the handle of the window to search under. The routine searches through all of this windows children and their children recursively. If 'undef' then the routine searches through all windows. There is also a regexp used to match against the text in the window caption and another regexp used to match against the text in the window class. If you pass a child ID number, the functions will only match windows with this id.
GetActiveWindow(HWND hwnd) -> HWND
GetCaretPos(HWND hwnd, int out_x, int out_y)
Retrieves the caret's position, in client coordinates as (x,y) array. (Like Windows function)
GetChildDepth(HWND hAncestor, HWND hChild) -> DWORD
Using the GetParent library function in a loop, returns the distance between an ancestor window and a child (descendant) window.
Features/bugs:
If the given 'ancsetor' is not really an ancestor, the return value is the distance of child from the root window (0). If you supply the same id for both the ancestor and the child you get 1. If the ancestor you are checking is not 0 then the distance given is 1 larger than it should be.
GetChildWindows(HWND hWnd, int nelem) -> HWND
Using EnumChildWindows library function (see MSDN) it returns the WindowID of each child window. If the children have their own children the function returns them too until the tree ends.
GetClassName(HWND hwnd) -> char
Using the same Windows library function returns the name of the class wo which the specified window belongs.
See MSDN for more details.
You can also check out MSDN to see an overview of the Window Classes.
GetComboContents(HWND hWnd) -> VectorString
GetComboText(HWND hwnd, int index) -> char
GetCursorPos(int out_x, int out_y)
Retrieves the cursor's position,in screen coordinates as (x,y) array.
GetDesktopWindow() -> HWND
Returns a handle to the desktop window
GetFocus(HWND hwnd) -> HWND
GetForegroundWindow() -> HWND
GetListContents(HWND hWnd) -> VectorString
Fetch the contents of the list and combo boxes.
GetListText(HWND hwnd, int index) -> char
GetListViewContents(HWND hWnd) -> VectorString
Returns a list of the contents of the specified list view.
GetMenu(HWND hWnd) -> HMENU
Using the corresponding library function (see MSDN) it returns a MenuID number
GetMenuItemCount(HMENU hMenu) -> int
Returns the number of elements in the given menu.
GetMenuItemID(HMENU hMenu, int nPos) -> UINT
GetMenuItemIndex(HMENU hm, char sitem) -> int
First argument is a MenuId and the second is the (localized !) name of the menu including the hot key:'Rep&eat'.
Returns the index of the menu item (-1 if not found)
GetMenuItemInfo(HMENU hMenu, UINT uItem) -> VectorString
Receives a menu handler (one we got from GetMenu or GetSubMenu) and a number (which is the location of the item within the given menu).
Returns a hash of which there are currently 2 keys: type can be either 'string' or 'separator' - this is the type of the menu item text is the visible text of the menu item (provided only for 'string' type)
WARNING: This is an experimental function. Its behavior might change.
GetParent(HWND hwnd) -> HWND
A library function (see MSDN) to return the WindowID of the parent window. See MSDN for the special cases.
GetScreenRes(int out_x, int out_y)
Returns screen resolution.
GetSubMenu(HMENU hMenu, int nPos) -> HMENU
GetSystemMenu(HWND hWnd, BOOL bRevert) -> HMENU
GetTabItems(HWND hWnd) -> VectorString
Returns a list of a tab control's labels.
GetTopLevelWindows(int nelem) -> HWND
Using EnumWindows library function (see MSDN) it returns the WindowID of all the top-level window.
GetTreeViewSelPath(HWND hWnd) -> char
Returns a string containing the path (i.e., 'parent|child') of the currently selected tree view item.
oldpath = GetTreeViewSelPath(window) SelTreeViewItemPath(window, 'Parent|Child') SelTreeViewItemPath(window, oldpath);
GetWindow(HWND hwnd, UINT uCmd) -> HWND
Returns the control Id of the specified window.
GetWindowLong(HWND hwnd, int index) -> long
GetWindowRect(HWND hWnd, int left, int top, int right, int bottom)
GetWindowText(HWND hwnd) -> char
Get the text name of the window as shown on the top of it. Beware, this is text depends on localization.
GrayOutButton(HWND hwnd)
The names say it. Works on radio buttons and checkboxes. For regular buttons, use IsWindowEnabled.
IsCheckedButton(HWND hwnd) -> BOOL
The names say it. Works on radio buttons and checkboxes. For regular buttons, use IsWindowEnabled.
IsChild(HWND hWndParent, HWND hWnd) -> BOOL
Using the corresponding library function (see MSDN) it returns true if the second window is an immediate child or a descendant window of the first window.
IsGrayedButton(HWND hwnd) -> BOOL
The names say it. Works on radio buttons and checkboxes. For regular buttons, use IsWindowEnabled.
IsKeyPressed(char name) -> BOOL
Wrapper around the GetAsyncKeyState API function. Returns TRUE if the user presses the specified key.
IsKeyPressed('ESC') IsKeyPressed('A') IsKeyPressed('DOWN')
IsListViewItemSel(HWND hWnd, char lpItem) -> BOOL
Determines if the specified list view item is selected.
IsTabItemSel(HWND hWnd, char lpItem) -> BOOL
Determines if the specified tab item is selected.
IsWindow(HWND hwnd) -> BOOL
IsWindowEnabled(HWND hwnd) -> BOOL
Determines if a window has the specified style. See sample script for more details.
Determines if a window has the specified extended style.
IsWindowVisible(HWND hwnd) -> BOOL
Allows selecting a menu programmatically.
Simple Examples: # Exit foreground application through application menu. MenuSelect('&File|E&xit')
# Exit foreground application through system menu MenuSelect('&Close', 0, GetSystemMenu(GetForegroundWindow(), False))
Parameters: window (Window Handle), menu (Parent/Root Menu), items (Menu Item Path).
Returns: False on failure, True on success
Allows one to easily interact with an application through mouse emulation.
window - Regexp for a Window caption / Child caption, or just a Child ID.
parent - Handle to parent window. Default is foreground window. Use GetDesktopWindow() return value for this if clicking on an application title bar.
x_off - Offset for X axis. Default is 0.
y_off - Offset for Y axis. Default is 0.
button - {LEFT}, {MIDDLE}, {RIGHT}. Default is {LEFT}
delay - Default is 0. 0.50 = 500 ms. Delay between button down and button up.
Simple Examples:
# Click on CE button if its parent window is in foreground. MouseClick('^CE$')
# Right click on CE button if its parent window is in foreground MouseClick('^CE$', button='{RIGHT}')
# Click on 8 button window under the specified parent window; where # [PARENTHWND] will be replaced by a parent handle variable. MouseClick('8', [PARENTHWND]);
# Click on Calculator parent window itself MouseClick('Calculator', GetDesktopWindow());
MouseMoveAbsPix(int x, int y)
MouseMoveWheel(DWORD dwChange)
Positive or negative value to direct mouse wheel movement.
NormToScreen(int x, int y, int out_x, int out_y)
The opposite transformation to ScreenToNorm
PostMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) -> int
See corresponding Windows library function in MSDN.
Equivalent to PushChildButton(GetForegroundWindow(), button, delay)
Allows generating a mouse click on a particular button.
parent - the parent window of the button
button - either the text in a button (e.g.'Yes') or the control ID of a button.
delay - the time (0.25 means 250 ms) to wait between the mouse down and the mouse up event. This is useful for debugging.
ScreenToClient(HWND hwnd, int x, int y, int out_x, int out_y)
ScreenToNorm(int x, int y, int out_x, int out_y)
Returns normalised coordinates of given point (0-FFFF as a fraction of screen resolution)
SelComboItem(HWND hWnd, int iItem) -> BOOL
Selects an item in the combo box based off an index (zero-based).
SelComboItemText(HWND hWnd, char lpItem) -> BOOL
Selects an item in the combo box based off text (case insensitive).
Select tab item of window given item number and parent.
SelListViewItem(HWND hWnd, int iItem, BOOL bMulti=False) -> BOOL SelListViewItem(HWND hWnd, int iItem) -> BOOL
Selects an item in the list view based off an index (zero-based).
# Select first item, clears out any previous selections. SelListViewItem(win, 0) # Select an additional item. SelListViewItem(win, 1, 1)
SelListViewItemText(HWND hWnd, char lpItem, BOOL bMulti=False) -> BOOL SelListViewItemText(HWND hWnd, char lpItem) -> BOOL
Selects an item in the list view based off text (case insensitive).
# Select first item, clears out any previous selections. SelListViewItemText($win, 'Temp') # Select an additional item. SelListViewItemText($win, 'cabs', 1)
SelTabItem(HWND hWnd, int iItem) -> BOOL
Selects a tab based off an index (zero-based).
SelTabItemText(HWND hWnd, char lpItem) -> BOOL
Selects a tab based off text label (case insensitive).
SelTreeViewItemPath(HWND hWnd, char lpPath) -> BOOL
Selects a tree view item based off a 'path' (case insensitive).
# Select Machine item and Processors sub-item. SelTreeViewItemPath(window, 'Machine|Processors')
SelTreeViewItemPath(window, 'Item')
Sends keystrokes to the active window as if typed at the
keyboard using the optional delay between keystrokes (default is
50 ms and should be OK for most uses).
The keystrokes to send are specified in KEYS. There are several
characters that have special meaning. This allows sending control
codes and modifiers:
- ~ means ENTER
- + means SHIFT
- ^ means CTRL
- % means ALT
The parens allow character grouping. You may group several
characters, so that a specific keyboard modifier applies to all of
them. E.g. SendKeys('ABC') is equivalent to SendKeys('+(abc)').
The curly braces are used to quote special characters (SendKeys('{+}{{}')
sends a '+' and a '{'). You can also use them to specify certain
named actions:
=========== ======================
Name Action
=========== ======================
{BACKSPACE} Backspace
{BS} Backspace
{BKSP} Backspace
{BREAK} Break
{CAPS} Caps Lock
{DELETE} Delete
{DOWN} Down arrow
{END} End
{ENTER} Enter (same as ~)
{ESCAPE} Escape
{HELP} Help key
{HOME} Home
{INSERT} Insert
{LEFT} Left arrow
{NUMLOCK} Num lock
{PGDN} Page down
{PGUP} Page up
{PRTSCR} Print screen
{RIGHT} Right arrow
{SCROLL} Scroll lock
{TAB} Tab
{UP} Up arrow
{PAUSE} Pause
{F1} Function Key 1
... ...
{F24} Function Key 24
{SPC} Spacebar
{SPACE} Spacebar
{SPACEBAR} Spacebar
{LWI} Left Windows Key
{RWI} Right Windows Key
{APP} Open Context Menu Key
=========== ======================
All these named actions take an optional integer argument, like in
{RIGHT 5}. For all of them, except PAUSE, the argument means a
repeat count. For PAUSE it means the number of milliseconds SendKeys
should pause before proceding.
In this implementation, SendKeys always returns after sending the
keystrokes. There is no way to tell if an application has processed
those keys when the function returns.
SendKeysImp(char s, DWORD wait)
SendLButtonDown()
SendLButtonUp()
SendMButtonDown()
SendMButtonUp()
SendMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) -> int
This is a library function (see MSDN) used by a number of the functions provided by Win32::GuiTest. It sends the specified message to a window or windows. HWnd is the WindowID or HWND_BROADCAST to send message to all top level windows. Message is not sent to child windows. (If I understand this correctly this means it is sent to all the immediate children of the root window (0). Msg the message wParam additional parameter lParam additioanl parameter
It is most likely you won't use this directly but through one of the other functions .
This function emulates mouse input. The command parameter is a string containing one or more of the following substrings:
Note: Absolute mouse coordinates range from 0 to 65535. Relative coordinates can be positive or negative. If you need pixel coordinates you can use MouseMoveAbsPix.
Also equivalent low-level functions are available:
SendMouseMoveAbs(int x, int y)
SendMouseMoveRel(int x, int y)
SendRawKey(UINT vk, DWORD flags)
Wrapper around keybd_event. Allows sending low-level keys. The first argument is any of the VK_* constants. The second argument can be 0, KEYEVENTF_EXTENDEDKEY, KEYEVENTF_KEYUP or a combination of them.
KEYEVENTF_EXTENDEDKEY - Means it is an extended key (i.e. to distinguish between arrow keys on the numeric keypad and elsewhere).
KEYEVENTF_KEYUP - Means keyup. Unspecified means keydown.
#Example use Win32::GuiTest qw/:FUNC :VK/;
- while 1:
- SendRawKey(VK_DOWN, KEYEVENTF_EXTENDEDKEY) SendKeys('{PAUSE 200}');
SendRButtonDown()
SendRButtonUp()
SetActiveWindow(HWND hwnd) -> HWND
SetFocus(HWND hWnd) -> HWND
Sets the keyboard focus to the specified window
SetForegroundWindow(HWND hWnd) -> BOOL
See corresponding Windows functions.
ShowWindow(HWND hwnd, int nCmdShow) -> BOOL
TabCtrl_GetCurFocus(HWND hWnd) -> int
TabCtrl_GetItemCount(HWND hWnd) -> int
TabCtrl_SetCurFocus(HWND hWnd, int item)
TabCtrl_SetCurSel(HWND hWnd, int item) -> int
UnCheckButton(HWND hwnd)
The names say it. Works on radio buttons and checkboxes. For regular buttons, use IsWindowEnabled.
Minimal version of WaitWindowLike. Only requires the window title regexp. You can also specify the wait timeout in seconds.
titlere - Regexp for the window title
wait - How many seconds should we wait before giving up
Function which allows one to wait for a window to appear vs. using hard waits (e.g. sleep 2).
parent - Where to start (parent window)
titlere - Regexp for the window title
classre - Regexp for the window class name
wid - Numeric Window or Control ID
depth - How deep should we search before we stop
wait - How many seconds should we wait before giving up
WindowFromPoint(int x, int y) -> HWND
WMGetText(HWND hwnd) -> char
Sends a WM_GETTEXT to a window and returns its contents
WMSetText(HWND hwnd, char text) -> int
Sends a WM_SETTEXT to a window setting its contents
| Local name | Refers to |
|---|---|
| _guitest | _guitest |
| re | re |
| time | time |
| types | types |
© Copyright 2002-2008 Enthought, Inc.