Window

class ahk.window.AsyncWindow(engine, ahk_id, encoding=None)[source]
property always_on_top
Return type

bool

async classmethod from_mouse_position(engine, **kwargs)[source]
async classmethod from_pid(engine, pid, **kwargs)[source]
async get_pos(info=None)[source]
Returns

async get_transparency()[source]
Return type

int

property height
async is_always_on_top()[source]
async is_maximized()[source]
async is_minimized()[source]
async is_minmax()[source]
property non_max_non_min
property position
property rect
async set_transparency(value)[source]
property title
property transparent
Return type

int

property width
class ahk.window.AsyncWindowMixin(*args, **kwargs)[source]
property active_window
async find_window(func=None, **kwargs)[source]

Like find_windows but only returns the first found window

Parameters
  • func

  • kwargs

Returns

a Window object or None if no matching window is found

async find_window_by_class(*args, **kwargs)[source]
Parameters
  • args

  • kwargs

Returns

a Window object or None if no matching window is found

async find_window_by_text(*args, **kwargs)[source]
Parameters
  • args

  • kwargs

Returns

a Window object or None if no matching window is found

async find_window_by_title(title)[source]

Like find_windows_by_title but only returns the first result.

Returns

a Window object or None if no matching window is found

find_windows(func=None, **kwargs)[source]

Find all matching windows

Parameters
  • func – a callable to filter windows

  • exact (bool) – if False (the default) partial matches are found. If True, only exact matches are returned

  • kwargs – keywords of attributes of the window (has no effect if func is provided)

Returns

a generator containing any matching Window objects.

find_windows_by_class(class_name, exact=False)[source]
Parameters
  • class_name

  • exact

Returns

a generator containing any matching Window objects.

find_windows_by_text(text, exact=False)[source]
Parameters
  • text

  • exact

Returns

a generator containing any matching Window objects.

find_windows_by_title(title, exact=False)[source]

Equivalent to find_windows(title=title)`

Note that title is a bytes object

Parameters
  • title (bytes) –

  • exact

Returns

async win_get(*args, **kwargs)[source]
async windows()[source]

Returns a list of windows

Returns

class ahk.window.Control[source]
__init__()[source]

Initialize self. See help(type(self)) for accurate signature.

click()[source]

REF: https://www.autohotkey.com/docs/commands/ControlClick.htm

Returns

focus()[source]

REF: https://www.autohotkey.com/docs/commands/ControlFocus.htm

Returns

get(key)[source]

REF: https://www.autohotkey.com/docs/commands/ControlGet.htm

Parameters

key

Returns

has_focus()[source]
move()[source]

REF: https://www.autohotkey.com/docs/commands/ControlMove.htm

Returns

property position

REF: https://www.autohotkey.com/docs/commands/ControlGetPos.htm

Returns

send(raw=False)[source]

REF: https://www.autohotkey.com/docs/commands/ControlSend.htm

Parameters

raw

Returns

property text

REF: https://www.autohotkey.com/docs/commands/ControlGetText.htm

Returns

class ahk.window.Window(engine, ahk_id, encoding=None)[source]
MAXIMIZED = '1'
MINIMIZED = '-1'
NON_MIN_NON_MAX = '0'
__init__(engine, ahk_id, encoding=None)[source]

Initialize self. See help(type(self)) for accurate signature.

activate()[source]

Activate the window.

See also: WinActivate

Returns

activate_bottom()[source]

Calls WinActivateBottom on the window

Returns

property active
property always_on_top
Return type

bool

property class_name
click(*args, **kwargs)[source]

Click at an x/y location on the screen. Uses ControlClick https://autohotkey.com/docs/commands/ControlClick.htm

x/y position params may also be specified as a 2-item sequence

Parameters
  • x – x offset relative to topleft corner of the window

  • y – y offset relative to the top of the window

  • button – the button to press (default is left mouse)

  • n – number of times to click

  • options – per ControlClick documentation

  • blocking

Returns

close(seconds_to_wait='')[source]

Closes the Window. See also: WinClose

Parameters

seconds_to_wait

Returns

disable()[source]

Distable the window

Returns

enable()[source]

Enable the window

Returns

property exist
exists()[source]
classmethod from_mouse_position(engine, **kwargs)[source]
classmethod from_pid(engine, pid, **kwargs)[source]
get(subcommand)[source]
get_class_name()[source]
get_pos(info=None)[source]
Returns

get_text()[source]
get_title()[source]
get_transparency()[source]
Return type

int

property height
hide()[source]

Hides the window. See also: WinHide

Returns

is_active()[source]
is_always_on_top()[source]
Return type

bool

is_maximized()[source]
is_minimized()[source]
is_minmax()[source]
kill(seconds_to_wait='')[source]
maximize()[source]

maximize the window

Returns

property maximized
minimize()[source]

minimize the window

Returns

property minimized
move(x='', y='', width=None, height=None)[source]

Move the window to a position and/or change its geometry

Parameters
  • x

  • y

  • width

  • height

Returns

property non_max_non_min
property position
property rect
redraw()[source]
restore()[source]

restore the window

Returns

send(keys, delay=10, raw=False, blocking=False, escape=False, press_duration=-1)[source]

Send keystrokes directly to the window. Uses ControlSend https://autohotkey.com/docs/commands/Send.htm

set(subcommand, value)[source]
set_always_on_top(value)[source]
set_position(new_position)[source]
set_title(value)[source]
set_transparency(value)[source]
show()[source]

show the window

Returns

property text
property title
to_bottom()[source]

Send window to bottom (behind other windows) :return:

to_top()[source]

Bring the window to the foreground (above other windows)

Returns

property transparent
Return type

int

wait(seconds_to_wait='')[source]
Parameters

seconds_to_wait

Returns

wait_active(seconds_to_wait='')[source]
Parameters

seconds_to_wait

Returns

wait_close(seconds_to_wait='')[source]
Parameters

seconds_to_wait

Returns

wait_not_active(seconds_to_wait='')[source]
Parameters

seconds_to_wait

Returns

property width
class ahk.window.WindowMixin(*args, **kwargs)[source]
__init__(*args, **kwargs)[source]

This class is typically not used directly. AHK components inherit from this class and the arguments for this class should usually be passed in to AHK.

Parameters
  • executable_path

    the path to the AHK executable. If not provided explicitly in this argument, the path to the AHK executable is resolved in the following order:

    If environment variable not present, tries to look for ‘AutoHotkey.exe’ or ‘AutoHotkeyA32.exe’ with shutil.which

  • directives – a set of directives to apply to all generated AHK scripts

Raises

ExecutableNotFound – if AHK executable cannot be found or the specified file does not exist

property active_window
find_window(func=None, **kwargs)[source]

Like find_windows but only returns the first found window

Parameters
  • func

  • kwargs

Returns

a Window object or None if no matching window is found

find_window_by_class(*args, **kwargs)[source]
Parameters
  • args

  • kwargs

Returns

a Window object or None if no matching window is found

find_window_by_text(*args, **kwargs)[source]
Parameters
  • args

  • kwargs

Returns

a Window object or None if no matching window is found

find_window_by_title(*args, **kwargs)[source]

Like find_windows_by_title but only returns the first result.

Returns

a Window object or None if no matching window is found

find_windows(func=None, **kwargs)[source]

Find all matching windows

Parameters
  • func – a callable to filter windows

  • exact (bool) – if False (the default) partial matches are found. If True, only exact matches are returned

  • kwargs – keywords of attributes of the window (has no effect if func is provided)

Returns

a generator containing any matching Window objects.

find_windows_by_class(class_name, exact=False)[source]
Parameters
  • class_name

  • exact

Returns

a generator containing any matching Window objects.

find_windows_by_text(text, exact=False)[source]
Parameters
  • text

  • exact

Returns

a generator containing any matching Window objects.

find_windows_by_title(title, exact=False)[source]

Equivalent to find_windows(title=title)`

Note that title is a bytes object

Parameters
  • title (bytes) –

  • exact

Returns

get_active_window()[source]
win_get(title='', text='', exclude_title='', exclude_text='', encoding=None)[source]
win_set(subcommand, *args, blocking=True)[source]
windows()[source]

Returns a list of windows

Returns

exception ahk.window.WindowNotFoundError[source]