Package winappdbg :: Module window :: Class Window
[hide private]
[frames] | no frames]

Class Window

source code


Interface to an open window in the current desktop.

Instance Methods [hide private]
 
__init__(self, hWnd=None, process=None, thread=None)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
__get_pid_and_tid(self)
Internally used by get_pid() and get_tid().
source code
 
__load_Process_class(self) source code
 
__load_Thread_class(self) source code
 
__get_window(self, hWnd)
User internally to get another Window from this one.
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

    Properties
int
get_handle(self)
Returns: Window handle.
source code
int
get_pid(self)
Returns: Global ID of the process that owns this window.
source code
int
get_tid(self)
Returns: Global ID of the thread that owns this window.
source code
Process
get_process(self)
Returns: Parent Process object.
source code
 
set_process(self, process=None)
Manually set the parent process.
source code
Thread
get_thread(self)
Returns: Parent Thread object.
source code
 
set_thread(self, thread=None)
Manually set the thread process.
source code
str
get_classname(self)
Returns: Window class name.
source code
int
get_style(self)
Returns: Window style mask.
source code
int
get_extended_style(self)
Returns: Window extended style mask.
source code
str
get_text(self)
Returns: Window text (caption) on success, None on error.
source code
 
set_text(self, text)
Set the window text (caption).
source code
win32.WindowPlacement
get_placement(self)
Retrieve the window placement in the desktop.
source code
 
set_placement(self, placement)
Set the window placement in the desktop.
source code
win32.Rect
get_screen_rect(self)
Get the window coordinates in the desktop.
source code
win32.Rect
get_client_rect(self)
Get the window's client area coordinates in the desktop.
source code
tuple( int, int )
client_to_screen(self, x, y)
Translates window client coordinates to screen coordinates.
source code
tuple( int, int )
screen_to_client(self, x, y)
Translates window screen coordinates to client coordinates.
source code
    State
bool
is_valid(self)
Returns: True if the window handle is still valid.
source code
bool
is_visible(self)
Returns: True if the window is in a visible state.
source code
bool
is_enabled(self)
Returns: True if the window is in an enabled state.
source code
bool
is_maximized(self)
Returns: True if the window is maximized.
source code
bool
is_minimized(self)
Returns: True if the window is minimized.
source code
bool
is_child(self)
Returns: True if the window is a child window.
source code
bool
is_zoomed(self)
Returns: True if the window is maximized.
source code
bool
is_iconic(self)
Returns: True if the window is minimized.
source code
    Navigation
Window or None
get_parent(self)
Returns: Parent window.
source code
list( Window )
get_children(self)
Returns: List of child windows.
source code
dict( Window → dict( ... ) )
get_tree(self)
Returns: Dictionary of dictionaries forming a tree of child windows.
source code
Window
get_root(self)
Returns: If this is a child window, return the top-level window it belongs to.
source code
Window
get_child_at(self, x, y, bAllowTransparency=True)
Get the child window located at the given coordinates.
source code
    Instrumentation
 
enable(self)
Enable the user input for the window.
source code
 
disable(self)
Disable the user input for the window.
source code
 
show(self, bAsync=True)
Make the window visible.
source code
 
hide(self, bAsync=True)
Make the window invisible.
source code
 
maximize(self, bAsync=True)
Maximize the window.
source code
 
minimize(self, bAsync=True)
Minimize the window.
source code
 
restore(self, bAsync=True)
Unmaximize and unminimize the window.
source code
 
move(self, x=None, y=None, width=None, height=None, bRepaint=True)
Moves and/or resizes the window.
source code
 
kill(self)
Signals the program to quit.
source code
    Low-level access
int
send(self, uMsg, wParam=None, lParam=None, dwTimeout=None)
Send a low-level window message syncronically.
source code
 
post(self, uMsg, wParam=None, lParam=None)
Post a low-level window message asyncronically.
source code
Instance Variables [hide private]
Process process
Process that owns this window.
Thread thread
Thread that owns this window.
str classname
Window class name.
str text
Window text (caption).
win32.WindowPlacement placement
Window placement in the desktop.
int dwProcessId
Global ID of the process that owns this window.
int dwThreadId
Global ID of the thread that owns this window.
int hWnd
Window handle.
Properties [hide private]
  _as_parameter_
Compatibility with ctypes.
  style
  exstyle

Inherited from object: __class__

Method Details [hide private]

__init__(self, hWnd=None, process=None, thread=None)
(Constructor)

source code 

x.__init__(...) initializes x; see help(type(x)) for signature

Parameters:
  • hWnd (int or win32.HWND) - Window handle.
  • process (Process) - (Optional) Process that owns this window.
  • thread (Thread) - (Optional) Thread that owns this window.
Overrides: object.__init__

get_handle(self)

source code 
Returns: int
Window handle.
Raises:
  • ValueError - No window handle set.

get_pid(self)

source code 
Returns: int
Global ID of the process that owns this window.

get_tid(self)

source code 
Returns: int
Global ID of the thread that owns this window.

get_process(self)

source code 
Returns: Process
Parent Process object.

set_process(self, process=None)

source code 

Manually set the parent process. Use with care!

Parameters:
  • process (Process) - (Optional) Process object. Use None to autodetect.

get_thread(self)

source code 
Returns: Thread
Parent Thread object.

set_thread(self, thread=None)

source code 

Manually set the thread process. Use with care!

Parameters:
  • thread (Thread) - (Optional) Thread object. Use None to autodetect.

__get_window(self, hWnd)

source code 

User internally to get another Window from this one. It'll try to copy the parent Process and Thread references if possible.

get_classname(self)

source code 
Returns: str
Window class name.
Raises:
  • WindowsError - An error occured while processing this request.

get_style(self)

source code 
Returns: int
Window style mask.
Raises:
  • WindowsError - An error occured while processing this request.

get_extended_style(self)

source code 
Returns: int
Window extended style mask.
Raises:
  • WindowsError - An error occured while processing this request.

get_text(self)

source code 
Returns: str
Window text (caption) on success, None on error.

See Also: set_text

set_text(self, text)

source code 

Set the window text (caption).

Parameters:
  • text (str) - New window text.
Raises:
  • WindowsError - An error occured while processing this request.

See Also: get_text

get_placement(self)

source code 

Retrieve the window placement in the desktop.

Returns: win32.WindowPlacement
Window placement in the desktop.
Raises:
  • WindowsError - An error occured while processing this request.

See Also: set_placement

set_placement(self, placement)

source code 

Set the window placement in the desktop.

Parameters:
Raises:
  • WindowsError - An error occured while processing this request.

See Also: get_placement

get_screen_rect(self)

source code 

Get the window coordinates in the desktop.

Returns: win32.Rect
Rectangle occupied by the window in the desktop.
Raises:
  • WindowsError - An error occured while processing this request.

get_client_rect(self)

source code 

Get the window's client area coordinates in the desktop.

Returns: win32.Rect
Rectangle occupied by the window's client area in the desktop.
Raises:
  • WindowsError - An error occured while processing this request.

client_to_screen(self, x, y)

source code 

Translates window client coordinates to screen coordinates.

Parameters:
  • x (int) - Horizontal coordinate.
  • y (int) - Vertical coordinate.
Returns: tuple( int, int )
Translated coordinates in a tuple (x, y).
Raises:
  • WindowsError - An error occured while processing this request.

Note: This is a simplified interface to some of the functionality of the win32.Point class.

See Also: {win32.Point.client_to_screen}

screen_to_client(self, x, y)

source code 

Translates window screen coordinates to client coordinates.

Parameters:
  • x (int) - Horizontal coordinate.
  • y (int) - Vertical coordinate.
Returns: tuple( int, int )
Translated coordinates in a tuple (x, y).
Raises:
  • WindowsError - An error occured while processing this request.

Note: This is a simplified interface to some of the functionality of the win32.Point class.

See Also: {win32.Point.screen_to_client}

get_parent(self)

source code 
Returns: Window or None
Parent window. Returns None if the window has no parent.
Raises:
  • WindowsError - An error occured while processing this request.

See Also: get_children

get_children(self)

source code 
Returns: list( Window )
List of child windows.
Raises:
  • WindowsError - An error occured while processing this request.

See Also: get_parent

get_tree(self)

source code 
Returns: dict( Window → dict( ... ) )
Dictionary of dictionaries forming a tree of child windows.
Raises:
  • WindowsError - An error occured while processing this request.

See Also: get_root

get_root(self)

source code 
Returns: Window
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.

See Also: get_tree

get_child_at(self, x, y, bAllowTransparency=True)

source code 

Get the child window located at the given coordinates. If no such window exists an exception is raised.

Parameters:
  • x (int) - Horizontal coordinate.
  • y (int) - Vertical coordinate.
  • bAllowTransparency (bool) - If True transparent areas in windows are ignored, returning the window behind them. If False transparent areas are treated just like any other area.
Returns: Window
Child window at the requested position, or None if there is no window at those coordinates.

See Also: get_children

is_valid(self)

source code 
Returns: bool
True if the window handle is still valid.

is_visible(self)

source code 
Returns: bool
True if the window is in a visible state.

See Also: {show}, {hide}

is_enabled(self)

source code 
Returns: bool
True if the window is in an enabled state.

See Also: {enable}, {disable}

is_maximized(self)

source code 
Returns: bool
True if the window is maximized.

See Also: maximize

is_minimized(self)

source code 
Returns: bool
True if the window is minimized.

See Also: minimize

is_child(self)

source code 
Returns: bool
True if the window is a child window.

See Also: get_parent

is_zoomed(self)

source code 
Returns: bool
True if the window is maximized.

See Also: maximize

is_iconic(self)

source code 
Returns: bool
True if the window is minimized.

See Also: minimize

enable(self)

source code 

Enable the user input for the window.

Raises:
  • WindowsError - An error occured while processing this request.

See Also: disable

disable(self)

source code 

Disable the user input for the window.

Raises:
  • WindowsError - An error occured while processing this request.

See Also: enable

show(self, bAsync=True)

source code 

Make the window visible.

Parameters:
  • bAsync (bool) - Perform the request asynchronously.
Raises:
  • WindowsError - An error occured while processing this request.

See Also: hide

hide(self, bAsync=True)

source code 

Make the window invisible.

Parameters:
  • bAsync (bool) - Perform the request asynchronously.
Raises:
  • WindowsError - An error occured while processing this request.

See Also: show

maximize(self, bAsync=True)

source code 

Maximize the window.

Parameters:
  • bAsync (bool) - Perform the request asynchronously.
Raises:
  • WindowsError - An error occured while processing this request.

See Also: minimize, restore

minimize(self, bAsync=True)

source code 

Minimize the window.

Parameters:
  • bAsync (bool) - Perform the request asynchronously.
Raises:
  • WindowsError - An error occured while processing this request.

See Also: maximize, restore

restore(self, bAsync=True)

source code 

Unmaximize and unminimize the window.

Parameters:
  • bAsync (bool) - Perform the request asynchronously.
Raises:
  • WindowsError - An error occured while processing this request.

See Also: maximize, minimize

move(self, x=None, y=None, width=None, height=None, bRepaint=True)

source code 

Moves and/or resizes the window.

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) True if the window should be redrawn afterwards.
Raises:
  • WindowsError - An error occured while processing this request.

Note: This is request is performed syncronously.

kill(self)

source code 

Signals the program to quit.

Raises:
  • WindowsError - An error occured while processing this request.

Note: This is an asyncronous request.

send(self, uMsg, wParam=None, lParam=None, dwTimeout=None)

source code 

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 None to wait indefinitely.
Returns: int
The meaning of the return value depends on the window message. Typically a value of 0 means an error occured. You can get the error code by calling win32.GetLastError.

post(self, uMsg, wParam=None, lParam=None)

source code 

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.

Instance Variable Details [hide private]

process

Process that owns this window. Use the get_process method instead.
Get Method:
get_process(self) - Returns: Parent Process object.
Set Method:
set_process(self, process=None) - Manually set the parent process.

thread

Thread that owns this window. Use the get_thread method instead.
Get Method:
get_thread(self) - Returns: Parent Thread object.
Set Method:
set_thread(self, thread=None) - Manually set the thread process.

classname

Window class name.
Get Method:
get_classname(self) - Returns: Window class name.

text

Window text (caption).
Get Method:
get_text(self) - Returns: Window text (caption) on success, None on error.
Set Method:
set_text(self, text) - Set the window text (caption).

placement

Window placement in the desktop.
Get Method:
get_placement(self) - Retrieve the window placement in the desktop.
Set Method:
set_placement(self, placement) - Set the window placement in the desktop.

Property Details [hide private]

_as_parameter_

Compatibility with ctypes. Allows passing transparently a Window object to an API call.

Get Method:
unreachable._as_parameter_(self) - Compatibility with ctypes.

style

Get Method:
get_style(self) - Returns: Window style mask.

exstyle

Get Method:
get_extended_style(self) - Returns: Window extended style mask.