Keyboard¶
-
class
ahk.keyboard.
AsyncKeyboardMixin
(executable_path='', directives=None, **kwargs)[source]¶ -
async
key_press
(key, release=True, blocking=True)[source]¶ Press and (optionally) release a single key
- Parameters
key –
release –
- Returns
-
async
key_wait
(key_name, timeout=None, logical_state=False, released=False)[source]¶ Wait for key to be pressed or released (default is pressed; specify
released=True
to wait for key release).https://autohotkey.com/docs/commands/KeyWait.htm
- Parameters
key_name – The name of the key
timeout (
Optional
[int
]) – how long (in seconds) to wait for the key. If not specified, waits indefinitelylogical_state – Check the logical state of the key, which is the state that the OS and the active window believe the key to be in (not necessarily the same as the physical state). This option is ignored for joystick buttons.
released – Set to True to wait for the key to be released rather than pressed
- Return type
None
- Returns
None
- Raises
TimeoutError – if the key was not pressed (or released, if specified) within timeout
-
async
-
class
ahk.keyboard.
Hotkey
(engine, hotkey, script)[source]¶ -
__init__
(engine, hotkey, script)[source]¶ - Parameters
engine (
ScriptEngine
) – anAHK
instancehotkey (
str
) – The hotkey to use (AutoHotkey syntax)script (
str
) – The script to execute when the hotkey is activated (AutoHotkey code as a string)
-
property
running
¶
-
-
class
ahk.keyboard.
KeyboardMixin
(executable_path='', directives=None, **kwargs)[source]¶ -
hotkey
(*args, **kwargs)[source]¶ Convenience function for creating
Hotkey
instance using current engine.- Parameters
hotkey – The hotkey to use (AutoHotkey syntax)
script – The script to execute when the hotkey is activated (AutoHotkey code as a string)
- Returns
an
Hotkey
instance
-
key_down
(key, blocking=True)[source]¶ Press down a key (without releasing it)
- Parameters
key –
blocking –
- Returns
-
key_press
(key, release=True, blocking=True)[source]¶ Press and (optionally) release a single key
- Parameters
key –
release –
- Returns
-
key_release
(key, blocking=True)[source]¶ Release a key that is currently in pressed down state
- Parameters
key –
- Returns
-
key_wait
(key_name, timeout=None, logical_state=False, released=False)[source]¶ Wait for key to be pressed or released (default is pressed; specify
released=True
to wait for key release).https://autohotkey.com/docs/commands/KeyWait.htm
- Parameters
key_name – The name of the key
timeout (
Optional
[int
]) – how long (in seconds) to wait for the key. If not specified, waits indefinitelylogical_state – Check the logical state of the key, which is the state that the OS and the active window believe the key to be in (not necessarily the same as the physical state). This option is ignored for joystick buttons.
released – Set to True to wait for the key to be released rather than pressed
- Return type
None
- Returns
None
- Raises
TimeoutError – if the key was not pressed (or released, if specified) within timeout
-
send
(s, raw=False, delay=None, blocking=True)[source]¶ https://autohotkey.com/docs/commands/Send.htm
- Parameters
s –
raw –
delay –
blocking – if
True
, waits until script finishes, else returns immediately.
- Returns
-
send_event
(s, delay=None)[source]¶ https://autohotkey.com/docs/commands/Send.htm
- Parameters
s –
delay –
- Returns
-
send_play
(s)[source]¶ https://autohotkey.com/docs/commands/Send.htm
- Parameters
s –
- Returns
-
send_raw
(s, delay=None)[source]¶ https://autohotkey.com/docs/commands/Send.htm
- Parameters
s –
delay –
- Returns
-
set_capslock_state
(state=None)[source]¶ https://www.autohotkey.com/docs/commands/SetNumScrollCapsLockState.htm
Sets capslock state
- Parameters
state (str) – the desired state (“on” or “off”). Can also be True/False. If omitted, toggles capslock state.
- Returns
-