winappdbg.window
Window instrumentation.
- class winappdbg.window.Window(hWnd=None, process=None, thread=None)
Interface to an open window in the current desktop.
- Variables:
hWnd – Window handle.
dwProcessId – Global ID of the process that owns this window.
dwThreadId – Global ID of the thread that owns this window.
process – Process that owns this window. Use the
get_process()method instead.thread – Thread that owns this window. Use the
get_thread()method instead.classname – Window class name.
text – Window text (caption).
placement – Window placement in the desktop.
- client_to_screen(x, y)
Translates window client coordinates to screen coordinates.
Note
This is a simplified interface to some of the functionality of the win32.Point class.
- See:
win32.Point.client_to_screen()- Parameters:
x (int) – Horizontal coordinate.
y (int) – Vertical coordinate.
- Return type:
tuple( int, int )
- Returns:
Translated coordinates in a tuple (x, y).
- Raises:
WindowsError – An error occured while processing this request.
- disable()
Disable the user input for the window.
- See:
- Raises:
WindowsError – An error occured while processing this request.
- enable()
Enable the user input for the window.
- See:
- Raises:
WindowsError – An error occured while processing this request.
- get_child_at(x, y, bAllowTransparency=True)
Get the child window located at the given coordinates. If no such window exists an exception is raised.
- See:
- Parameters:
x (int) – Horizontal coordinate.
y (int) – Vertical coordinate.
bAllowTransparency (bool) – If
Truetransparent areas in windows are ignored, returning the window behind them. IfFalsetransparent areas are treated just like any other area.
- Return type:
Window
- Returns:
Child window at the requested position, or
Noneif there is no window at those coordinates.
- get_children()
- See:
- Return type:
list( Window )
- Returns:
List of child windows.
- Raises:
WindowsError – An error occured while processing this request.
- get_classname()
- Return type:
str
- Returns:
Window class name.
- Raises:
WindowsError – An error occured while processing this request.
- get_client_rect()
Get the window’s client area coordinates in the desktop.
- Return type:
win32.Rect
- Returns:
Rectangle occupied by the window’s client area in the desktop.
- Raises:
WindowsError – An error occured while processing this request.
- get_extended_style()
- Return type:
int
- Returns:
Window extended style mask.
- Raises:
WindowsError – An error occured while processing this request.
- get_handle()
- Return type:
int
- Returns:
Window handle.
- Raises:
ValueError – No window handle set.
- get_parent()
- See:
- Return type:
Window or None
- Returns:
Parent window. Returns
Noneif the window has no parent.- Raises:
WindowsError – An error occured while processing this request.
- get_pid()
- Return type:
int
- Returns:
Global ID of the process that owns this window.
- get_placement()
Retrieve the window placement in the desktop.
- See:
- Return type:
win32.WindowPlacement
- Returns:
Window placement in the desktop.
- Raises:
WindowsError – An error occured while processing this request.
- get_process()
- Return type:
Process
- Returns:
Parent Process object.
- get_root()
- See:
- Return type:
Window
- Returns:
If this is a child window, return the top-level window it belongs to. If this window is already a top-level window, returns itself.
- Raises:
WindowsError – An error occured while processing this request.
- get_screen_rect()
Get the window coordinates in the desktop.
- Return type:
win32.Rect
- Returns:
Rectangle occupied by the window in the desktop.
- Raises:
WindowsError – An error occured while processing this request.
- get_style()
- Return type:
int
- Returns:
Window style mask.
- Raises:
WindowsError – An error occured while processing this request.
- get_text()
- See:
- Return type:
str
- Returns:
Window text (caption) on success,
Noneon error.
- get_thread()
- Return type:
Thread
- Returns:
Parent Thread object.
- get_tid()
- Return type:
int
- Returns:
Global ID of the thread that owns this window.
- get_tree()
- See:
- Return type:
dict( Window -> dict( … ) )
- Returns:
Dictionary of dictionaries forming a tree of child windows.
- Raises:
WindowsError – An error occured while processing this request.
- hide(bAsync=True)
Make the window invisible.
- See:
- Parameters:
bAsync (bool) – Perform the request asynchronously.
- Raises:
WindowsError – An error occured while processing this request.
- is_child()
- See:
- Return type:
bool
- Returns:
Trueif the window is a child window.
- is_enabled()
- is_iconic()
- See:
- Return type:
bool
- Returns:
Trueif the window is minimized.
- is_maximized()
- See:
- Return type:
bool
- Returns:
Trueif the window is maximized.
- is_minimized()
- See:
- Return type:
bool
- Returns:
Trueif the window is minimized.
- is_valid()
- Return type:
bool
- Returns:
Trueif the window handle is still valid.
- is_visible()
- is_zoomed()
- See:
- Return type:
bool
- Returns:
Trueif the window is maximized.
- kill()
Signals the program to quit.
Note
This is an asyncronous request.
- Raises:
WindowsError – An error occured while processing this request.
- maximize(bAsync=True)
Maximize the window.
- See:
- Parameters:
bAsync (bool) – Perform the request asynchronously.
- Raises:
WindowsError – An error occured while processing this request.
- minimize(bAsync=True)
Minimize the window.
- See:
- Parameters:
bAsync (bool) – Perform the request asynchronously.
- Raises:
WindowsError – An error occured while processing this request.
- move(x=None, y=None, width=None, height=None, bRepaint=True)
Moves and/or resizes the window.
Note
This is request is performed syncronously.
- Parameters:
x (int) – (Optional) New horizontal coordinate.
y (int) – (Optional) New vertical coordinate.
width (int) – (Optional) Desired window width.
height (int) – (Optional) Desired window height.
bRepaint (bool) – (Optional)
Trueif the window should be redrawn afterwards.
- Raises:
WindowsError – An error occured while processing this request.
- post(uMsg, wParam=None, lParam=None)
Post a low-level window message asyncronically.
- Parameters:
uMsg (int) – Message code.
wParam – The type and meaning of this parameter depends on the message.
lParam – The type and meaning of this parameter depends on the message.
- Raises:
WindowsError – An error occured while sending the message.
- restore(bAsync=True)
Unmaximize and unminimize the window.
- See:
- Parameters:
bAsync (bool) – Perform the request asynchronously.
- Raises:
WindowsError – An error occured while processing this request.
- screen_to_client(x, y)
Translates window screen coordinates to client coordinates.
Note
This is a simplified interface to some of the functionality of the win32.Point class.
- See:
win32.Point.screen_to_client()- Parameters:
x (int) – Horizontal coordinate.
y (int) – Vertical coordinate.
- Return type:
tuple( int, int )
- Returns:
Translated coordinates in a tuple (x, y).
- Raises:
WindowsError – An error occured while processing this request.
- send(uMsg, wParam=None, lParam=None, dwTimeout=None)
Send a low-level window message syncronically.
- Parameters:
uMsg (int) – Message code.
wParam – The type and meaning of this parameter depends on the message.
lParam – The type and meaning of this parameter depends on the message.
dwTimeout – Optional timeout for the operation. Use
Noneto wait indefinitely.
- Return type:
int
- Returns:
The meaning of the return value depends on the window message. Typically a value of
0means an error occured. You can get the error code by callingwin32.GetLastError().
- set_placement(placement)
Set the window placement in the desktop.
- See:
- Parameters:
placement (win32.WindowPlacement) – Window placement in the desktop.
- Raises:
WindowsError – An error occured while processing this request.
- set_process(process=None)
Manually set the parent process. Use with care!
- Parameters:
process (Process) – (Optional) Process object. Use
Noneto autodetect.
- set_text(text)
Set the window text (caption).
- See:
- Parameters:
text (str) – New window text.
- Raises:
WindowsError – An error occured while processing this request.
- set_thread(thread=None)
Manually set the thread process. Use with care!
- Parameters:
thread (Thread) – (Optional) Thread object. Use
Noneto autodetect.