• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

spyoungtech / ahk / 5501596615

pending completion
5501596615

push

github

spyoungtech
document directives for hotkeys process

4490 of 5980 relevant lines covered (75.08%)

3.0 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

66.81
/ahk/_async/engine.py
1
from __future__ import annotations
4✔
2

3
import asyncio
4✔
4
import os
4✔
5
import sys
4✔
6
import tempfile
4✔
7
import time
4✔
8
import warnings
4✔
9
from typing import Any
4✔
10
from typing import Awaitable
4✔
11
from typing import Callable
4✔
12
from typing import Coroutine
4✔
13
from typing import List
4✔
14
from typing import Literal
4✔
15
from typing import NoReturn
4✔
16
from typing import Optional
4✔
17
from typing import overload
4✔
18
from typing import Tuple
4✔
19
from typing import Type
4✔
20
from typing import Union
4✔
21

22
from .._hotkey import Hotkey
4✔
23
from .._hotkey import Hotstring
4✔
24
from .._utils import type_escape
4✔
25
from ..directives import Directive
4✔
26

27
if sys.version_info < (3, 10):
4✔
28
    from typing_extensions import TypeAlias
2✔
29
else:
30
    from typing import TypeAlias
2✔
31

32
from ..keys import Key
4✔
33
from .transport import AsyncDaemonProcessTransport
4✔
34
from .transport import AsyncFutureResult
4✔
35
from .transport import AsyncTransport
4✔
36
from .window import AsyncControl
4✔
37
from .window import AsyncWindow
4✔
38
from ahk.message import Position
4✔
39

40
async_sleep = asyncio.sleep  # unasync: remove
4✔
41
sleep = time.sleep
4✔
42

43
AsyncFilterFunc: TypeAlias = Callable[[AsyncWindow], Awaitable[bool]]  # unasync: remove
4✔
44
SyncFilterFunc: TypeAlias = Callable[[AsyncWindow], bool]
4✔
45

46
CoordModeTargets: TypeAlias = Union[
4✔
47
    Literal['ToolTip'], Literal['Pixel'], Literal['Mouse'], Literal['Caret'], Literal['Menu']
48
]
49
CoordModeRelativeTo: TypeAlias = Union[Literal['Screen', 'Relative', 'Window', 'Client', '']]
4✔
50

51
CoordMode: TypeAlias = Union[CoordModeTargets, Tuple[CoordModeTargets, CoordModeRelativeTo]]
4✔
52

53
MatchModes: TypeAlias = Literal[1, 2, 3, 'RegEx', '']
4✔
54
MatchSpeeds: TypeAlias = Literal['Fast', 'Slow', '']
4✔
55

56
TitleMatchMode: TypeAlias = Optional[
4✔
57
    Union[MatchModes, MatchSpeeds, Tuple[Union[MatchModes, MatchSpeeds], Union[MatchSpeeds, MatchModes]]]
58
]
59

60
_BUTTONS: dict[Union[str, int], str] = {
4✔
61
    1: 'L',
62
    2: 'R',
63
    3: 'M',
64
    'left': 'L',
65
    'right': 'R',
66
    'middle': 'M',
67
    'wheelup': 'WU',
68
    'wheeldown': 'WD',
69
    'wheelleft': 'WL',
70
    'wheelright': 'WR',
71
}
72

73
MouseButton: TypeAlias = Union[
4✔
74
    int,
75
    Literal[
76
        'L',
77
        'R',
78
        'M',
79
        'left',
80
        'right',
81
        'middle',
82
        'wheelup',
83
        'WU',
84
        'wheeldown',
85
        'WD',
86
        'wheelleft',
87
        'WL',
88
        'wheelright',
89
        'WR',
90
    ],
91
]
92

93
AsyncPropertyReturnTupleIntInt: TypeAlias = Coroutine[None, None, Tuple[int, int]]  # unasync: remove
4✔
94
SyncPropertyReturnTupleIntInt: TypeAlias = Tuple[int, int]
4✔
95

96
AsyncPropertyReturnOptionalAsyncWindow: TypeAlias = Coroutine[None, None, Optional[AsyncWindow]]  # unasync: remove
4✔
97
SyncPropertyReturnOptionalAsyncWindow: TypeAlias = Optional[AsyncWindow]
4✔
98

99
_PROPERTY_DEPRECATION_WARNING_MESSAGE = 'Use of the {0} property is not recommended (in the async API only) and may be removed in a future version. Use the get_{0} method instead'
4✔
100

101

102
def _resolve_button(button: Union[str, int]) -> str:
4✔
103
    """
104
    Resolve a string of a button name to a canonical name used for AHK script
105
    :param button:
106
    :type button: str
107
    :return:
108
    """
109
    if isinstance(button, str):
×
110
        button = button.lower()
×
111

112
    if button in _BUTTONS:
×
113
        resolved_button = _BUTTONS[button]
×
114
    elif isinstance(button, int) and button > 3:
×
115
        #  for addtional mouse buttons
116
        resolved_button = f'X{button-3}'
×
117
    else:
118
        assert isinstance(button, str)
×
119
        resolved_button = button
×
120
    return resolved_button
×
121

122

123
class AsyncAHK:
4✔
124
    def __init__(
4✔
125
        self,
126
        *,
127
        TransportClass: Optional[Type[AsyncTransport]] = None,
128
        directives: Optional[list[Directive | Type[Directive]]] = None,
129
        executable_path: str = '',
130
    ):
131
        if TransportClass is None:
4✔
132
            TransportClass = AsyncDaemonProcessTransport
4✔
133
        assert TransportClass is not None
4✔
134
        transport = TransportClass(executable_path=executable_path, directives=directives)
4✔
135
        self._transport: AsyncTransport = transport
4✔
136

137
    def add_hotkey(
4✔
138
        self, keyname: str, callback: Callable[[], Any], ex_handler: Optional[Callable[[str, Exception], Any]] = None
139
    ) -> None:
140
        """
141
        Register a function to be called when a hotkey is pressed.
142

143
        Key notes:
144

145
        - You must call the `start_hotkeys` method for the hotkeys to be active
146
        - All hotkeys run in a single AHK process instance (but Python callbacks also get their own thread and can run simultaneously)
147
        - If you add a hotkey after the hotkey thread/instance is active, it will be restarted automatically
148
        - `async` functions are not directly supported as callbacks, however you may write a synchronous function that calls `asyncio.run`/`loop.create_task` etc.
149

150
        :param keyname: the key trigger for the hotkey, such as ``#n`` (win+n)
151
        :param callback: callback function to call when the hotkey is triggered
152
        :param ex_handler: a function which accepts two parameters: the keyname for the hotkey and the exception raised by the callback function.
153
        :return:
154
        """
155
        hotkey = Hotkey(keyname, callback, ex_handler=ex_handler)
4✔
156
        with warnings.catch_warnings(record=True) as caught_warnings:
4✔
157
            self._transport.add_hotkey(hotkey=hotkey)
4✔
158
        if caught_warnings:
4✔
159
            for warning in caught_warnings:
×
160
                warnings.warn(warning.message, warning.category, stacklevel=2)
×
161
        return None
4✔
162

163
    def add_hotstring(
4✔
164
        self,
165
        trigger: str,
166
        replacement_or_callback: Union[str, Callable[[], Any]],
167
        ex_handler: Optional[Callable[[str, Exception], Any]] = None,
168
        options: str = '',
169
    ) -> None:
170
        """
171
        Register a hotstring, e.g., `::btw::by the way`
172

173
        Key notes:
174

175
        - You must call the `start_hotkeys` method for registered hotstrings to be active
176
        - All hotstrings (and hotkeys) run in a single AHK process instance separate from other AHK processes.
177

178
        :param trigger: the trigger phrase for the hotstring, e.g., ``btw``
179
        :param replacement_or_callback: the replacement phrase (e.g., ``by the way``) or a Python callable to execute in response to the hotstring trigger
180
        :param ex_handler: a function which accepts two parameters: the hotstring and the exception raised by the callback function.
181
        :param options: the hotstring options -- same meanings as in AutoHotkey.
182
        :return:
183
        """
184
        hotstring = Hotstring(trigger, replacement_or_callback, ex_handler=ex_handler, options=options)
4✔
185
        with warnings.catch_warnings(record=True) as caught_warnings:
4✔
186
            self._transport.add_hotstring(hotstring=hotstring)
4✔
187
        if caught_warnings:
4✔
188
            for warning in caught_warnings:
×
189
                warnings.warn(warning.message, warning.category, stacklevel=2)
×
190
        return None
4✔
191

192
    def remove_hotkey(self, keyname: str) -> None:
4✔
193
        def _() -> None:
4✔
194
            return None
×
195

196
        h = Hotkey(keyname=keyname, callback=_)  # XXX: this can probably be avoided
4✔
197
        self._transport.remove_hotkey(hotkey=h)
4✔
198
        return None
4✔
199

200
    def clear_hotkeys(self) -> None:
4✔
201
        self._transport.clear_hotkeys()
4✔
202
        return None
4✔
203

204
    def remove_hotstring(self, trigger: str) -> None:
4✔
205
        hs = Hotstring(trigger=trigger, replacement_or_callback='')  # XXX: this can probably be avoided
4✔
206
        self._transport.remove_hotstring(hs)
4✔
207
        return None
4✔
208

209
    def clear_hotstrings(self) -> None:
4✔
210
        self._transport.clear_hotstrings()
4✔
211
        return None
4✔
212

213
    async def set_title_match_mode(self, title_match_mode: TitleMatchMode, /) -> None:
4✔
214
        """
215
        Sets the default title match mode
216

217
        Does not affect methods called with ``blocking=True`` (because these run in a separate AHK process)
218

219
        Reference: https://www.autohotkey.com/docs/commands/SetTitleMatchMode.htm
220

221
        :param title_match_mode: the match mode (and/or match speed) to set as the default title match mode. Can be 1, 2, 3, 'Regex', 'Fast', 'Slow' or a tuple of these.
222
        :return: None
223
        """
224

225
        args = []
4✔
226
        if isinstance(title_match_mode, tuple):
4✔
227
            (match_mode, match_speed) = title_match_mode
4✔
228
        elif title_match_mode in (1, 2, 3, 'RegEx'):
4✔
229
            match_mode = title_match_mode
4✔
230
            match_speed = ''
4✔
231
        elif title_match_mode in ('Fast', 'Slow'):
4✔
232
            match_mode = ''
4✔
233
            match_speed = title_match_mode
4✔
234
        else:
235
            raise ValueError(
×
236
                f"Invalid value for title_match_mode argument. Expected 1, 2, 3, 'RegEx', 'Fast', 'Slow' or a tuple of these. Got {title_match_mode!r}"
237
            )
238
        args.append(str(match_mode))
4✔
239
        args.append(str(match_speed))
4✔
240
        await self._transport.function_call('AHKSetTitleMatchMode', args)
4✔
241
        return None
4✔
242

243
    async def get_title_match_mode(self) -> str:
4✔
244
        """
245
        Get the title match mode.
246

247
        I.E. the current value of ``A_TitleMatchMode``
248

249
        """
250
        resp = await self._transport.function_call('AHKGetTitleMatchMode')
4✔
251
        return resp
4✔
252

253
    async def get_title_match_speed(self) -> str:
4✔
254
        """
255
        Get the title match mode speed.
256

257
        I.E. the current value of ``A_TitleMatchModeSpeed``
258

259
        """
260
        resp = await self._transport.function_call('AHKGetTitleMatchSpeed')
4✔
261
        return resp
4✔
262

263
    async def set_coord_mode(self, target: CoordModeTargets, relative_to: CoordModeRelativeTo = 'Screen') -> None:
4✔
264
        """
265
        Analog of `CoordMode <https://www.autohotkey.com/docs/commands/CoordMode.htm>`_
266
        """
267
        args = [str(target), str(relative_to)]
×
268
        await self._transport.function_call('AHKSetCoordMode', args)
×
269
        return None
×
270

271
    async def get_coord_mode(self, target: CoordModeTargets) -> str:
4✔
272
        """
273
        Analog for ``A_CoordMode<target>``
274
        """
275
        args = [str(target)]
×
276
        resp = await self._transport.function_call('AHKGetCoordMode', args)
×
277
        return resp
×
278

279
    # fmt: off
280
    @overload
4✔
281
    async def control_click(self, button: Literal['L', 'R', 'M', 'LEFT', 'RIGHT', 'MIDDLE'] = 'L', click_count: int = 1, options: str = '', control: str = '', title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None) -> None: ...
4✔
282
    @overload
4✔
283
    async def control_click(self, button: Literal['L', 'R', 'M', 'LEFT', 'RIGHT', 'MIDDLE'] = 'L', click_count: int = 1, options: str = '', control: str = '', title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: Literal[False]) -> AsyncFutureResult[None]: ...
4✔
284
    @overload
4✔
285
    async def control_click(self, button: Literal['L', 'R', 'M', 'LEFT', 'RIGHT', 'MIDDLE'] = 'L', click_count: int = 1, options: str = '', control: str = '', title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: Literal[True]) -> None: ...
4✔
286
    @overload
4✔
287
    async def control_click(self, button: Literal['L', 'R', 'M', 'LEFT', 'RIGHT', 'MIDDLE'] = 'L', click_count: int = 1, options: str = '', control: str = '', title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: bool = True) -> Union[None, AsyncFutureResult[None]]: ...
4✔
288
    # fmt: on
289
    async def control_click(
4✔
290
        self,
291
        button: Literal['L', 'R', 'M', 'LEFT', 'RIGHT', 'MIDDLE'] = 'L',
292
        click_count: int = 1,
293
        options: str = '',
294
        control: str = '',
295
        title: str = '',
296
        text: str = '',
297
        exclude_title: str = '',
298
        exclude_text: str = '',
299
        *,
300
        title_match_mode: Optional[TitleMatchMode] = None,
301
        detect_hidden_windows: Optional[bool] = None,
302
        blocking: bool = True,
303
    ) -> Union[None, AsyncFutureResult[None]]:
304
        """
305
        Analog for `ControlClick <https://www.autohotkey.com/docs/commands/ControlClick.htm>`_
306
        """
307
        args = [control, title, text, str(button), str(click_count), options, exclude_title, exclude_text]
×
308
        if detect_hidden_windows is not None:
×
309
            if detect_hidden_windows is True:
×
310
                args.append('On')
×
311
            elif detect_hidden_windows is False:
×
312
                args.append('Off')
×
313
            else:
314
                raise TypeError(
×
315
                    f'Invalid value for parameter detect_hidden_windows. Expected boolean or None, got {detect_hidden_windows!r}'
316
                )
317
        else:
318
            args.append('')
×
319
        if title_match_mode is not None:
×
320
            if isinstance(title_match_mode, tuple):
×
321
                match_mode, match_speed = title_match_mode
×
322
            elif title_match_mode in (1, 2, 3, 'RegEx'):
×
323
                match_mode = title_match_mode
×
324
                match_speed = ''
×
325
            elif title_match_mode in ('Fast', 'Slow'):
×
326
                match_mode = ''
×
327
                match_speed = title_match_mode
×
328
            else:
329
                raise ValueError(
×
330
                    f"Invalid value for title_match_mode argument. Expected 1, 2, 3, 'RegEx', 'Fast', 'Slow' or a tuple of these. Got {title_match_mode!r}"
331
                )
332
            args.append(str(match_mode))
×
333
            args.append(str(match_speed))
×
334
        else:
335
            args.append('')
×
336
            args.append('')
×
337
        resp = await self._transport.function_call('AHKControlClick', args=args, blocking=blocking)
×
338

339
        return resp
×
340

341
    # fmt: off
342
    @overload
4✔
343
    async def control_get_text(self, *, control: str = '', title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None) -> str: ...
4✔
344
    @overload
4✔
345
    async def control_get_text(self, *, control: str = '', title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: Literal[False]) -> AsyncFutureResult[str]: ...
4✔
346
    @overload
4✔
347
    async def control_get_text(self, *, control: str = '', title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: Literal[True]) -> str: ...
4✔
348
    @overload
4✔
349
    async def control_get_text(self, *, control: str = '', title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: bool = True) -> Union[str, AsyncFutureResult[str]]: ...
4✔
350
    # fmt: on
351
    async def control_get_text(
4✔
352
        self,
353
        *,
354
        control: str = '',
355
        title: str = '',
356
        text: str = '',
357
        exclude_title: str = '',
358
        exclude_text: str = '',
359
        title_match_mode: Optional[TitleMatchMode] = None,
360
        detect_hidden_windows: Optional[bool] = None,
361
        blocking: bool = True,
362
    ) -> Union[str, AsyncFutureResult[str]]:
363
        """
364
        Analog for `ControlGetText <https://www.autohotkey.com/docs/commands/ControlGetText.htm>`_
365
        """
366
        args = [control, title, text, exclude_title, exclude_text]
×
367
        if detect_hidden_windows is not None:
×
368
            if detect_hidden_windows is True:
×
369
                args.append('On')
×
370
            elif detect_hidden_windows is False:
×
371
                args.append('Off')
×
372
            else:
373
                raise TypeError(
×
374
                    f'Invalid value for parameter detect_hidden_windows. Expected boolean or None, got {detect_hidden_windows!r}'
375
                )
376
        else:
377
            args.append('')
×
378
        if title_match_mode is not None:
×
379
            if isinstance(title_match_mode, tuple):
×
380
                match_mode, match_speed = title_match_mode
×
381
            elif title_match_mode in (1, 2, 3, 'RegEx'):
×
382
                match_mode = title_match_mode
×
383
                match_speed = ''
×
384
            elif title_match_mode in ('Fast', 'Slow'):
×
385
                match_mode = ''
×
386
                match_speed = title_match_mode
×
387
            else:
388
                raise ValueError(
×
389
                    f"Invalid value for title_match_mode argument. Expected 1, 2, 3, 'RegEx', 'Fast', 'Slow' or a tuple of these. Got {title_match_mode!r}"
390
                )
391
            args.append(str(match_mode))
×
392
            args.append(str(match_speed))
×
393
        else:
394
            args.append('')
×
395
            args.append('')
×
396
        resp = await self._transport.function_call('AHKControlGetText', args, blocking=blocking)
×
397
        return resp
×
398

399
    # fmt: off
400
    @overload
4✔
401
    async def control_get_position(self, control: str = '', title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None) -> Position: ...
4✔
402
    @overload
4✔
403
    async def control_get_position(self, control: str = '', title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: Literal[False]) -> AsyncFutureResult[Position]: ...
4✔
404
    @overload
4✔
405
    async def control_get_position(self, control: str = '', title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: Literal[True]) -> Position: ...
4✔
406
    @overload
4✔
407
    async def control_get_position(self, control: str = '', title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: bool = True) -> Union[Position, AsyncFutureResult[Position]]: ...
4✔
408
    # fmt: on
409
    async def control_get_position(
4✔
410
        self,
411
        control: str = '',
412
        title: str = '',
413
        text: str = '',
414
        exclude_title: str = '',
415
        exclude_text: str = '',
416
        *,
417
        title_match_mode: Optional[TitleMatchMode] = None,
418
        detect_hidden_windows: Optional[bool] = None,
419
        blocking: bool = True,
420
    ) -> Union[Position, AsyncFutureResult[Position]]:
421
        """
422
        Analog to `ControlGetPos <https://www.autohotkey.com/docs/commands/ControlGetPos.htm>`_
423
        """
424
        args = [control, title, text, exclude_title, exclude_text]
4✔
425
        if detect_hidden_windows is not None:
4✔
426
            if detect_hidden_windows is True:
4✔
427
                args.append('On')
4✔
428
            elif detect_hidden_windows is False:
×
429
                args.append('Off')
×
430
            else:
431
                raise TypeError(
×
432
                    f'Invalid value for parameter detect_hidden_windows. Expected boolean or None, got {detect_hidden_windows!r}'
433
                )
434
        else:
435
            args.append('')
×
436
        if title_match_mode is not None:
4✔
437
            if isinstance(title_match_mode, tuple):
4✔
438
                match_mode, match_speed = title_match_mode
4✔
439
            elif title_match_mode in (1, 2, 3, 'RegEx'):
×
440
                match_mode = title_match_mode
×
441
                match_speed = ''
×
442
            elif title_match_mode in ('Fast', 'Slow'):
×
443
                match_mode = ''
×
444
                match_speed = title_match_mode
×
445
            else:
446
                raise ValueError(
×
447
                    f"Invalid value for title_match_mode argument. Expected 1, 2, 3, 'RegEx', 'Fast', 'Slow' or a tuple of these. Got {title_match_mode!r}"
448
                )
449
            args.append(str(match_mode))
4✔
450
            args.append(str(match_speed))
4✔
451
        else:
452
            args.append('')
×
453
            args.append('')
×
454

455
        resp = await self._transport.function_call('AHKControlGetPos', args, blocking=blocking)
4✔
456
        return resp
4✔
457

458
    # fmt: off
459
    @overload
4✔
460
    async def control_send(self, keys: str, control: str = '', title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None) -> None: ...
4✔
461
    @overload
4✔
462
    async def control_send(self, keys: str, control: str = '', title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: Literal[False]) -> AsyncFutureResult[None]: ...
4✔
463
    @overload
4✔
464
    async def control_send(self, keys: str, control: str = '', title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: Literal[True]) -> None: ...
4✔
465
    @overload
4✔
466
    async def control_send(self, keys: str, control: str = '', title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: bool = True) -> Union[None, AsyncFutureResult[None]]: ...
4✔
467
    # fmt: on
468
    async def control_send(
4✔
469
        self,
470
        keys: str,
471
        control: str = '',
472
        title: str = '',
473
        text: str = '',
474
        exclude_title: str = '',
475
        exclude_text: str = '',
476
        *,
477
        title_match_mode: Optional[TitleMatchMode] = None,
478
        detect_hidden_windows: Optional[bool] = None,
479
        blocking: bool = True,
480
    ) -> Union[None, AsyncFutureResult[None]]:
481
        """
482
        Analog for `ControlSend <https://www.autohotkey.com/docs/commands/ControlSend.htm>`_
483
        """
484
        args = [control, keys, title, text, exclude_title, exclude_text]
4✔
485
        if detect_hidden_windows is not None:
4✔
486
            if detect_hidden_windows is True:
4✔
487
                args.append('On')
4✔
488
            elif detect_hidden_windows is False:
×
489
                args.append('Off')
×
490
            else:
491
                raise TypeError(
×
492
                    f'Invalid value for parameter detect_hidden_windows. Expected boolean or None, got {detect_hidden_windows!r}'
493
                )
494
        else:
495
            args.append('')
×
496
        if title_match_mode is not None:
4✔
497
            if isinstance(title_match_mode, tuple):
4✔
498
                match_mode, match_speed = title_match_mode
4✔
499
            elif title_match_mode in (1, 2, 3, 'RegEx'):
×
500
                match_mode = title_match_mode
×
501
                match_speed = ''
×
502
            elif title_match_mode in ('Fast', 'Slow'):
×
503
                match_mode = ''
×
504
                match_speed = title_match_mode
×
505
            else:
506
                raise ValueError(
×
507
                    f"Invalid value for title_match_mode argument. Expected 1, 2, 3, 'RegEx', 'Fast', 'Slow' or a tuple of these. Got {title_match_mode!r}"
508
                )
509
            args.append(str(match_mode))
4✔
510
            args.append(str(match_speed))
4✔
511
        else:
512
            args.append('')
×
513
            args.append('')
×
514
        resp = await self._transport.function_call('AHKControlSend', args, blocking=blocking)
4✔
515
        return resp
4✔
516

517
    # TODO: raw option for control_send
518

519
    def start_hotkeys(self) -> None:
4✔
520
        """
521
        Start the Autohotkey process for triggering hotkeys
522

523
        """
524
        return self._transport.start_hotkeys()
4✔
525

526
    def stop_hotkeys(self) -> None:
4✔
527
        """
528
        Stop the Autohotkey process for triggering hotkeys/hotstrings
529

530
        """
531
        return self._transport.stop_hotkeys()
4✔
532

533
    async def set_detect_hidden_windows(self, value: bool) -> None:
4✔
534
        """
535
        Analog for `DetectHiddenWindows <https://www.autohotkey.com/docs/commands/DetectHiddenWindows.htm>`_
536

537
        :param value: The setting value. ``True`` to turn on hidden window detection, ``False`` to turn it off.
538
        """
539

540
        if value not in (True, False):
4✔
541
            raise TypeError(f'detect hidden windows must be a boolean, got object of type {type(value)}')
×
542
        args = []
4✔
543
        if value is True:
4✔
544
            args.append('On')
4✔
545
        else:
546
            args.append('Off')
×
547
        await self._transport.function_call('AHKSetDetectHiddenWindows', args=args)
4✔
548
        return None
4✔
549

550
    @staticmethod
4✔
551
    def _format_win_args(
4✔
552
        title: str,
553
        text: str,
554
        exclude_title: str,
555
        exclude_text: str,
556
        title_match_mode: Optional[TitleMatchMode] = None,
557
        detect_hidden_windows: Optional[bool] = None,
558
    ) -> List[str]:
559
        args = [title, text, exclude_title, exclude_text]
4✔
560
        if detect_hidden_windows is not None:
4✔
561
            if detect_hidden_windows is True:
4✔
562
                args.append('On')
4✔
563
            elif detect_hidden_windows is False:
4✔
564
                args.append('Off')
4✔
565
            else:
566
                raise TypeError(
×
567
                    f'Invalid value for parameter detect_hidden_windows. Expected boolean or None, got {detect_hidden_windows!r}'
568
                )
569
        else:
570
            args.append('')
4✔
571
        if title_match_mode is not None:
4✔
572
            if isinstance(title_match_mode, tuple):
4✔
573
                match_mode, match_speed = title_match_mode
4✔
574
            elif title_match_mode in (1, 2, 3, 'RegEx'):
×
575
                match_mode = title_match_mode
×
576
                match_speed = ''
×
577
            elif title_match_mode in ('Fast', 'Slow'):
×
578
                match_mode = ''
×
579
                match_speed = title_match_mode
×
580
            else:
581
                raise ValueError(
×
582
                    f"Invalid value for title_match_mode argument. Expected 1, 2, 3, 'RegEx', 'Fast', 'Slow' or a tuple of these. Got {title_match_mode!r}"
583
                )
584
            args.append(str(match_mode))
4✔
585
            args.append(str(match_speed))
4✔
586
        else:
587
            args.append('')
4✔
588
            args.append('')
4✔
589
        return args
4✔
590

591
    # fmt: off
592
    @overload
4✔
593
    async def list_windows(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None) -> List[AsyncWindow]: ...
4✔
594
    @overload
4✔
595
    async def list_windows(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: Literal[False]) -> Union[List[AsyncWindow], AsyncFutureResult[List[AsyncWindow]]]: ...
4✔
596
    @overload
4✔
597
    async def list_windows(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: Literal[True]) -> List[AsyncWindow]: ...
4✔
598
    @overload
4✔
599
    async def list_windows(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: bool = True,) -> Union[List[AsyncWindow], AsyncFutureResult[List[AsyncWindow]]]: ...
4✔
600
    # fmt: on
601
    async def list_windows(
4✔
602
        self,
603
        title: str = '',
604
        text: str = '',
605
        exclude_title: str = '',
606
        exclude_text: str = '',
607
        *,
608
        title_match_mode: Optional[TitleMatchMode] = None,
609
        detect_hidden_windows: Optional[bool] = None,
610
        blocking: bool = True,
611
    ) -> Union[List[AsyncWindow], AsyncFutureResult[List[AsyncWindow]]]:
612
        """
613
        Enumerate all windows matching the criteria.
614

615
        Analog for `WinGet List subcommand <https://www.autohotkey.com/docs/v1/lib/WinGet.htm#List>_`
616
        """
617
        args = self._format_win_args(
4✔
618
            title=title,
619
            text=text,
620
            exclude_title=exclude_title,
621
            exclude_text=exclude_text,
622
            title_match_mode=title_match_mode,
623
            detect_hidden_windows=detect_hidden_windows,
624
        )
625
        resp = await self._transport.function_call('AHKWindowList', args, engine=self, blocking=blocking)
4✔
626
        return resp
4✔
627

628
    # fmt: off
629
    @overload
4✔
630
    async def get_mouse_position(self, coord_mode: Optional[CoordModeRelativeTo] = None, *, blocking: Literal[True]) -> Tuple[int, int]: ...
4✔
631
    @overload
4✔
632
    async def get_mouse_position(self, coord_mode: Optional[CoordModeRelativeTo] = None, *, blocking: Literal[False]) -> AsyncFutureResult[Tuple[int, int]]: ...
4✔
633
    @overload
4✔
634
    async def get_mouse_position(self, coord_mode: Optional[CoordModeRelativeTo] = None) -> Tuple[int, int]: ...
4✔
635
    @overload
4✔
636
    async def get_mouse_position(self, coord_mode: Optional[CoordModeRelativeTo] = None, *, blocking: bool = True) -> Union[Tuple[int, int], AsyncFutureResult[Tuple[int, int]]]: ...
4✔
637
    # fmt: on
638
    async def get_mouse_position(
4✔
639
        self, coord_mode: Optional[CoordModeRelativeTo] = None, *, blocking: bool = True
640
    ) -> Union[Tuple[int, int], AsyncFutureResult[Tuple[int, int]]]:
641
        """
642
        Analog for `MouseGetPos <https://www.autohotkey.com/docs/commands/MouseGetPos.htm>`_
643
        """
644
        if coord_mode:
4✔
645
            args = [str(coord_mode)]
×
646
        else:
647
            args = []
4✔
648
        resp = await self._transport.function_call('AHKMouseGetPos', args, blocking=blocking)
4✔
649
        return resp
4✔
650

651
    @property
4✔
652
    def mouse_position(self) -> AsyncPropertyReturnTupleIntInt:
4✔
653
        """
654
        Convenience property for :py:meth:`get_mouse_position`
655

656
        Setter accepts a tuple of x,y coordinates passed to :py:meth:`mouse_mouse`
657
        """
658
        warnings.warn(  # unasync: remove
×
659
            _PROPERTY_DEPRECATION_WARNING_MESSAGE.format('mouse_position'), category=DeprecationWarning, stacklevel=2
660
        )
661
        return self.get_mouse_position()
×
662

663
    @mouse_position.setter
4✔
664
    def mouse_position(self, new_position: Tuple[int, int]) -> None:
4✔
665
        """
666
        Convenience setter for ``mouse_move``
667

668
        :param new_position: a tuple of x,y coordinates to move to
669
        """
670
        raise RuntimeError('Use of the mouse_position setter is not supported in the async API.')  # unasync: remove
×
671
        x, y = new_position
672
        return self.mouse_move(x=x, y=y, speed=0, relative=False)
673

674
    # fmt: off
675
    @overload
4✔
676
    async def mouse_move(self, x: Optional[Union[str, int]] = None, y: Optional[Union[str, int]] = None, *, speed: Optional[int] = None, relative: bool = False) -> None: ...
4✔
677
    @overload
4✔
678
    async def mouse_move(self, x: Optional[Union[str, int]] = None, y: Optional[Union[str, int]] = None, *, blocking: Literal[True], speed: Optional[int] = None, relative: bool = False) -> None: ...
4✔
679
    @overload
4✔
680
    async def mouse_move(self, x: Optional[Union[str, int]] = None, y: Optional[Union[str, int]] = None, *, blocking: Literal[False], speed: Optional[int] = None, relative: bool = False, ) -> AsyncFutureResult[None]: ...
4✔
681
    @overload
4✔
682
    async def mouse_move(self, x: Optional[Union[str, int]] = None, y: Optional[Union[str, int]] = None, *, speed: Optional[int] = None, relative: bool = False, blocking: bool = True) -> Union[None, AsyncFutureResult[None]]: ...
4✔
683
    # fmt: on
684
    async def mouse_move(
4✔
685
        self,
686
        x: Optional[Union[str, int]] = None,
687
        y: Optional[Union[str, int]] = None,
688
        *,
689
        speed: Optional[int] = None,
690
        relative: bool = False,
691
        blocking: bool = True,
692
    ) -> Union[None, AsyncFutureResult[None]]:
693
        """
694
        Analog for `MouseMove <https://www.autohotkey.com/docs/commands/MouseMove.htm>`_
695
        """
696
        if relative and (x is None or y is None):
4✔
697
            x = x or 0
×
698
            y = y or 0
×
699
        elif not relative and (x is None or y is None):
4✔
700
            posx, posy = await self.get_mouse_position()
×
701
            x = x or posx
×
702
            y = y or posy
×
703

704
        if speed is None:
4✔
705
            speed = 2
4✔
706
        args = [str(x), str(y), str(speed)]
4✔
707
        if relative:
4✔
708
            args.append('R')
4✔
709
        resp = await self._transport.function_call('AHKMouseMove', args, blocking=blocking)
4✔
710
        return resp
4✔
711

712
    async def a_run_script(self, *args: Any, **kwargs: Any) -> Union[str, AsyncFutureResult[str]]:
4✔
713
        """
714
        Deprecated. Use :py:meth:`run_script` instead.
715
        """
716
        warnings.warn('a_run_script is deprecated. Use run_script instead.', DeprecationWarning, stacklevel=2)
×
717
        return await self.run_script(*args, **kwargs)
×
718

719
    # fmt: off
720
    @overload
4✔
721
    async def get_active_window(self) -> Optional[AsyncWindow]: ...
4✔
722
    @overload
4✔
723
    async def get_active_window(self, blocking: Literal[True]) -> Optional[AsyncWindow]: ...
4✔
724
    @overload
4✔
725
    async def get_active_window(self, blocking: Literal[False]) -> AsyncFutureResult[Optional[AsyncWindow]]: ...
4✔
726
    @overload
4✔
727
    async def get_active_window(self, blocking: bool = True) -> Union[Optional[AsyncWindow], AsyncFutureResult[Optional[AsyncWindow]]]: ...
4✔
728
    # fmt: on
729
    async def get_active_window(
4✔
730
        self, blocking: bool = True
731
    ) -> Union[Optional[AsyncWindow], AsyncFutureResult[Optional[AsyncWindow]]]:
732
        """
733
        Gets the currently active window.
734
        """
735
        return await self.win_get(
4✔
736
            title='A', detect_hidden_windows=False, title_match_mode=(1, 'Fast'), blocking=blocking
737
        )
738

739
    @property
4✔
740
    def active_window(self) -> AsyncPropertyReturnOptionalAsyncWindow:
4✔
741
        """
742
        Gets the currently active window. Convenience property for :py:meth:`get_active_window`
743
        """
744
        warnings.warn(  # unasync: remove
×
745
            _PROPERTY_DEPRECATION_WARNING_MESSAGE.format('active_window'), category=DeprecationWarning, stacklevel=2
746
        )
747
        return self.get_active_window()
×
748

749
    async def find_windows(
4✔
750
        self,
751
        func: Optional[AsyncFilterFunc] = None,
752
        *,
753
        title_match_mode: Optional[TitleMatchMode] = None,
754
        title: str = '',
755
        text: str = '',
756
        exclude_title: str = '',
757
        exclude_text: str = '',
758
        exact: Optional[bool] = None,
759
    ) -> List[AsyncWindow]:
760
        if exact is not None and title_match_mode is not None:
×
761
            raise TypeError('exact and match_mode parameters are mutually exclusive')
×
762
        if exact is not None:
×
763
            warnings.warn('exact parameter is deprecated. Use match_mode=3 instead', stacklevel=2)
×
764
            if exact:
×
765
                title_match_mode = (3, 'Fast')
×
766
            else:
767
                title_match_mode = (1, 'Fast')
×
768
        elif title_match_mode is None:
×
769
            title_match_mode = (1, 'Fast')
×
770

771
        windows = await self.list_windows(
×
772
            title=title,
773
            text=text,
774
            exclude_title=exclude_title,
775
            exclude_text=exclude_text,
776
            title_match_mode=title_match_mode,
777
        )
778
        if func is None:
×
779
            return windows
×
780
        else:
781
            ret: List[AsyncWindow] = []
×
782
            for win in windows:
×
783
                match = await func(win)
×
784
                if match:
×
785
                    ret.append(win)
×
786
            return ret
×
787

788
    async def find_windows_by_class(
4✔
789
        self, class_name: str, *, exact: Optional[bool] = None, title_match_mode: Optional[TitleMatchMode] = None
790
    ) -> List[AsyncWindow]:
791
        with warnings.catch_warnings(record=True) as caught_warnings:
×
792
            ret = await self.find_windows(
×
793
                title=f'ahk_class {class_name}', title_match_mode=title_match_mode, exact=exact
794
            )
795
        if caught_warnings:
×
796
            for warning in caught_warnings:
×
797
                warnings.warn(warning.message, warning.category, stacklevel=2)
×
798
        return ret
×
799

800
    async def find_windows_by_text(
4✔
801
        self, text: str, exact: Optional[bool] = None, title_match_mode: Optional[TitleMatchMode] = None
802
    ) -> List[AsyncWindow]:
803
        with warnings.catch_warnings(record=True) as caught_warnings:
×
804
            ret = await self.find_windows(text=text, exact=exact, title_match_mode=title_match_mode)
×
805
        if caught_warnings:
×
806
            for warning in caught_warnings:
×
807
                warnings.warn(warning.message, warning.category, stacklevel=2)
×
808
        return ret
×
809

810
    async def find_windows_by_title(
4✔
811
        self, title: str, exact: Optional[bool] = None, title_match_mode: Optional[TitleMatchMode] = None
812
    ) -> List[AsyncWindow]:
813
        with warnings.catch_warnings(record=True) as caught_warnings:
×
814
            ret = await self.find_windows(title=title, exact=exact, title_match_mode=title_match_mode)
×
815
        if caught_warnings:
×
816
            for warning in caught_warnings:
×
817
                warnings.warn(warning.message, warning.category, stacklevel=2)
×
818
        return ret
×
819

820
    async def find_window(
4✔
821
        self,
822
        func: Optional[AsyncFilterFunc] = None,
823
        *,
824
        title_match_mode: Optional[TitleMatchMode] = None,
825
        title: str = '',
826
        text: str = '',
827
        exclude_title: str = '',
828
        exclude_text: str = '',
829
        exact: Optional[bool] = None,
830
    ) -> Optional[AsyncWindow]:
831
        with warnings.catch_warnings(record=True) as caught_warnings:
×
832
            windows = await self.find_windows(
×
833
                func,
834
                title=title,
835
                text=text,
836
                exclude_title=exclude_title,
837
                exclude_text=exclude_text,
838
                exact=exact,
839
                title_match_mode=title_match_mode,
840
            )
841
        if caught_warnings:
×
842
            for warning in caught_warnings:
×
843
                warnings.warn(warning.message, warning.category, stacklevel=2)
×
844
        return windows[0] if windows else None
×
845

846
    async def find_window_by_class(
4✔
847
        self, class_name: str, exact: Optional[bool] = None, title_match_mode: Optional[TitleMatchMode] = None
848
    ) -> Optional[AsyncWindow]:
849
        with warnings.catch_warnings(record=True) as caught_warnings:
×
850
            windows = await self.find_windows_by_class(
×
851
                class_name=class_name, exact=exact, title_match_mode=title_match_mode
852
            )
853
        if caught_warnings:
×
854
            for warning in caught_warnings:
×
855
                warnings.warn(warning.message, warning.category, stacklevel=2)
×
856
        return windows[0] if windows else None
×
857

858
    async def find_window_by_text(
4✔
859
        self, text: str, exact: Optional[bool] = None, title_match_mode: Optional[TitleMatchMode] = None
860
    ) -> Optional[AsyncWindow]:
861
        with warnings.catch_warnings(record=True) as caught_warnings:
×
862
            windows = await self.find_windows_by_text(text=text, exact=exact, title_match_mode=title_match_mode)
×
863
        if caught_warnings:
×
864
            for warning in caught_warnings:
×
865
                warnings.warn(warning.message, warning.category, stacklevel=2)
×
866
        return windows[0] if windows else None
×
867

868
    async def find_window_by_title(
4✔
869
        self, title: str, exact: Optional[bool] = None, title_match_mode: Optional[TitleMatchMode] = None
870
    ) -> Optional[AsyncWindow]:
871
        with warnings.catch_warnings(record=True) as caught_warnings:
×
872
            windows = await self.find_windows_by_title(title=title, exact=exact, title_match_mode=title_match_mode)
×
873
        if caught_warnings:
×
874
            for warning in caught_warnings:
×
875
                warnings.warn(warning.message, warning.category, stacklevel=2)
×
876
        return windows[0] if windows else None
×
877

878
    async def get_volume(self, device_number: int = 1) -> float:
4✔
879
        """
880
        Analog for `SoundGetWaveVolume <https://www.autohotkey.com/docs/commands/SoundGetWaveVolume.htm>`_
881
        """
882
        args = [str(device_number)]
×
883
        response = await self._transport.function_call('AHKGetVolume', args)
×
884
        return response
×
885

886
    # fmt: off
887
    @overload
4✔
888
    async def key_down(self, key: Union[str, Key]) -> None: ...
4✔
889
    @overload
4✔
890
    async def key_down(self, key: Union[str, Key], *, blocking: Literal[True]) -> None: ...
4✔
891
    @overload
4✔
892
    async def key_down(self, key: Union[str, Key], *, blocking: Literal[False]) -> AsyncFutureResult[None]: ...
4✔
893
    @overload
4✔
894
    async def key_down(self, key: Union[str, Key], *, blocking: bool = True) -> Union[None, AsyncFutureResult[None]]: ...
4✔
895
    # fmt: on
896
    async def key_down(self, key: Union[str, Key], *, blocking: bool = True) -> Union[None, AsyncFutureResult[None]]:
4✔
897
        """
898
        Shortcut for :py:meth:`send_input` but transforms specified key to perform a key "DOWN" only (no release)
899
        """
900
        if isinstance(key, str):
4✔
901
            key = Key(key_name=key)
4✔
902
        if blocking:
4✔
903
            await self.send_input(key.DOWN, blocking=True)
4✔
904
            return None
4✔
905
        else:
906
            return await self.send_input(key.DOWN, blocking=False)
×
907

908
    # fmt: off
909
    @overload
4✔
910
    async def key_press(self, key: Union[str, Key], *, release: bool = True) -> None: ...
4✔
911
    @overload
4✔
912
    async def key_press(self, key: Union[str, Key], *, blocking: Literal[True], release: bool = True) -> None: ...
4✔
913
    @overload
4✔
914
    async def key_press(self, key: Union[str, Key], *, blocking: Literal[False], release: bool = True) -> AsyncFutureResult[None]: ...
4✔
915
    @overload
4✔
916
    async def key_press(self, key: Union[str, Key], *, release: bool = True, blocking: bool = True) -> Union[None, AsyncFutureResult[None]]: ...
4✔
917
    # fmt: on
918
    async def key_press(
4✔
919
        self, key: Union[str, Key], *, release: bool = True, blocking: bool = True
920
    ) -> Union[None, AsyncFutureResult[None]]:
921
        """
922
        Press (and release) a key. Sends `:py:meth:`key_down` then, if ``release`` is ``True`` (the default), sends
923
        :py:meth:`key_up` subsequently.
924
        """
925
        if blocking:
4✔
926
            await self.key_down(key, blocking=True)
4✔
927
            if release:
4✔
928
                await self.key_up(key, blocking=True)
4✔
929
            return None
4✔
930
        else:
931
            d = await self.key_down(key, blocking=False)
×
932
            if release:
×
933
                return await self.key_up(key, blocking=False)
×
934
            return d
×
935

936
    # fmt: off
937
    @overload
4✔
938
    async def key_release(self, key: Union[str, Key]) -> None: ...
4✔
939
    @overload
4✔
940
    async def key_release(self, key: Union[str, Key], *, blocking: Literal[True]) -> None: ...
4✔
941
    @overload
4✔
942
    async def key_release(self, key: Union[str, Key], *, blocking: Literal[False]) -> AsyncFutureResult[None]: ...
4✔
943
    @overload
4✔
944
    async def key_release(self, key: Union[str, Key], *, blocking: bool = True) -> Union[None, AsyncFutureResult[None]]: ...
4✔
945
    # fmt: on
946
    async def key_release(self, key: Union[str, Key], *, blocking: bool = True) -> Union[None, AsyncFutureResult[None]]:
4✔
947
        """
948
        Alias for :py:meth:`key_up`
949
        """
950
        if blocking:
×
951
            await self.key_up(key=key, blocking=True)
×
952
            return None
×
953
        else:
954
            return await self.key_up(key=key, blocking=False)
×
955

956
    # fmt: off
957
    @overload
4✔
958
    async def key_state(self, key_name: str, *, mode: Optional[Literal['T', 'P']] = None) -> Union[float, int, str, None]: ...
4✔
959
    @overload
4✔
960
    async def key_state(self, key_name: str, *, mode: Optional[Literal['T', 'P']] = None, blocking: Literal[True]) -> Union[float, int, str, None]: ...
4✔
961
    @overload
4✔
962
    async def key_state(self, key_name: str, *, mode: Optional[Literal['T', 'P']] = None, blocking: Literal[False]) -> Union[AsyncFutureResult[str], AsyncFutureResult[int], AsyncFutureResult[float], AsyncFutureResult[None]]: ...
4✔
963
    @overload
4✔
964
    async def key_state(self, key_name: str, *, mode: Optional[Literal['T', 'P']] = None, blocking: bool = True) -> Union[None, AsyncFutureResult[None], Union[str, AsyncFutureResult[str]], Union[int, AsyncFutureResult[int]], Union[float, AsyncFutureResult[float]]]: ...
4✔
965
    # fmt: on
966
    async def key_state(
4✔
967
        self, key_name: str, *, mode: Optional[Literal['T', 'P']] = None, blocking: bool = True
968
    ) -> Union[
969
        int,
970
        float,
971
        str,
972
        None,
973
        AsyncFutureResult[str],
974
        AsyncFutureResult[int],
975
        AsyncFutureResult[float],
976
        AsyncFutureResult[None],
977
    ]:
978
        """
979
        Analog for `GetKeyState <https://www.autohotkey.com/docs/commands/GetKeyState.htm#command>`_
980
        """
981
        args: List[str] = [key_name]
4✔
982
        if mode is not None:
4✔
983
            if mode not in ('T', 'P'):
4✔
984
                raise ValueError(f'Invalid value for mode parameter. Mode must be `T` or `P`. Got {mode!r}')
×
985
            args.append(mode)
4✔
986
        resp = await self._transport.function_call('AHKKeyState', args, blocking=blocking)
4✔
987
        return resp
4✔
988

989
    # fmt: off
990
    @overload
4✔
991
    async def key_up(self, key: Union[str, Key]) -> None: ...
4✔
992
    @overload
4✔
993
    async def key_up(self, key: Union[str, Key], *, blocking: Literal[True]) -> None: ...
4✔
994
    @overload
4✔
995
    async def key_up(self, key: Union[str, Key], *, blocking: Literal[False]) -> AsyncFutureResult[None]: ...
4✔
996
    @overload
4✔
997
    async def key_up(self, key: Union[str, Key], blocking: bool = True) -> Union[None, AsyncFutureResult[None]]: ...
4✔
998
    # fmt: on
999
    async def key_up(self, key: Union[str, Key], blocking: bool = True) -> Union[None, AsyncFutureResult[None]]:
4✔
1000
        """
1001
        Shortcut for :py:meth:`send_input` but transforms specified key to perform a key "UP" only. Useful if the key
1002
        was previously pressed down but not released.
1003
        """
1004
        if isinstance(key, str):
4✔
1005
            key = Key(key_name=key)
4✔
1006
        if blocking:
4✔
1007
            await self.send_input(key.UP, blocking=True)
4✔
1008
            return None
4✔
1009
        else:
1010
            return await self.send_input(key.UP, blocking=False)
×
1011

1012
    # fmt: off
1013
    @overload
4✔
1014
    async def key_wait(self, key_name: str, *, timeout: Optional[int] = None, logical_state: bool = False, released: bool = False) -> int: ...
4✔
1015
    @overload
4✔
1016
    async def key_wait(self, key_name: str, *, blocking: Literal[True], timeout: Optional[int] = None, logical_state: bool = False, released: bool = False) -> int: ...
4✔
1017
    @overload
4✔
1018
    async def key_wait(self, key_name: str, *, blocking: Literal[False], timeout: Optional[int] = None, logical_state: bool = False, released: bool = False) -> AsyncFutureResult[int]: ...
4✔
1019
    @overload
4✔
1020
    async def key_wait(self, key_name: str, *, timeout: Optional[int] = None, logical_state: bool = False, released: bool = False, blocking: bool = True) -> Union[int, AsyncFutureResult[int]]: ...
4✔
1021
    # fmt: on
1022
    async def key_wait(
4✔
1023
        self,
1024
        key_name: str,
1025
        *,
1026
        timeout: Optional[int] = None,
1027
        logical_state: bool = False,
1028
        released: bool = False,
1029
        blocking: bool = True,
1030
    ) -> Union[int, AsyncFutureResult[int]]:
1031
        """
1032
        Analog for `KeyWait <https://www.autohotkey.com/docs/commands/KeyWait.htm>`_
1033
        """
1034
        options = ''
×
1035
        if not released:
×
1036
            options += 'D'
×
1037
        if logical_state:
×
1038
            options += 'L'
×
1039
        if timeout:
×
1040
            options += f'T{timeout}'
×
1041
        args = [key_name]
×
1042
        if options:
×
1043
            args.append(options)
×
1044

1045
        resp = await self._transport.function_call('AHKKeyWait', args, blocking=blocking)
×
1046
        return resp
×
1047

1048
    async def run_script(
4✔
1049
        self, script_text_or_path: str, /, *, blocking: bool = True, timeout: Optional[int] = None
1050
    ) -> Union[str, AsyncFutureResult[str]]:
1051
        """
1052
        Run an AutoHotkey script.
1053
        Can either be a path to a script (``.ahk``) file or a string containing script contents
1054
        """
1055
        return await self._transport.run_script(script_text_or_path, blocking=blocking, timeout=timeout)
4✔
1056

1057
    async def set_send_level(self, level: int) -> None:
4✔
1058
        """
1059
        Analog for `SendLevel <https://www.autohotkey.com/docs/commands/SendLevel.htm>`_
1060
        """
1061
        if not isinstance(level, int):
4✔
1062
            raise TypeError('level must be an integer between 0 and 100')
×
1063
        if not 0 <= level <= 100:
4✔
1064
            raise ValueError('level value must be between 0 and 100')
×
1065
        args = [str(level)]
4✔
1066
        await self._transport.function_call('AHKSetSendLevel', args)
4✔
1067

1068
    async def get_send_level(self) -> int:
4✔
1069
        """
1070
        Get the current `SendLevel <https://www.autohotkey.com/docs/commands/SendLevel.htm>`_
1071
        (I.E. the value of ``A_SendLevel``)
1072
        """
1073
        resp = await self._transport.function_call('AHKGetSendLevel')
×
1074
        return resp
×
1075

1076
    # fmt: off
1077
    @overload
4✔
1078
    async def send(self, s: str, *, raw: bool = False, key_delay: Optional[int] = None, key_press_duration: Optional[int] = None) -> None: ...
4✔
1079
    @overload
4✔
1080
    async def send(self, s: str, *, raw: bool = False, key_delay: Optional[int] = None, key_press_duration: Optional[int] = None, blocking: Literal[True]) -> None: ...
4✔
1081
    @overload
4✔
1082
    async def send(self, s: str, *, raw: bool = False, key_delay: Optional[int] = None, key_press_duration: Optional[int] = None, blocking: Literal[False]) -> AsyncFutureResult[None]: ...
4✔
1083
    @overload
4✔
1084
    async def send(self, s: str, *, raw: bool = False, key_delay: Optional[int] = None, key_press_duration: Optional[int] = None, blocking: bool = True) -> Union[None, AsyncFutureResult[None]]: ...
4✔
1085
    # fmt: on
1086
    async def send(
4✔
1087
        self,
1088
        s: str,
1089
        *,
1090
        raw: bool = False,
1091
        key_delay: Optional[int] = None,
1092
        key_press_duration: Optional[int] = None,
1093
        blocking: bool = True,
1094
    ) -> Union[None, AsyncFutureResult[None]]:
1095
        """
1096
        Analog for `Send <https://www.autohotkey.com/docs/v1/lib/Send.htm>`_
1097
        """
1098
        args = [s]
4✔
1099
        if key_delay:
4✔
1100
            args.append(str(key_delay))
×
1101
        else:
1102
            args.append('')
4✔
1103
        if key_press_duration:
4✔
1104
            args.append(str(key_press_duration))
×
1105
        else:
1106
            args.append('')
4✔
1107

1108
        if raw:
4✔
1109
            raw_resp = await self._transport.function_call('AHKSendRaw', args=args, blocking=blocking)
×
1110
            return raw_resp
×
1111
        else:
1112
            resp = await self._transport.function_call('AHKSend', args=args, blocking=blocking)
4✔
1113
            return resp
4✔
1114

1115
    # fmt: off
1116
    @overload
4✔
1117
    async def send_raw(self, s: str, *, key_delay: Optional[int] = None, key_press_duration: Optional[int] = None) -> None: ...
4✔
1118
    @overload
4✔
1119
    async def send_raw(self, s: str, *, key_delay: Optional[int] = None, key_press_duration: Optional[int] = None, blocking: Literal[True]) -> None: ...
4✔
1120
    @overload
4✔
1121
    async def send_raw(self, s: str, *, key_delay: Optional[int] = None, key_press_duration: Optional[int] = None, blocking: Literal[False]) -> AsyncFutureResult[None]: ...
4✔
1122
    @overload
4✔
1123
    async def send_raw(self, s: str, *, key_delay: Optional[int] = None, key_press_duration: Optional[int] = None, blocking: bool = True) -> Union[None, AsyncFutureResult[None]]: ...
4✔
1124
    # fmt: on
1125
    async def send_raw(
4✔
1126
        self,
1127
        s: str,
1128
        *,
1129
        key_delay: Optional[int] = None,
1130
        key_press_duration: Optional[int] = None,
1131
        blocking: bool = True,
1132
    ) -> Union[None, AsyncFutureResult[None]]:
1133
        """
1134
        Analog for `SendRaw <https://www.autohotkey.com/docs/v1/lib/Send.htm>`_
1135
        """
1136
        resp = await self.send(
×
1137
            s, raw=True, key_delay=key_delay, key_press_duration=key_press_duration, blocking=blocking
1138
        )
1139
        return resp
×
1140

1141
    # fmt: off
1142
    @overload
4✔
1143
    async def send_input(self, s: str) -> None: ...
4✔
1144
    @overload
4✔
1145
    async def send_input(self, s: str, *, blocking: Literal[True]) -> None: ...
4✔
1146
    @overload
4✔
1147
    async def send_input(self, s: str, *, blocking: Literal[False]) -> AsyncFutureResult[None]: ...
4✔
1148
    @overload
4✔
1149
    async def send_input(self, s: str, *, blocking: bool = True) -> Union[None, AsyncFutureResult[None]]: ...
4✔
1150
    # fmt: on
1151
    async def send_input(self, s: str, *, blocking: bool = True) -> Union[None, AsyncFutureResult[None]]:
4✔
1152
        """
1153
        Analog for `SendInput <https://www.autohotkey.com/docs/v1/lib/Send.htm>`_
1154
        """
1155
        args = [s]
4✔
1156
        resp = await self._transport.function_call('AHKSendInput', args, blocking=blocking)
4✔
1157
        return resp
4✔
1158

1159
    # fmt: off
1160
    @overload
4✔
1161
    async def type(self, s: str) -> None: ...
4✔
1162
    @overload
4✔
1163
    async def type(self, s: str, *, blocking: Literal[True]) -> None: ...
4✔
1164
    @overload
4✔
1165
    async def type(self, s: str, *, blocking: Literal[False]) -> AsyncFutureResult[None]: ...
4✔
1166
    @overload
4✔
1167
    async def type(self, s: str, *, blocking: bool = True) -> Union[None, AsyncFutureResult[None]]: ...
4✔
1168
    # fmt: on
1169
    async def type(self, s: str, *, blocking: bool = True) -> Union[None, AsyncFutureResult[None]]:
4✔
1170
        """
1171
        Like :py:meth:`send_input` but performs necessary escapes for you.
1172
        """
1173
        resp = await self.send_input(type_escape(s), blocking=blocking)
4✔
1174
        return resp
4✔
1175

1176
    # fmt: off
1177
    @overload
4✔
1178
    async def send_play(self, s: str, *, key_delay: Optional[int] = None, key_press_duration: Optional[int] = None) -> None: ...
4✔
1179
    @overload
4✔
1180
    async def send_play(self, s: str, *, key_delay: Optional[int] = None, key_press_duration: Optional[int] = None, blocking: Literal[True]) -> None: ...
4✔
1181
    @overload
4✔
1182
    async def send_play(self, s: str, *, key_delay: Optional[int] = None, key_press_duration: Optional[int] = None, blocking: Literal[False]) -> AsyncFutureResult[None]: ...
4✔
1183
    @overload
4✔
1184
    async def send_play(self, s: str, *, key_delay: Optional[int] = None, key_press_duration: Optional[int] = None, blocking: bool = True) -> Union[None, AsyncFutureResult[None]]: ...
4✔
1185
    # fmt: on
1186
    async def send_play(
4✔
1187
        self,
1188
        s: str,
1189
        *,
1190
        key_delay: Optional[int] = None,
1191
        key_press_duration: Optional[int] = None,
1192
        blocking: bool = True,
1193
    ) -> Union[None, AsyncFutureResult[None]]:
1194
        """
1195
        Analog for `SendPlay <https://www.autohotkey.com/docs/v1/lib/Send.htm>`_
1196
        """
1197
        args = [s]
×
1198
        if key_delay:
×
1199
            args.append(str(key_delay))
×
1200
        else:
1201
            args.append('')
×
1202
        if key_press_duration:
×
1203
            args.append(str(key_press_duration))
×
1204
        else:
1205
            args.append('')
×
1206

1207
        resp = await self._transport.function_call('AHKSendPlay', args=args, blocking=blocking)
×
1208
        return resp
×
1209

1210
    # fmt: off
1211
    @overload
4✔
1212
    async def set_capslock_state(self, state: Optional[Literal[0, 1, 'On', 'Off', 'AlwaysOn', 'AlwaysOff']] = None) -> None: ...
4✔
1213
    @overload
4✔
1214
    async def set_capslock_state(self, state: Optional[Literal[0, 1, 'On', 'Off', 'AlwaysOn', 'AlwaysOff']] = None, *, blocking: Literal[True]) -> None: ...
4✔
1215
    @overload
4✔
1216
    async def set_capslock_state(self, state: Optional[Literal[0, 1, 'On', 'Off', 'AlwaysOn', 'AlwaysOff']] = None, *, blocking: Literal[False]) -> AsyncFutureResult[None]: ...
4✔
1217
    @overload
4✔
1218
    async def set_capslock_state(self, state: Optional[Literal[0, 1, 'On', 'Off', 'AlwaysOn', 'AlwaysOff']] = None, *, blocking: bool = True) -> Union[None, AsyncFutureResult[None]]: ...
4✔
1219
    # fmt: on
1220
    async def set_capslock_state(
4✔
1221
        self, state: Optional[Literal[0, 1, 'On', 'Off', 'AlwaysOn', 'AlwaysOff']] = None, *, blocking: bool = True
1222
    ) -> Union[None, AsyncFutureResult[None]]:
1223
        """
1224
        Analog for `SetCapsLockState <https://www.autohotkey.com/docs/commands/SetNumScrollCapsLockState.htm>`_
1225
        """
1226
        args: List[str] = []
4✔
1227
        if state is not None:
4✔
1228
            if str(state).lower() not in ('1', '0', 'on', 'off', 'alwayson', 'alwaysoff'):
4✔
1229
                raise ValueError(
×
1230
                    f'Invalid value for state. Must be one of On, Off, AlwaysOn, AlwaysOff or None. Got {state!r}'
1231
                )
1232
            args.append(str(state))
4✔
1233

1234
        resp = await self._transport.function_call('AHKSetCapsLockState', args, blocking=blocking)
4✔
1235
        return resp
4✔
1236

1237
    # fmt: off
1238
    @overload
4✔
1239
    async def set_volume(self, value: int, device_number: int = 1) -> None: ...
4✔
1240
    @overload
4✔
1241
    async def set_volume(self, value: int, device_number: int = 1, *, blocking: Literal[False]) -> AsyncFutureResult[None]: ...
4✔
1242
    @overload
4✔
1243
    async def set_volume(self, value: int, device_number: int = 1, *, blocking: Literal[True]) -> None: ...
4✔
1244
    @overload
4✔
1245
    async def set_volume(self, value: int, device_number: int = 1, *, blocking: bool = True) -> Union[None, AsyncFutureResult[None]]: ...
4✔
1246
    # fmt: on
1247
    async def set_volume(
4✔
1248
        self, value: int, device_number: int = 1, *, blocking: bool = True
1249
    ) -> Union[None, AsyncFutureResult[None]]:
1250
        """
1251
        Analog for `SoundSetWaveVolume <https://www.autohotkey.com/docs/commands/SoundSetWaveVolume.htm>`_
1252
        """
1253
        args = [str(device_number), str(value)]
×
1254
        return await self._transport.function_call('AHKSetVolume', args, blocking=blocking)
×
1255

1256
    # fmt: off
1257
    @overload
4✔
1258
    async def show_traytip(self, title: str, text: str, second: float = 1.0, type_id: int = 1, *, silent: bool = False, large_icon: bool = False) -> None: ...
4✔
1259
    @overload
4✔
1260
    async def show_traytip(self, title: str, text: str, second: float = 1.0, type_id: int = 1, *, silent: bool = False, large_icon: bool = False, blocking: Literal[False]) -> AsyncFutureResult[None]: ...
4✔
1261
    @overload
4✔
1262
    async def show_traytip(self, title: str, text: str, second: float = 1.0, type_id: int = 1, *, silent: bool = False, large_icon: bool = False, blocking: Literal[True]) -> None: ...
4✔
1263
    @overload
4✔
1264
    async def show_traytip(self, title: str, text: str, second: float = 1.0, type_id: int = 1, *, silent: bool = False, large_icon: bool = False, blocking: bool = True) -> Union[None, AsyncFutureResult[None]]: ...
4✔
1265
    # fmt: on
1266
    async def show_traytip(
4✔
1267
        self,
1268
        title: str,
1269
        text: str,
1270
        second: float = 1.0,
1271
        type_id: int = 1,
1272
        *,
1273
        silent: bool = False,
1274
        large_icon: bool = False,
1275
        blocking: bool = True,
1276
    ) -> Union[None, AsyncFutureResult[None]]:
1277
        """
1278
        Analog for `TrayTip <https://www.autohotkey.com/docs/commands/TrayTip.htm>`_
1279
        """
1280
        option = type_id + (16 if silent else 0) + (32 if large_icon else 0)
×
1281
        args = [title, text, str(second), str(option)]
×
1282
        return await self._transport.function_call('AHKTrayTip', args, blocking=blocking)
×
1283

1284
    # fmt: off
1285
    @overload
4✔
1286
    async def show_error_traytip(self, title: str, text: str, second: float = 1.0, *, silent: bool = False, large_icon: bool = False) -> None: ...
4✔
1287
    @overload
4✔
1288
    async def show_error_traytip(self, title: str, text: str, second: float = 1.0, *, silent: bool = False, large_icon: bool = False, blocking: Literal[False]) -> AsyncFutureResult[None]: ...
4✔
1289
    @overload
4✔
1290
    async def show_error_traytip(self, title: str, text: str, second: float = 1.0, *, silent: bool = False, large_icon: bool = False, blocking: Literal[True]) -> None: ...
4✔
1291
    @overload
4✔
1292
    async def show_error_traytip(self, title: str, text: str, second: float = 1.0, *, silent: bool = False, large_icon: bool = False, blocking: bool = True) -> Union[None, AsyncFutureResult[None]]: ...
4✔
1293
    # fmt: on
1294
    async def show_error_traytip(
4✔
1295
        self,
1296
        title: str,
1297
        text: str,
1298
        second: float = 1.0,
1299
        *,
1300
        silent: bool = False,
1301
        large_icon: bool = False,
1302
        blocking: bool = True,
1303
    ) -> Union[None, AsyncFutureResult[None]]:
1304
        """
1305
        Convenience method for :py:meth:`show_traytip` for error-style messages
1306
        """
1307
        return await self.show_traytip(
×
1308
            title=title, text=text, second=second, type_id=3, silent=silent, large_icon=large_icon, blocking=blocking
1309
        )
1310

1311
    # fmt: off
1312
    @overload
4✔
1313
    async def show_info_traytip(self, title: str, text: str, second: float = 1.0, *, silent: bool = False, large_icon: bool = False) -> None: ...
4✔
1314
    @overload
4✔
1315
    async def show_info_traytip(self, title: str, text: str, second: float = 1.0, *, silent: bool = False, large_icon: bool = False, blocking: Literal[False]) -> AsyncFutureResult[None]: ...
4✔
1316
    @overload
4✔
1317
    async def show_info_traytip(self, title: str, text: str, second: float = 1.0, *, silent: bool = False, large_icon: bool = False, blocking: Literal[True]) -> None: ...
4✔
1318
    @overload
4✔
1319
    async def show_info_traytip(self, title: str, text: str, second: float = 1.0, *, silent: bool = False, large_icon: bool = False, blocking: bool = True) -> Union[None, AsyncFutureResult[None]]: ...
4✔
1320
    # fmt: on
1321
    async def show_info_traytip(
4✔
1322
        self,
1323
        title: str,
1324
        text: str,
1325
        second: float = 1.0,
1326
        *,
1327
        silent: bool = False,
1328
        large_icon: bool = False,
1329
        blocking: bool = True,
1330
    ) -> Union[None, AsyncFutureResult[None]]:
1331
        """
1332
        Convenience method for :py:meth:`show_traytip` for info-style messages
1333
        """
1334
        return await self.show_traytip(
×
1335
            title=title, text=text, second=second, type_id=1, silent=silent, large_icon=large_icon, blocking=blocking
1336
        )
1337

1338
    # fmt: off
1339
    @overload
4✔
1340
    async def show_warning_traytip(self, title: str, text: str, second: float = 1.0, *, silent: bool = False, large_icon: bool = False) -> None: ...
4✔
1341
    @overload
4✔
1342
    async def show_warning_traytip(self, title: str, text: str, second: float = 1.0, *, silent: bool = False, large_icon: bool = False, blocking: Literal[False]) -> AsyncFutureResult[None]: ...
4✔
1343
    @overload
4✔
1344
    async def show_warning_traytip(self, title: str, text: str, second: float = 1.0, *, silent: bool = False, large_icon: bool = False, blocking: Literal[True]) -> None: ...
4✔
1345
    @overload
4✔
1346
    async def show_warning_traytip(self, title: str, text: str, second: float = 1.0, *, silent: bool = False, large_icon: bool = False, blocking: bool = True) -> Union[None, AsyncFutureResult[None]]: ...
4✔
1347
    # fmt: on
1348
    async def show_warning_traytip(
4✔
1349
        self,
1350
        title: str,
1351
        text: str,
1352
        second: float = 1.0,
1353
        *,
1354
        silent: bool = False,
1355
        large_icon: bool = False,
1356
        blocking: bool = True,
1357
    ) -> Union[None, AsyncFutureResult[None]]:
1358
        """
1359
        Convenience method for :py:meth:`show_traytip` for warning-style messages
1360
        """
1361
        return await self.show_traytip(
×
1362
            title=title, text=text, second=second, type_id=2, silent=silent, large_icon=large_icon, blocking=blocking
1363
        )
1364

1365
    async def show_tooltip(
4✔
1366
        self,
1367
        text: str = '',
1368
        x: Optional[int] = None,
1369
        y: Optional[int] = None,
1370
        which: int = 1,
1371
    ) -> None:
1372
        """
1373
        Analog for `ToolTip <https://www.autohotkey.com/docs/commands/ToolTip.htm>`_
1374
        """
1375
        if which not in range(1, 21):
×
1376
            raise ValueError('which must be an integer between 1 and 20')
×
1377
        args = [text]
×
1378
        if x is not None:
×
1379
            args.append(str(x))
×
1380
        else:
1381
            args.append('')
×
1382
        if y is not None:
×
1383
            args.append(str(y))
×
1384
        else:
1385
            args.append('')
×
1386
        await self._transport.function_call('AHKShowToolTip', args)
×
1387

1388
    async def hide_tooltip(self, which: int = 1) -> None:
4✔
1389
        await self.show_tooltip(which=which)
×
1390

1391
    async def menu_tray_tooltip(self, value: str) -> None:
4✔
1392
        """
1393
        Change the menu tray icon tooltip that appears when hovering the mouse over the tray icon.
1394
        Does not affect tray icon for AHK processes started with :py:meth:`run_script` or ``blocking=False``
1395

1396
        Uses the `Tip subcommand <https://www.autohotkey.com/docs/v1/lib/Menu.htm#Tip>`_
1397
        """
1398

1399
        args = [value]
×
1400
        await self._transport.function_call('AHKMenuTrayTip', args)
×
1401
        return None
×
1402

1403
    async def menu_tray_icon(self, filename: str = '*', icon_number: int = 1, freeze: Optional[bool] = None) -> None:
4✔
1404
        """
1405
        Change the tray icon menu.
1406
        Does not affect tray icon for AHK processes started with :py:meth:`run_script` or ``blocking=False``
1407

1408
        Uses the `Icon subcommand <https://www.autohotkey.com/docs/v1/lib/Menu.htm#Icon>`_
1409

1410
        If called with no parameters, the tray icon will be reset to the original default.
1411
        """
1412
        args = [filename, str(icon_number)]
×
1413
        if freeze is True:
×
1414
            args.append('1')
×
1415
        elif freeze is False:
×
1416
            args.append('0')
×
1417
        await self._transport.function_call('AHKMenuTrayIcon', args)
×
1418
        return None
×
1419

1420
    async def menu_tray_icon_show(self) -> None:
4✔
1421
        """
1422
        Show ('unhide') the tray icon previously hidden by :py:class:`~ahk.directives.NoTrayIcon` directive.
1423
        Does not affect tray icon for AHK processes started with :py:meth:`run_script` or ``blocking=False``
1424
        """
1425
        await self._transport.function_call('AHKMenuTrayShow')
×
1426
        return None
×
1427

1428
    # fmt: off
1429
    @overload
4✔
1430
    async def sound_beep(self, frequency: int = 523, duration: int = 150) -> None: ...
4✔
1431
    @overload
4✔
1432
    async def sound_beep(self, frequency: int = 523, duration: int = 150, *, blocking: Literal[False]) -> AsyncFutureResult[None]: ...
4✔
1433
    @overload
4✔
1434
    async def sound_beep(self, frequency: int = 523, duration: int = 150, *, blocking: Literal[True]) -> None: ...
4✔
1435
    @overload
4✔
1436
    async def sound_beep(self, frequency: int = 523, duration: int = 150, *, blocking: bool = True) -> Optional[AsyncFutureResult[None]]: ...
4✔
1437
    # fmt: on
1438
    async def sound_beep(
4✔
1439
        self, frequency: int = 523, duration: int = 150, *, blocking: bool = True
1440
    ) -> Optional[AsyncFutureResult[None]]:
1441
        """
1442
        Analog for `SoundBeep <https://www.autohotkey.com/docs/commands/SoundBeep.htm>`_
1443
        """
1444
        args = [str(frequency), str(duration)]
×
1445
        await self._transport.function_call('AHKSoundBeep', args, blocking=blocking)
×
1446
        return None
×
1447

1448
    # fmt: off
1449
    @overload
4✔
1450
    async def sound_get(self, device_number: int = 1, component_type: str = 'MASTER', control_type: str = 'VOLUME') -> str: ...
4✔
1451
    @overload
4✔
1452
    async def sound_get(self, device_number: int = 1, component_type: str = 'MASTER', control_type: str = 'VOLUME', *, blocking: Literal[False]) -> AsyncFutureResult[str]: ...
4✔
1453
    @overload
4✔
1454
    async def sound_get(self, device_number: int = 1, component_type: str = 'MASTER', control_type: str = 'VOLUME', *, blocking: Literal[True]) -> str: ...
4✔
1455
    @overload
4✔
1456
    async def sound_get(self, device_number: int = 1, component_type: str = 'MASTER', control_type: str = 'VOLUME', *, blocking: bool = True) -> Union[str, AsyncFutureResult[str]]: ...
4✔
1457
    # fmt: on
1458
    async def sound_get(
4✔
1459
        self,
1460
        device_number: int = 1,
1461
        component_type: str = 'MASTER',
1462
        control_type: str = 'VOLUME',
1463
        *,
1464
        blocking: bool = True,
1465
    ) -> Union[str, AsyncFutureResult[str]]:
1466
        """
1467
        Analog for `SoundGet <https://www.autohotkey.com/docs/commands/SoundGet.htm>`_
1468
        """
1469
        args = [str(device_number), component_type, control_type]
×
1470
        return await self._transport.function_call('AHKSoundGet', args, blocking=blocking)
×
1471

1472
    # fmt: off
1473
    @overload
4✔
1474
    async def sound_play(self, filename: str) -> None: ...
4✔
1475
    @overload
4✔
1476
    async def sound_play(self, filename: str, *, blocking: Literal[False]) -> AsyncFutureResult[None]: ...
4✔
1477
    @overload
4✔
1478
    async def sound_play(self, filename: str, *, blocking: Literal[True]) -> None: ...
4✔
1479
    @overload
4✔
1480
    async def sound_play(self, filename: str, *, blocking: bool = True) -> Union[None, AsyncFutureResult[None]]: ...
4✔
1481
    # fmt: on
1482
    async def sound_play(self, filename: str, *, blocking: bool = True) -> Union[None, AsyncFutureResult[None]]:
4✔
1483
        """
1484
        Analog for `SoundPlay <https://www.autohotkey.com/docs/commands/SoundPlay.htm>`_
1485
        """
1486
        return await self._transport.function_call('AHKSoundPlay', [filename], blocking=blocking)
×
1487

1488
    async def sound_set(
4✔
1489
        self,
1490
        value: Union[str, int, float],
1491
        device_number: int = 1,
1492
        component_type: str = 'MASTER',
1493
        control_type: str = 'VOLUME',
1494
        *,
1495
        blocking: bool = True,
1496
    ) -> Union[None, AsyncFutureResult[None]]:
1497
        """
1498
        Analog for `SoundSet <https://www.autohotkey.com/docs/commands/SoundSet.htm>`_
1499
        """
1500
        args = [str(device_number), component_type, control_type, str(value)]
×
1501
        return await self._transport.function_call('AHKSoundSet', args, blocking=blocking)
×
1502

1503
    # fmt: off
1504
    @overload
4✔
1505
    async def win_get(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None) -> Union[AsyncWindow, None]: ...
4✔
1506
    @overload
4✔
1507
    async def win_get(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: Literal[False]) -> AsyncFutureResult[Union[AsyncWindow, None]]: ...
4✔
1508
    @overload
4✔
1509
    async def win_get(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: Literal[True]) -> Union[AsyncWindow, None]: ...
4✔
1510
    @overload
4✔
1511
    async def win_get(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: bool = True) -> Union[AsyncWindow, None, AsyncFutureResult[Union[None, AsyncWindow]]]: ...
4✔
1512
    # fmt: on
1513
    async def win_get(
4✔
1514
        self,
1515
        title: str = '',
1516
        text: str = '',
1517
        exclude_title: str = '',
1518
        exclude_text: str = '',
1519
        *,
1520
        title_match_mode: Optional[TitleMatchMode] = None,
1521
        detect_hidden_windows: Optional[bool] = None,
1522
        blocking: bool = True,
1523
    ) -> Union[AsyncWindow, None, AsyncFutureResult[Union[None, AsyncWindow]]]:
1524
        """
1525
        Analog for `WinGet <https://www.autohotkey.com/docs/commands/WinGet.htm>`_
1526
        """
1527
        args = self._format_win_args(
4✔
1528
            title=title,
1529
            text=text,
1530
            exclude_title=exclude_title,
1531
            exclude_text=exclude_text,
1532
            title_match_mode=title_match_mode,
1533
            detect_hidden_windows=detect_hidden_windows,
1534
        )
1535
        resp = await self._transport.function_call('AHKWinGetID', args, blocking=blocking, engine=self)
4✔
1536
        return resp
4✔
1537

1538
    # fmt: off
1539
    @overload
4✔
1540
    async def win_get_text(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None) -> str: ...
4✔
1541
    @overload
4✔
1542
    async def win_get_text(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: Literal[False]) -> AsyncFutureResult[str]: ...
4✔
1543
    @overload
4✔
1544
    async def win_get_text(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: Literal[True]) -> str: ...
4✔
1545
    @overload
4✔
1546
    async def win_get_text(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: bool = True) -> Union[str, AsyncFutureResult[str]]: ...
4✔
1547
    # fmt: on
1548
    async def win_get_text(
4✔
1549
        self,
1550
        title: str = '',
1551
        text: str = '',
1552
        exclude_title: str = '',
1553
        exclude_text: str = '',
1554
        *,
1555
        title_match_mode: Optional[TitleMatchMode] = None,
1556
        detect_hidden_windows: Optional[bool] = None,
1557
        blocking: bool = True,
1558
    ) -> Union[str, AsyncFutureResult[str]]:
1559
        args = self._format_win_args(
4✔
1560
            title=title,
1561
            text=text,
1562
            exclude_title=exclude_title,
1563
            exclude_text=exclude_text,
1564
            title_match_mode=title_match_mode,
1565
            detect_hidden_windows=detect_hidden_windows,
1566
        )
1567
        resp = await self._transport.function_call('AHKWinGetText', args, blocking=blocking)
4✔
1568
        return resp
4✔
1569

1570
    # fmt: off
1571
    @overload
4✔
1572
    async def win_get_title(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None) -> str: ...
4✔
1573
    @overload
4✔
1574
    async def win_get_title(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: Literal[False]) -> AsyncFutureResult[str]: ...
4✔
1575
    @overload
4✔
1576
    async def win_get_title(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: Literal[True]) -> str: ...
4✔
1577
    @overload
4✔
1578
    async def win_get_title(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: bool = True) -> Union[str, AsyncFutureResult[str]]: ...
4✔
1579
    # fmt: on
1580
    async def win_get_title(
4✔
1581
        self,
1582
        title: str = '',
1583
        text: str = '',
1584
        exclude_title: str = '',
1585
        exclude_text: str = '',
1586
        *,
1587
        title_match_mode: Optional[TitleMatchMode] = None,
1588
        detect_hidden_windows: Optional[bool] = None,
1589
        blocking: bool = True,
1590
    ) -> Union[str, AsyncFutureResult[str]]:
1591
        args = self._format_win_args(
4✔
1592
            title=title,
1593
            text=text,
1594
            exclude_title=exclude_title,
1595
            exclude_text=exclude_text,
1596
            title_match_mode=title_match_mode,
1597
            detect_hidden_windows=detect_hidden_windows,
1598
        )
1599
        resp = await self._transport.function_call('AHKWinGetTitle', args, blocking=blocking)
4✔
1600
        return resp
4✔
1601

1602
    # fmt: off
1603
    @overload
4✔
1604
    async def win_get_class(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None) -> str: ...
4✔
1605
    @overload
4✔
1606
    async def win_get_class(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: Literal[False]) -> AsyncFutureResult[str]: ...
4✔
1607
    @overload
4✔
1608
    async def win_get_class(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: Literal[True]) -> str: ...
4✔
1609
    @overload
4✔
1610
    async def win_get_class(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: bool = True) -> Union[str, AsyncFutureResult[str]]: ...
4✔
1611
    # fmt: on
1612
    async def win_get_class(
4✔
1613
        self,
1614
        title: str = '',
1615
        text: str = '',
1616
        exclude_title: str = '',
1617
        exclude_text: str = '',
1618
        *,
1619
        title_match_mode: Optional[TitleMatchMode] = None,
1620
        detect_hidden_windows: Optional[bool] = None,
1621
        blocking: bool = True,
1622
    ) -> Union[str, AsyncFutureResult[str]]:
1623
        """
1624
        Analog for `WinGetClass <https://www.autohotkey.com/docs/commands/WinGetClass.htm>`_
1625
        """
1626
        args = self._format_win_args(
4✔
1627
            title=title,
1628
            text=text,
1629
            exclude_title=exclude_title,
1630
            exclude_text=exclude_text,
1631
            title_match_mode=title_match_mode,
1632
            detect_hidden_windows=detect_hidden_windows,
1633
        )
1634
        resp = await self._transport.function_call('AHKWinGetClass', args, blocking=blocking)
4✔
1635
        return resp
4✔
1636

1637
    # fmt: off
1638
    @overload
4✔
1639
    async def win_get_position(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None) -> Union[Position, None]: ...
4✔
1640
    @overload
4✔
1641
    async def win_get_position(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: Literal[False]) -> AsyncFutureResult[Union[Position, None]]: ...
4✔
1642
    @overload
4✔
1643
    async def win_get_position(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: Literal[True]) -> Union[Position, None]: ...
4✔
1644
    @overload
4✔
1645
    async def win_get_position(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: bool = True) -> Union[Position, None, AsyncFutureResult[Union[Position, None]]]: ...
4✔
1646
    # fmt: on
1647
    async def win_get_position(
4✔
1648
        self,
1649
        title: str = '',
1650
        text: str = '',
1651
        exclude_title: str = '',
1652
        exclude_text: str = '',
1653
        *,
1654
        title_match_mode: Optional[TitleMatchMode] = None,
1655
        detect_hidden_windows: Optional[bool] = None,
1656
        blocking: bool = True,
1657
    ) -> Union[Position, None, AsyncFutureResult[Union[Position, None]]]:
1658
        """
1659
        Analog for `WinGetPos <https://www.autohotkey.com/docs/commands/WinGetPos.htm>`_
1660
        """
1661
        args = self._format_win_args(
4✔
1662
            title=title,
1663
            text=text,
1664
            exclude_title=exclude_title,
1665
            exclude_text=exclude_text,
1666
            title_match_mode=title_match_mode,
1667
            detect_hidden_windows=detect_hidden_windows,
1668
        )
1669
        resp = await self._transport.function_call('AHKWinGetPos', args, blocking=blocking, engine=self)
4✔
1670
        return resp
4✔
1671

1672
    # fmt: off
1673
    @overload
4✔
1674
    async def win_get_idlast(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None) -> Union[AsyncWindow, None]: ...
4✔
1675
    @overload
4✔
1676
    async def win_get_idlast(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: Literal[False]) -> AsyncFutureResult[Union[AsyncWindow, None]]: ...
4✔
1677
    @overload
4✔
1678
    async def win_get_idlast(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: Literal[True]) -> Union[AsyncWindow, None]: ...
4✔
1679
    @overload
4✔
1680
    async def win_get_idlast(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: bool = True) -> Union[AsyncWindow, None, AsyncFutureResult[Union[AsyncWindow, None]]]: ...
4✔
1681
    # fmt: on
1682
    async def win_get_idlast(
4✔
1683
        self,
1684
        title: str = '',
1685
        text: str = '',
1686
        exclude_title: str = '',
1687
        exclude_text: str = '',
1688
        *,
1689
        title_match_mode: Optional[TitleMatchMode] = None,
1690
        detect_hidden_windows: Optional[bool] = None,
1691
        blocking: bool = True,
1692
    ) -> Union[AsyncWindow, None, AsyncFutureResult[Union[AsyncWindow, None]]]:
1693
        """
1694
        Like the IDLast subcommand for WinGet
1695
        """
1696
        args = self._format_win_args(
4✔
1697
            title=title,
1698
            text=text,
1699
            exclude_title=exclude_title,
1700
            exclude_text=exclude_text,
1701
            title_match_mode=title_match_mode,
1702
            detect_hidden_windows=detect_hidden_windows,
1703
        )
1704
        resp = await self._transport.function_call('AHKWinGetIDLast', args, blocking=blocking, engine=self)
4✔
1705
        return resp
4✔
1706

1707
    # fmt: off
1708
    @overload
4✔
1709
    async def win_get_pid(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None) -> Union[int, None]: ...
4✔
1710
    @overload
4✔
1711
    async def win_get_pid(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: Literal[False]) -> AsyncFutureResult[Union[int, None]]: ...
4✔
1712
    @overload
4✔
1713
    async def win_get_pid(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: Literal[True]) -> Union[int, None]: ...
4✔
1714
    @overload
4✔
1715
    async def win_get_pid(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: bool = True) -> Union[int, None, AsyncFutureResult[Union[int, None]]]: ...
4✔
1716
    # fmt: on
1717
    async def win_get_pid(
4✔
1718
        self,
1719
        title: str = '',
1720
        text: str = '',
1721
        exclude_title: str = '',
1722
        exclude_text: str = '',
1723
        *,
1724
        title_match_mode: Optional[TitleMatchMode] = None,
1725
        detect_hidden_windows: Optional[bool] = None,
1726
        blocking: bool = True,
1727
    ) -> Union[int, None, AsyncFutureResult[Union[int, None]]]:
1728
        """
1729
        Get a window by process ID.
1730

1731
        Like the pid subcommand for WinGet
1732
        """
1733
        args = self._format_win_args(
4✔
1734
            title=title,
1735
            text=text,
1736
            exclude_title=exclude_title,
1737
            exclude_text=exclude_text,
1738
            title_match_mode=title_match_mode,
1739
            detect_hidden_windows=detect_hidden_windows,
1740
        )
1741
        resp = await self._transport.function_call('AHKWinGetPID', args, blocking=blocking)
4✔
1742
        return resp
4✔
1743

1744
    # fmt: off
1745
    @overload
4✔
1746
    async def win_get_process_name(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None) -> Union[str, None]: ...
4✔
1747
    @overload
4✔
1748
    async def win_get_process_name(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: Literal[False]) -> AsyncFutureResult[Union[str, None]]: ...
4✔
1749
    @overload
4✔
1750
    async def win_get_process_name(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: Literal[True]) -> Union[str, None]: ...
4✔
1751
    @overload
4✔
1752
    async def win_get_process_name(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: bool = True) -> Union[None, str, AsyncFutureResult[Optional[str]]]: ...
4✔
1753
    # fmt: on
1754
    async def win_get_process_name(
4✔
1755
        self,
1756
        title: str = '',
1757
        text: str = '',
1758
        exclude_title: str = '',
1759
        exclude_text: str = '',
1760
        *,
1761
        title_match_mode: Optional[TitleMatchMode] = None,
1762
        detect_hidden_windows: Optional[bool] = None,
1763
        blocking: bool = True,
1764
    ) -> Union[None, str, AsyncFutureResult[Optional[str]]]:
1765
        """
1766
        Get the process name of a window
1767

1768
        Analog for `ProcessName subcommand for WinGet <https://www.autohotkey.com/docs/v1/lib/WinGet.htm#ProcessName>`_
1769
        """
1770
        args = self._format_win_args(
4✔
1771
            title=title,
1772
            text=text,
1773
            exclude_title=exclude_title,
1774
            exclude_text=exclude_text,
1775
            title_match_mode=title_match_mode,
1776
            detect_hidden_windows=detect_hidden_windows,
1777
        )
1778
        resp = await self._transport.function_call('AHKWinGetProcessName', args, blocking=blocking)
4✔
1779
        return resp
4✔
1780

1781
    # fmt: off
1782
    @overload
4✔
1783
    async def win_get_process_path(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None) -> Union[str, None]: ...
4✔
1784
    @overload
4✔
1785
    async def win_get_process_path(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: Literal[False]) -> AsyncFutureResult[Union[str, None]]: ...
4✔
1786
    @overload
4✔
1787
    async def win_get_process_path(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: Literal[True]) -> Union[str, None]: ...
4✔
1788
    @overload
4✔
1789
    async def win_get_process_path(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: bool = True) -> Union[str, None, Union[None, str, AsyncFutureResult[Optional[str]]]]: ...
4✔
1790
    # fmt: on
1791
    async def win_get_process_path(
4✔
1792
        self,
1793
        title: str = '',
1794
        text: str = '',
1795
        exclude_title: str = '',
1796
        exclude_text: str = '',
1797
        *,
1798
        title_match_mode: Optional[TitleMatchMode] = None,
1799
        detect_hidden_windows: Optional[bool] = None,
1800
        blocking: bool = True,
1801
    ) -> Union[str, None, Union[None, str, AsyncFutureResult[Optional[str]]]]:
1802
        """
1803
        Get the process path for a window.
1804

1805
        Analog for the `ProcessPath subcommand for WinGet <https://www.autohotkey.com/docs/v1/lib/WinGet.htm#ProcessPath>`_
1806
        """
1807
        args = self._format_win_args(
4✔
1808
            title=title,
1809
            text=text,
1810
            exclude_title=exclude_title,
1811
            exclude_text=exclude_text,
1812
            title_match_mode=title_match_mode,
1813
            detect_hidden_windows=detect_hidden_windows,
1814
        )
1815
        resp = await self._transport.function_call('AHKWinGetProcessPath', args, blocking=blocking)
4✔
1816
        return resp
4✔
1817

1818
    # fmt: off
1819
    @overload
4✔
1820
    async def win_get_count(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None) -> int: ...
4✔
1821
    @overload
4✔
1822
    async def win_get_count(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: Literal[False]) -> AsyncFutureResult[int]: ...
4✔
1823
    @overload
4✔
1824
    async def win_get_count(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: Literal[True]) -> int: ...
4✔
1825
    @overload
4✔
1826
    async def win_get_count(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: bool = True) -> Union[int, AsyncFutureResult[int]]: ...
4✔
1827
    # fmt: on
1828
    async def win_get_count(
4✔
1829
        self,
1830
        title: str = '',
1831
        text: str = '',
1832
        exclude_title: str = '',
1833
        exclude_text: str = '',
1834
        *,
1835
        title_match_mode: Optional[TitleMatchMode] = None,
1836
        detect_hidden_windows: Optional[bool] = None,
1837
        blocking: bool = True,
1838
    ) -> Union[int, AsyncFutureResult[int]]:
1839
        """
1840
        Analog for the `Count subcommand for WinGet <https://www.autohotkey.com/docs/v1/lib/WinGet.htm#Count>`_
1841
        """
1842
        args = self._format_win_args(
4✔
1843
            title=title,
1844
            text=text,
1845
            exclude_title=exclude_title,
1846
            exclude_text=exclude_text,
1847
            title_match_mode=title_match_mode,
1848
            detect_hidden_windows=detect_hidden_windows,
1849
        )
1850
        resp = await self._transport.function_call('AHKWinGetCount', args, blocking=blocking)
4✔
1851
        return resp
4✔
1852

1853
    # fmt: off
1854
    @overload
4✔
1855
    async def win_get_minmax(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None) -> Union[int, None]: ...
4✔
1856
    @overload
4✔
1857
    async def win_get_minmax(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: Literal[False]) -> AsyncFutureResult[Union[int, None]]: ...
4✔
1858
    @overload
4✔
1859
    async def win_get_minmax(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: Literal[True]) -> Union[int, None]: ...
4✔
1860
    @overload
4✔
1861
    async def win_get_minmax(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: bool = True) -> Union[None, int, AsyncFutureResult[Optional[int]]]: ...
4✔
1862
    # fmt: on
1863
    async def win_get_minmax(
4✔
1864
        self,
1865
        title: str = '',
1866
        text: str = '',
1867
        exclude_title: str = '',
1868
        exclude_text: str = '',
1869
        *,
1870
        title_match_mode: Optional[TitleMatchMode] = None,
1871
        detect_hidden_windows: Optional[bool] = None,
1872
        blocking: bool = True,
1873
    ) -> Union[None, int, AsyncFutureResult[Optional[int]]]:
1874
        """
1875
        Analog for the `MinMax subcommand for WinGet <https://www.autohotkey.com/docs/v1/lib/WinGet.htm#MinMax>`_
1876
        """
1877
        args = self._format_win_args(
4✔
1878
            title=title,
1879
            text=text,
1880
            exclude_title=exclude_title,
1881
            exclude_text=exclude_text,
1882
            title_match_mode=title_match_mode,
1883
            detect_hidden_windows=detect_hidden_windows,
1884
        )
1885
        resp = await self._transport.function_call('AHKWinGetMinMax', args, blocking=blocking)
4✔
1886
        return resp
4✔
1887

1888
    # fmt: off
1889
    @overload
4✔
1890
    async def win_get_control_list(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None) -> Union[List[AsyncControl], None]: ...
4✔
1891
    @overload
4✔
1892
    async def win_get_control_list(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: Literal[False]) -> AsyncFutureResult[Union[List[AsyncControl], None]]: ...
4✔
1893
    @overload
4✔
1894
    async def win_get_control_list(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: Literal[True]) -> Union[List[AsyncControl], None]: ...
4✔
1895
    @overload
4✔
1896
    async def win_get_control_list(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: bool = True) -> Union[List[AsyncControl], None, AsyncFutureResult[Optional[List[AsyncControl]]]]: ...
4✔
1897
    # fmt: on
1898
    async def win_get_control_list(
4✔
1899
        self,
1900
        title: str = '',
1901
        text: str = '',
1902
        exclude_title: str = '',
1903
        exclude_text: str = '',
1904
        *,
1905
        title_match_mode: Optional[TitleMatchMode] = None,
1906
        detect_hidden_windows: Optional[bool] = None,
1907
        blocking: bool = True,
1908
    ) -> Union[List[AsyncControl], None, AsyncFutureResult[Optional[List[AsyncControl]]]]:
1909
        """
1910
        Analog for the `ControlList subcommand for WinGet <https://www.autohotkey.com/docs/v1/lib/WinGet.htm#ControlList>`_
1911
        """
1912
        args = self._format_win_args(
4✔
1913
            title=title,
1914
            text=text,
1915
            exclude_title=exclude_title,
1916
            exclude_text=exclude_text,
1917
            title_match_mode=title_match_mode,
1918
            detect_hidden_windows=detect_hidden_windows,
1919
        )
1920
        resp = await self._transport.function_call('AHKWinGetControlList', args, blocking=blocking, engine=self)
4✔
1921
        return resp
4✔
1922

1923
    # fmt: off
1924
    @overload
4✔
1925
    async def win_get_from_mouse_position(self) -> Union[AsyncWindow, None]: ...
4✔
1926
    @overload
4✔
1927
    async def win_get_from_mouse_position(self, *, blocking: Literal[False]) -> AsyncFutureResult[Union[AsyncWindow, None]]: ...
4✔
1928
    @overload
4✔
1929
    async def win_get_from_mouse_position(self, *, blocking: Literal[True]) -> Union[AsyncWindow, None]: ...
4✔
1930
    @overload
4✔
1931
    async def win_get_from_mouse_position(self, *, blocking: bool = True) -> Union[Optional[AsyncWindow], AsyncFutureResult[Optional[AsyncWindow]]]: ...
4✔
1932
    # fmt: on
1933
    async def win_get_from_mouse_position(
4✔
1934
        self, *, blocking: bool = True
1935
    ) -> Union[Optional[AsyncWindow], AsyncFutureResult[Optional[AsyncWindow]]]:
1936
        resp = await self._transport.function_call('AHKWinFromMouse', blocking=blocking, engine=self)
×
1937
        return resp
×
1938

1939
    # fmt: off
1940
    @overload
4✔
1941
    async def win_exists(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None) -> bool: ...
4✔
1942
    @overload
4✔
1943
    async def win_exists(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: Literal[False]) -> AsyncFutureResult[bool]: ...
4✔
1944
    @overload
4✔
1945
    async def win_exists(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: Literal[True]) -> bool: ...
4✔
1946
    @overload
4✔
1947
    async def win_exists(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: bool = True) -> Union[bool, AsyncFutureResult[bool]]: ...
4✔
1948
    # fmt: on
1949
    async def win_exists(
4✔
1950
        self,
1951
        title: str = '',
1952
        text: str = '',
1953
        exclude_title: str = '',
1954
        exclude_text: str = '',
1955
        *,
1956
        title_match_mode: Optional[TitleMatchMode] = None,
1957
        detect_hidden_windows: Optional[bool] = None,
1958
        blocking: bool = True,
1959
    ) -> Union[bool, AsyncFutureResult[bool]]:
1960
        args = self._format_win_args(
4✔
1961
            title=title,
1962
            text=text,
1963
            exclude_title=exclude_title,
1964
            exclude_text=exclude_text,
1965
            title_match_mode=title_match_mode,
1966
            detect_hidden_windows=detect_hidden_windows,
1967
        )
1968
        resp = await self._transport.function_call('AHKWinExist', args, blocking=blocking)
4✔
1969
        return resp
4✔
1970

1971
    # fmt: off
1972
    @overload
4✔
1973
    async def win_activate(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None) -> None: ...
4✔
1974
    @overload
4✔
1975
    async def win_activate(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: Literal[False]) -> AsyncFutureResult[None]: ...
4✔
1976
    @overload
4✔
1977
    async def win_activate(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: Literal[True]) -> None: ...
4✔
1978
    @overload
4✔
1979
    async def win_activate(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: bool = True) -> Union[None, AsyncFutureResult[None]]: ...
4✔
1980
    # fmt: on
1981
    async def win_activate(
4✔
1982
        self,
1983
        title: str = '',
1984
        text: str = '',
1985
        exclude_title: str = '',
1986
        exclude_text: str = '',
1987
        *,
1988
        title_match_mode: Optional[TitleMatchMode] = None,
1989
        detect_hidden_windows: Optional[bool] = None,
1990
        blocking: bool = True,
1991
    ) -> Union[None, AsyncFutureResult[None]]:
1992
        """
1993
        Analog for `WinActivate <https://www.autohotkey.com/docs/commands/WinActivate.htm>`_
1994
        """
1995
        args = self._format_win_args(
4✔
1996
            title=title,
1997
            text=text,
1998
            exclude_title=exclude_title,
1999
            exclude_text=exclude_text,
2000
            title_match_mode=title_match_mode,
2001
            detect_hidden_windows=detect_hidden_windows,
2002
        )
2003
        resp = await self._transport.function_call('AHKWinActivate', args, blocking=blocking)
4✔
2004
        return resp
4✔
2005

2006
    # fmt: off
2007
    @overload
4✔
2008
    async def win_set_title(self, new_title: str, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None) -> None: ...
4✔
2009
    @overload
4✔
2010
    async def win_set_title(self, new_title: str, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: Literal[True]) -> None: ...
4✔
2011
    @overload
4✔
2012
    async def win_set_title(self, new_title: str, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: Literal[False]) -> AsyncFutureResult[None]: ...
4✔
2013
    @overload
4✔
2014
    async def win_set_title(self, new_title: str, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: bool = True) -> Union[None, AsyncFutureResult[None]]: ...
4✔
2015
    # fmt: on
2016
    async def win_set_title(
4✔
2017
        self,
2018
        new_title: str,
2019
        title: str = '',
2020
        text: str = '',
2021
        exclude_title: str = '',
2022
        exclude_text: str = '',
2023
        *,
2024
        title_match_mode: Optional[TitleMatchMode] = None,
2025
        detect_hidden_windows: Optional[bool] = None,
2026
        blocking: bool = True,
2027
    ) -> Union[None, AsyncFutureResult[None]]:
2028
        """
2029
        Analog for `WinSetTitle <https://www.autohotkey.com/docs/commands/WinSetTitle.htm>`_
2030
        """
2031
        args = [new_title, title, text, exclude_title, exclude_text]
4✔
2032
        if detect_hidden_windows is not None:
4✔
2033
            if detect_hidden_windows is True:
4✔
2034
                args.append('On')
4✔
2035
            elif detect_hidden_windows is False:
×
2036
                args.append('Off')
×
2037
            else:
2038
                raise TypeError(
×
2039
                    f'Invalid value for parameter detect_hidden_windows. Expected boolean or None, got {detect_hidden_windows!r}'
2040
                )
2041
        else:
2042
            args.append('')
×
2043
        if title_match_mode is not None:
4✔
2044
            if isinstance(title_match_mode, tuple):
4✔
2045
                match_mode, match_speed = title_match_mode
4✔
2046
            elif title_match_mode in (1, 2, 3, 'RegEx'):
×
2047
                match_mode = title_match_mode
×
2048
                match_speed = ''
×
2049
            elif title_match_mode in ('Fast', 'Slow'):
×
2050
                match_mode = ''
×
2051
                match_speed = title_match_mode
×
2052
            else:
2053
                raise ValueError(
×
2054
                    f"Invalid value for title_match_mode argument. Expected 1, 2, 3, 'RegEx', 'Fast', 'Slow' or a tuple of these. Got {title_match_mode!r}"
2055
                )
2056
            args.append(str(match_mode))
4✔
2057
            args.append(str(match_speed))
4✔
2058
        else:
2059
            args.append('')
×
2060
            args.append('')
×
2061
        resp = await self._transport.function_call('AHKWinSetTitle', args, blocking=blocking)
4✔
2062
        return resp
4✔
2063

2064
    # fmt: off
2065
    @overload
4✔
2066
    async def win_set_always_on_top(self, toggle: Literal['On', 'Off', 'Toggle', 1, -1, 0], title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None) -> None: ...
4✔
2067
    @overload
4✔
2068
    async def win_set_always_on_top(self, toggle: Literal['On', 'Off', 'Toggle', 1, -1, 0], title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: Literal[False]) -> AsyncFutureResult[None]: ...
4✔
2069
    @overload
4✔
2070
    async def win_set_always_on_top(self, toggle: Literal['On', 'Off', 'Toggle', 1, -1, 0], title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: Literal[True]) -> None: ...
4✔
2071
    @overload
4✔
2072
    async def win_set_always_on_top(self, toggle: Literal['On', 'Off', 'Toggle', 1, -1, 0], title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: bool = True) -> Union[None, AsyncFutureResult[None]]: ...
4✔
2073
    # fmt: on
2074
    async def win_set_always_on_top(
4✔
2075
        self,
2076
        toggle: Literal['On', 'Off', 'Toggle', 1, -1, 0],
2077
        title: str = '',
2078
        text: str = '',
2079
        exclude_title: str = '',
2080
        exclude_text: str = '',
2081
        *,
2082
        title_match_mode: Optional[TitleMatchMode] = None,
2083
        detect_hidden_windows: Optional[bool] = None,
2084
        blocking: bool = True,
2085
    ) -> Union[None, AsyncFutureResult[None]]:
2086
        """
2087
        Analog for `AlwaysOnTop subcommand of WinSet <https://www.autohotkey.com/docs/v1/lib/WinSet.htm#AlwaysOnTop>`_
2088
        """
2089
        args = [str(toggle), title, text, exclude_title, exclude_text]
4✔
2090
        if detect_hidden_windows is not None:
4✔
2091
            if detect_hidden_windows is True:
4✔
2092
                args.append('On')
4✔
2093
            elif detect_hidden_windows is False:
×
2094
                args.append('Off')
×
2095
            else:
2096
                raise TypeError(
×
2097
                    f'Invalid value for parameter detect_hidden_windows. Expected boolean or None, got {detect_hidden_windows!r}'
2098
                )
2099
        else:
2100
            args.append('')
×
2101
        if title_match_mode is not None:
4✔
2102
            if isinstance(title_match_mode, tuple):
4✔
2103
                match_mode, match_speed = title_match_mode
4✔
2104
            elif title_match_mode in (1, 2, 3, 'RegEx'):
×
2105
                match_mode = title_match_mode
×
2106
                match_speed = ''
×
2107
            elif title_match_mode in ('Fast', 'Slow'):
×
2108
                match_mode = ''
×
2109
                match_speed = title_match_mode
×
2110
            else:
2111
                raise ValueError(
×
2112
                    f"Invalid value for title_match_mode argument. Expected 1, 2, 3, 'RegEx', 'Fast', 'Slow' or a tuple of these. Got {title_match_mode!r}"
2113
                )
2114
            args.append(str(match_mode))
4✔
2115
            args.append(str(match_speed))
4✔
2116
        else:
2117
            args.append('')
×
2118
            args.append('')
×
2119
        resp = await self._transport.function_call('AHKWinSetAlwaysOnTop', args, blocking=blocking)
4✔
2120
        return resp
4✔
2121

2122
    # fmt: off
2123
    @overload
4✔
2124
    async def win_set_bottom(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None) -> None: ...
4✔
2125
    @overload
4✔
2126
    async def win_set_bottom(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: Literal[False]) -> AsyncFutureResult[None]: ...
4✔
2127
    @overload
4✔
2128
    async def win_set_bottom(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: Literal[True]) -> None: ...
4✔
2129
    @overload
4✔
2130
    async def win_set_bottom(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: bool = True) -> Union[None, AsyncFutureResult[None]]: ...
4✔
2131
    # fmt: on
2132
    async def win_set_bottom(
4✔
2133
        self,
2134
        title: str = '',
2135
        text: str = '',
2136
        exclude_title: str = '',
2137
        exclude_text: str = '',
2138
        *,
2139
        title_match_mode: Optional[TitleMatchMode] = None,
2140
        detect_hidden_windows: Optional[bool] = None,
2141
        blocking: bool = True,
2142
    ) -> Union[None, AsyncFutureResult[None]]:
2143
        """
2144
        Analog for `Bottom subcommand of WinSet <https://www.autohotkey.com/docs/v1/lib/WinSet.htm#Bottom>`_
2145
        """
2146
        args = self._format_win_args(
4✔
2147
            title=title,
2148
            text=text,
2149
            exclude_title=exclude_title,
2150
            exclude_text=exclude_text,
2151
            title_match_mode=title_match_mode,
2152
            detect_hidden_windows=detect_hidden_windows,
2153
        )
2154
        resp = await self._transport.function_call('AHKWinSetBottom', args, blocking=blocking)
4✔
2155
        return resp
4✔
2156

2157
    # fmt: off
2158
    @overload
4✔
2159
    async def win_set_top(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None) -> None: ...
4✔
2160
    @overload
4✔
2161
    async def win_set_top(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: Literal[False]) -> AsyncFutureResult[None]: ...
4✔
2162
    @overload
4✔
2163
    async def win_set_top(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: Literal[True]) -> None: ...
4✔
2164
    @overload
4✔
2165
    async def win_set_top(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: bool = True) -> Union[None, AsyncFutureResult[None]]: ...
4✔
2166
    # fmt: on
2167
    async def win_set_top(
4✔
2168
        self,
2169
        title: str = '',
2170
        text: str = '',
2171
        exclude_title: str = '',
2172
        exclude_text: str = '',
2173
        *,
2174
        title_match_mode: Optional[TitleMatchMode] = None,
2175
        detect_hidden_windows: Optional[bool] = None,
2176
        blocking: bool = True,
2177
    ) -> Union[None, AsyncFutureResult[None]]:
2178
        """
2179
        Analog for `Top subcommand of WinSet <https://www.autohotkey.com/docs/v1/lib/WinSet.htm#Top>`_
2180
        """
2181
        args = self._format_win_args(
×
2182
            title=title,
2183
            text=text,
2184
            exclude_title=exclude_title,
2185
            exclude_text=exclude_text,
2186
            title_match_mode=title_match_mode,
2187
            detect_hidden_windows=detect_hidden_windows,
2188
        )
2189
        resp = await self._transport.function_call('AHKWinSetTop', args, blocking=blocking)
×
2190
        return resp
×
2191

2192
    # fmt: off
2193
    @overload
4✔
2194
    async def win_set_disable(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None) -> None: ...
4✔
2195
    @overload
4✔
2196
    async def win_set_disable(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: Literal[False]) -> AsyncFutureResult[None]: ...
4✔
2197
    @overload
4✔
2198
    async def win_set_disable(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: Literal[True]) -> None: ...
4✔
2199
    @overload
4✔
2200
    async def win_set_disable(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: bool = True) -> Union[None, AsyncFutureResult[None]]: ...
4✔
2201
    # fmt: on
2202
    async def win_set_disable(
4✔
2203
        self,
2204
        title: str = '',
2205
        text: str = '',
2206
        exclude_title: str = '',
2207
        exclude_text: str = '',
2208
        *,
2209
        title_match_mode: Optional[TitleMatchMode] = None,
2210
        detect_hidden_windows: Optional[bool] = None,
2211
        blocking: bool = True,
2212
    ) -> Union[None, AsyncFutureResult[None]]:
2213
        """
2214
        Analog for `Disable subcommand of WinSet <https://www.autohotkey.com/docs/v1/lib/WinSet.htm#Disable>`_
2215
        """
2216
        args = self._format_win_args(
×
2217
            title=title,
2218
            text=text,
2219
            exclude_title=exclude_title,
2220
            exclude_text=exclude_text,
2221
            title_match_mode=title_match_mode,
2222
            detect_hidden_windows=detect_hidden_windows,
2223
        )
2224
        resp = await self._transport.function_call('AHKWinSetDisable', args, blocking=blocking)
×
2225
        return resp
×
2226

2227
    # fmt: off
2228
    @overload
4✔
2229
    async def win_set_enable(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None) -> None: ...
4✔
2230
    @overload
4✔
2231
    async def win_set_enable(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: Literal[False]) -> AsyncFutureResult[None]: ...
4✔
2232
    @overload
4✔
2233
    async def win_set_enable(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: Literal[True]) -> None: ...
4✔
2234
    @overload
4✔
2235
    async def win_set_enable(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: bool = True) -> Union[None, AsyncFutureResult[None]]: ...
4✔
2236
    # fmt: on
2237
    async def win_set_enable(
4✔
2238
        self,
2239
        title: str = '',
2240
        text: str = '',
2241
        exclude_title: str = '',
2242
        exclude_text: str = '',
2243
        *,
2244
        title_match_mode: Optional[TitleMatchMode] = None,
2245
        detect_hidden_windows: Optional[bool] = None,
2246
        blocking: bool = True,
2247
    ) -> Union[None, AsyncFutureResult[None]]:
2248
        """
2249
        Analog for `Enable subcommand of WinSet <https://www.autohotkey.com/docs/v1/lib/WinSet.htm#Enable>`_
2250
        """
2251
        args = self._format_win_args(
×
2252
            title=title,
2253
            text=text,
2254
            exclude_title=exclude_title,
2255
            exclude_text=exclude_text,
2256
            title_match_mode=title_match_mode,
2257
            detect_hidden_windows=detect_hidden_windows,
2258
        )
2259
        resp = await self._transport.function_call('AHKWinSetEnable', args, blocking=blocking)
×
2260
        return resp
×
2261

2262
    # fmt: off
2263
    @overload
4✔
2264
    async def win_set_redraw(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None) -> None: ...
4✔
2265
    @overload
4✔
2266
    async def win_set_redraw(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: Literal[False]) -> AsyncFutureResult[None]: ...
4✔
2267
    @overload
4✔
2268
    async def win_set_redraw(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: Literal[True]) -> None: ...
4✔
2269
    @overload
4✔
2270
    async def win_set_redraw(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: bool = True) -> Union[None, AsyncFutureResult[None]]: ...
4✔
2271
    # fmt: on
2272
    async def win_set_redraw(
4✔
2273
        self,
2274
        title: str = '',
2275
        text: str = '',
2276
        exclude_title: str = '',
2277
        exclude_text: str = '',
2278
        *,
2279
        title_match_mode: Optional[TitleMatchMode] = None,
2280
        detect_hidden_windows: Optional[bool] = None,
2281
        blocking: bool = True,
2282
    ) -> Union[None, AsyncFutureResult[None]]:
2283
        """
2284
        Analog for `Redraw subcommand of WinSet <https://www.autohotkey.com/docs/v1/lib/WinSet.htm#Redraw>`_
2285
        """
2286

2287
        args = self._format_win_args(
×
2288
            title=title,
2289
            text=text,
2290
            exclude_title=exclude_title,
2291
            exclude_text=exclude_text,
2292
            title_match_mode=title_match_mode,
2293
            detect_hidden_windows=detect_hidden_windows,
2294
        )
2295
        resp = await self._transport.function_call('AHKWinSetRedraw', args, blocking=blocking)
×
2296
        return resp
×
2297

2298
    # fmt: off
2299
    @overload
4✔
2300
    async def win_set_style(self, style: str, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None) -> bool: ...
4✔
2301
    @overload
4✔
2302
    async def win_set_style(self, style: str, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: Literal[False]) -> AsyncFutureResult[bool]: ...
4✔
2303
    @overload
4✔
2304
    async def win_set_style(self, style: str, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: Literal[True]) -> bool: ...
4✔
2305
    @overload
4✔
2306
    async def win_set_style(self, style: str, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: bool = True) -> Union[bool, AsyncFutureResult[bool]]: ...
4✔
2307
    # fmt: on
2308
    async def win_set_style(
4✔
2309
        self,
2310
        style: str,
2311
        title: str = '',
2312
        text: str = '',
2313
        exclude_title: str = '',
2314
        exclude_text: str = '',
2315
        *,
2316
        title_match_mode: Optional[TitleMatchMode] = None,
2317
        detect_hidden_windows: Optional[bool] = None,
2318
        blocking: bool = True,
2319
    ) -> Union[bool, AsyncFutureResult[bool]]:
2320
        """
2321
        Analog for `Style subcommand of WinSet <https://www.autohotkey.com/docs/v1/lib/WinSet.htm#Style>`_
2322
        """
2323

2324
        args = [style, title, text, exclude_title, exclude_text]
×
2325
        if detect_hidden_windows is not None:
×
2326
            if detect_hidden_windows is True:
×
2327
                args.append('On')
×
2328
            elif detect_hidden_windows is False:
×
2329
                args.append('Off')
×
2330
            else:
2331
                raise TypeError(
×
2332
                    f'Invalid value for parameter detect_hidden_windows. Expected boolean or None, got {detect_hidden_windows!r}'
2333
                )
2334
        else:
2335
            args.append('')
×
2336
        if title_match_mode is not None:
×
2337
            if isinstance(title_match_mode, tuple):
×
2338
                match_mode, match_speed = title_match_mode
×
2339
            elif title_match_mode in (1, 2, 3, 'RegEx'):
×
2340
                match_mode = title_match_mode
×
2341
                match_speed = ''
×
2342
            elif title_match_mode in ('Fast', 'Slow'):
×
2343
                match_mode = ''
×
2344
                match_speed = title_match_mode
×
2345
            else:
2346
                raise ValueError(
×
2347
                    f"Invalid value for title_match_mode argument. Expected 1, 2, 3, 'RegEx', 'Fast', 'Slow' or a tuple of these. Got {title_match_mode!r}"
2348
                )
2349
            args.append(str(match_mode))
×
2350
            args.append(str(match_speed))
×
2351
        else:
2352
            args.append('')
×
2353
            args.append('')
×
2354
        resp = await self._transport.function_call('AHKWinSetStyle', args, blocking=blocking)
×
2355
        return resp
×
2356

2357
    # fmt: off
2358
    @overload
4✔
2359
    async def win_set_ex_style(self, style: str, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None) -> bool: ...
4✔
2360
    @overload
4✔
2361
    async def win_set_ex_style(self, style: str, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: Literal[False]) -> AsyncFutureResult[bool]: ...
4✔
2362
    @overload
4✔
2363
    async def win_set_ex_style(self, style: str, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: Literal[True]) -> bool: ...
4✔
2364
    @overload
4✔
2365
    async def win_set_ex_style(self, style: str, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: bool = True) -> Union[bool, AsyncFutureResult[bool]]: ...
4✔
2366
    # fmt: on
2367
    async def win_set_ex_style(
4✔
2368
        self,
2369
        style: str,
2370
        title: str = '',
2371
        text: str = '',
2372
        exclude_title: str = '',
2373
        exclude_text: str = '',
2374
        *,
2375
        title_match_mode: Optional[TitleMatchMode] = None,
2376
        detect_hidden_windows: Optional[bool] = None,
2377
        blocking: bool = True,
2378
    ) -> Union[bool, AsyncFutureResult[bool]]:
2379
        """
2380
        Analog for `ExStyle subcommand of WinSet <https://www.autohotkey.com/docs/v1/lib/WinSet.htm#ExStyle>`_
2381
        """
2382
        args = [style, title, text, exclude_title, exclude_text]
×
2383
        if detect_hidden_windows is not None:
×
2384
            if detect_hidden_windows is True:
×
2385
                args.append('On')
×
2386
            elif detect_hidden_windows is False:
×
2387
                args.append('Off')
×
2388
            else:
2389
                raise TypeError(
×
2390
                    f'Invalid value for parameter detect_hidden_windows. Expected boolean or None, got {detect_hidden_windows!r}'
2391
                )
2392
        else:
2393
            args.append('')
×
2394
        if title_match_mode is not None:
×
2395
            if isinstance(title_match_mode, tuple):
×
2396
                match_mode, match_speed = title_match_mode
×
2397
            elif title_match_mode in (1, 2, 3, 'RegEx'):
×
2398
                match_mode = title_match_mode
×
2399
                match_speed = ''
×
2400
            elif title_match_mode in ('Fast', 'Slow'):
×
2401
                match_mode = ''
×
2402
                match_speed = title_match_mode
×
2403
            else:
2404
                raise ValueError(
×
2405
                    f"Invalid value for title_match_mode argument. Expected 1, 2, 3, 'RegEx', 'Fast', 'Slow' or a tuple of these. Got {title_match_mode!r}"
2406
                )
2407
            args.append(str(match_mode))
×
2408
            args.append(str(match_speed))
×
2409
        else:
2410
            args.append('')
×
2411
            args.append('')
×
2412
        resp = await self._transport.function_call('AHKWinSetExStyle', args, blocking=blocking)
×
2413
        return resp
×
2414

2415
    # fmt: off
2416
    @overload
4✔
2417
    async def win_set_region(self, options: str, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None) -> bool: ...
4✔
2418
    @overload
4✔
2419
    async def win_set_region(self, options: str, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: Literal[False]) -> AsyncFutureResult[bool]: ...
4✔
2420
    @overload
4✔
2421
    async def win_set_region(self, options: str, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: Literal[True]) -> bool: ...
4✔
2422
    @overload
4✔
2423
    async def win_set_region(self, options: str, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: bool = True) -> Union[bool, AsyncFutureResult[bool]]: ...
4✔
2424
    # fmt: on
2425
    async def win_set_region(
4✔
2426
        self,
2427
        options: str,
2428
        title: str = '',
2429
        text: str = '',
2430
        exclude_title: str = '',
2431
        exclude_text: str = '',
2432
        *,
2433
        title_match_mode: Optional[TitleMatchMode] = None,
2434
        detect_hidden_windows: Optional[bool] = None,
2435
        blocking: bool = True,
2436
    ) -> Union[bool, AsyncFutureResult[bool]]:
2437
        """
2438
        Analog for `Region subcommand of WinSet <https://www.autohotkey.com/docs/v1/lib/WinSet.htm#Region>`_
2439
        """
2440
        args = [options, title, text, exclude_title, exclude_text]
×
2441
        if detect_hidden_windows is not None:
×
2442
            if detect_hidden_windows is True:
×
2443
                args.append('On')
×
2444
            elif detect_hidden_windows is False:
×
2445
                args.append('Off')
×
2446
            else:
2447
                raise TypeError(
×
2448
                    f'Invalid value for parameter detect_hidden_windows. Expected boolean or None, got {detect_hidden_windows!r}'
2449
                )
2450
        else:
2451
            args.append('')
×
2452
        if title_match_mode is not None:
×
2453
            if isinstance(title_match_mode, tuple):
×
2454
                match_mode, match_speed = title_match_mode
×
2455
            elif title_match_mode in (1, 2, 3, 'RegEx'):
×
2456
                match_mode = title_match_mode
×
2457
                match_speed = ''
×
2458
            elif title_match_mode in ('Fast', 'Slow'):
×
2459
                match_mode = ''
×
2460
                match_speed = title_match_mode
×
2461
            else:
2462
                raise ValueError(
×
2463
                    f"Invalid value for title_match_mode argument. Expected 1, 2, 3, 'RegEx', 'Fast', 'Slow' or a tuple of these. Got {title_match_mode!r}"
2464
                )
2465
            args.append(str(match_mode))
×
2466
            args.append(str(match_speed))
×
2467
        else:
2468
            args.append('')
×
2469
            args.append('')
×
2470
        resp = await self._transport.function_call('AHKWinSetRegion', args, blocking=blocking)
×
2471
        return resp
×
2472

2473
    # fmt: off
2474
    @overload
4✔
2475
    async def win_set_transparent(self, transparency: Union[int, Literal['Off']], title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None) -> None: ...
4✔
2476
    @overload
4✔
2477
    async def win_set_transparent(self, transparency: Union[int, Literal['Off']], title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: Literal[False]) -> AsyncFutureResult[None]: ...
4✔
2478
    @overload
4✔
2479
    async def win_set_transparent(self, transparency: Union[int, Literal['Off']], title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: Literal[True]) -> None: ...
4✔
2480
    @overload
4✔
2481
    async def win_set_transparent(self, transparency: Union[int, Literal['Off']], title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: bool = True) -> Union[None, AsyncFutureResult[None]]: ...
4✔
2482
    # fmt: on
2483
    async def win_set_transparent(
4✔
2484
        self,
2485
        transparency: Union[int, Literal['Off']],
2486
        title: str = '',
2487
        text: str = '',
2488
        exclude_title: str = '',
2489
        exclude_text: str = '',
2490
        *,
2491
        title_match_mode: Optional[TitleMatchMode] = None,
2492
        detect_hidden_windows: Optional[bool] = None,
2493
        blocking: bool = True,
2494
    ) -> Union[None, AsyncFutureResult[None]]:
2495
        """
2496
        Analog for `Transparent subcommand of WinSet <https://www.autohotkey.com/docs/v1/lib/WinSet.htm#Transparent>`_
2497
        """
2498
        args = [str(transparency), title, text, exclude_title, exclude_text]
×
2499
        if detect_hidden_windows is not None:
×
2500
            if detect_hidden_windows is True:
×
2501
                args.append('On')
×
2502
            elif detect_hidden_windows is False:
×
2503
                args.append('Off')
×
2504
            else:
2505
                raise TypeError(
×
2506
                    f'Invalid value for parameter detect_hidden_windows. Expected boolean or None, got {detect_hidden_windows!r}'
2507
                )
2508
        else:
2509
            args.append('')
×
2510
        if title_match_mode is not None:
×
2511
            if isinstance(title_match_mode, tuple):
×
2512
                match_mode, match_speed = title_match_mode
×
2513
            elif title_match_mode in (1, 2, 3, 'RegEx'):
×
2514
                match_mode = title_match_mode
×
2515
                match_speed = ''
×
2516
            elif title_match_mode in ('Fast', 'Slow'):
×
2517
                match_mode = ''
×
2518
                match_speed = title_match_mode
×
2519
            else:
2520
                raise ValueError(
×
2521
                    f"Invalid value for title_match_mode argument. Expected 1, 2, 3, 'RegEx', 'Fast', 'Slow' or a tuple of these. Got {title_match_mode!r}"
2522
                )
2523
            args.append(str(match_mode))
×
2524
            args.append(str(match_speed))
×
2525
        else:
2526
            args.append('')
×
2527
            args.append('')
×
2528
        resp = await self._transport.function_call('AHKWinSetTransparent', args, blocking=blocking)
×
2529
        return resp
×
2530

2531
    # fmt: off
2532
    @overload
4✔
2533
    async def win_set_trans_color(self, color: Union[int, str], title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None) -> None: ...
4✔
2534
    @overload
4✔
2535
    async def win_set_trans_color(self, color: Union[int, str], title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: Literal[False]) -> AsyncFutureResult[None]: ...
4✔
2536
    @overload
4✔
2537
    async def win_set_trans_color(self, color: Union[int, str], title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: Literal[True]) -> None: ...
4✔
2538
    @overload
4✔
2539
    async def win_set_trans_color(self, color: Union[int, str], title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: bool = True) -> Union[None, AsyncFutureResult[None]]: ...
4✔
2540
    # fmt: on
2541
    async def win_set_trans_color(
4✔
2542
        self,
2543
        color: Union[int, str],
2544
        title: str = '',
2545
        text: str = '',
2546
        exclude_title: str = '',
2547
        exclude_text: str = '',
2548
        *,
2549
        title_match_mode: Optional[TitleMatchMode] = None,
2550
        detect_hidden_windows: Optional[bool] = None,
2551
        blocking: bool = True,
2552
    ) -> Union[None, AsyncFutureResult[None]]:
2553
        """
2554
        Analog for `TransColor subcommand of WinSet <https://www.autohotkey.com/docs/v1/lib/WinSet.htm#TransColor>`_
2555
        """
2556
        args = [str(color), title, text, exclude_title, exclude_text]
×
2557
        if detect_hidden_windows is not None:
×
2558
            if detect_hidden_windows is True:
×
2559
                args.append('On')
×
2560
            elif detect_hidden_windows is False:
×
2561
                args.append('Off')
×
2562
            else:
2563
                raise TypeError(
×
2564
                    f'Invalid value for parameter detect_hidden_windows. Expected boolean or None, got {detect_hidden_windows!r}'
2565
                )
2566
        else:
2567
            args.append('')
×
2568
        if title_match_mode is not None:
×
2569
            if isinstance(title_match_mode, tuple):
×
2570
                match_mode, match_speed = title_match_mode
×
2571
            elif title_match_mode in (1, 2, 3, 'RegEx'):
×
2572
                match_mode = title_match_mode
×
2573
                match_speed = ''
×
2574
            elif title_match_mode in ('Fast', 'Slow'):
×
2575
                match_mode = ''
×
2576
                match_speed = title_match_mode
×
2577
            else:
2578
                raise ValueError(
×
2579
                    f"Invalid value for title_match_mode argument. Expected 1, 2, 3, 'RegEx', 'Fast', 'Slow' or a tuple of these. Got {title_match_mode!r}"
2580
                )
2581
            args.append(str(match_mode))
×
2582
            args.append(str(match_speed))
×
2583
        else:
2584
            args.append('')
×
2585
            args.append('')
×
2586
        resp = await self._transport.function_call('AHKWinSetTransColor', args, blocking=blocking)
×
2587
        return resp
×
2588

2589
    # alias for backwards compatibility
2590
    windows = list_windows
4✔
2591

2592
    # fmt: off
2593
    @overload
4✔
2594
    async def right_click(self, x: Optional[Union[int, Tuple[int, int]]] = None, y: Optional[int] = None, click_count: Optional[int] = None, direction: Optional[Literal['U', 'D', 'Up', 'Down']] = None, *, relative: Optional[bool] = None, coord_mode: Optional[CoordModeRelativeTo] = None) -> None: ...
4✔
2595
    @overload
4✔
2596
    async def right_click(self, x: Optional[Union[int, Tuple[int, int]]] = None, y: Optional[int] = None, click_count: Optional[int] = None, direction: Optional[Literal['U', 'D', 'Up', 'Down']] = None, *, relative: Optional[bool] = None, blocking: Literal[True], coord_mode: Optional[CoordModeRelativeTo] = None) -> None: ...
4✔
2597
    @overload
4✔
2598
    async def right_click(self, x: Optional[Union[int, Tuple[int, int]]] = None, y: Optional[int] = None, click_count: Optional[int] = None, direction: Optional[Literal['U', 'D', 'Up', 'Down']] = None, *, relative: Optional[bool] = None, blocking: Literal[False], coord_mode: Optional[CoordModeRelativeTo] = None) -> AsyncFutureResult[None]: ...
4✔
2599
    @overload
4✔
2600
    async def right_click(self, x: Optional[Union[int, Tuple[int, int]]] = None, y: Optional[int] = None, click_count: Optional[int] = None, direction: Optional[Literal['U', 'D', 'Up', 'Down']] = None, *, relative: Optional[bool] = None, blocking: bool = True, coord_mode: Optional[CoordModeRelativeTo] = None) -> Union[None, AsyncFutureResult[None]]: ...
4✔
2601
    # fmt: on
2602
    async def right_click(
4✔
2603
        self,
2604
        x: Optional[Union[int, Tuple[int, int]]] = None,
2605
        y: Optional[int] = None,
2606
        click_count: Optional[int] = None,
2607
        direction: Optional[Literal['U', 'D', 'Up', 'Down']] = None,
2608
        *,
2609
        relative: Optional[bool] = None,
2610
        blocking: bool = True,
2611
        coord_mode: Optional[CoordModeRelativeTo] = None,
2612
    ) -> Union[None, AsyncFutureResult[None]]:
2613
        button = 'R'
×
2614
        return await self.click(
×
2615
            x,
2616
            y,
2617
            button=button,
2618
            click_count=click_count,
2619
            direction=direction,
2620
            relative=relative,
2621
            blocking=blocking,
2622
            coord_mode=coord_mode,
2623
        )
2624

2625
    # fmt: off
2626
    @overload
4✔
2627
    async def click(self, x: Optional[Union[int, Tuple[int, int]]] = None, y: Optional[int] = None, button: Optional[Union[MouseButton, str]] = None, click_count: Optional[int] = None, direction: Optional[Literal['U', 'D', 'Up', 'Down']] = None, *, relative: Optional[bool] = None, coord_mode: Optional[CoordModeRelativeTo] = None) -> None: ...
4✔
2628
    @overload
4✔
2629
    async def click(self, x: Optional[Union[int, Tuple[int, int]]] = None, y: Optional[int] = None, button: Optional[Union[MouseButton, str]] = None, click_count: Optional[int] = None, direction: Optional[Literal['U', 'D', 'Up', 'Down']] = None, *, relative: Optional[bool] = None, blocking: Literal[True], coord_mode: Optional[CoordModeRelativeTo] = None) -> None: ...
4✔
2630
    @overload
4✔
2631
    async def click(self, x: Optional[Union[int, Tuple[int, int]]] = None, y: Optional[int] = None, button: Optional[Union[MouseButton, str]] = None, click_count: Optional[int] = None, direction: Optional[Literal['U', 'D', 'Up', 'Down']] = None, *, relative: Optional[bool] = None, blocking: Literal[False], coord_mode: Optional[CoordModeRelativeTo] = None) -> AsyncFutureResult[None]: ...
4✔
2632
    @overload
4✔
2633
    async def click(self, x: Optional[Union[int, Tuple[int, int]]] = None, y: Optional[int] = None, button: Optional[Union[MouseButton, str]] = None, click_count: Optional[int] = None, direction: Optional[Literal['U', 'D', 'Up', 'Down']] = None, *, relative: Optional[bool] = None, blocking: bool = True, coord_mode: Optional[CoordModeRelativeTo] = None) -> Union[None, AsyncFutureResult[None]]: ...
4✔
2634
    # fmt: on
2635
    async def click(
4✔
2636
        self,
2637
        x: Optional[Union[int, Tuple[int, int]]] = None,
2638
        y: Optional[int] = None,
2639
        button: Optional[Union[MouseButton, str]] = None,
2640
        click_count: Optional[int] = None,
2641
        direction: Optional[Literal['U', 'D', 'Up', 'Down']] = None,
2642
        *,
2643
        relative: Optional[bool] = None,
2644
        blocking: bool = True,
2645
        coord_mode: Optional[CoordModeRelativeTo] = None,
2646
    ) -> Union[None, AsyncFutureResult[None]]:
2647
        """
2648
        Analog for `Click <https://www.autohotkey.com/docs/commands/Click.htm>`_
2649
        """
2650
        if x or y:
×
2651
            if y is None and isinstance(x, tuple) and len(x) == 2:
×
2652
                #  allow position to be specified by a two-sequence tuple
2653
                x, y = x
×
2654
            assert x is not None and y is not None, 'If provided, position must be specified by x AND y'
×
2655
        if button is None:
×
2656
            button = 'L'
×
2657
        button = _resolve_button(button)
×
2658

2659
        if relative:
×
2660
            r = 'Rel'
×
2661
        else:
2662
            r = ''
×
2663
        if coord_mode is None:
×
2664
            coord_mode = ''
×
2665
        args = [str(x), str(y), button, str(click_count), direction or '', r, coord_mode]
×
2666
        resp = await self._transport.function_call('AHKClick', args, blocking=blocking)
×
2667
        return resp
×
2668

2669
    # fmt: off
2670
    @overload
4✔
2671
    async def image_search(self, image_path: str, upper_bound: Tuple[Union[int, str], Union[int, str]] = (0, 0), lower_bound: Optional[Tuple[Union[int, str], Union[int, str]]] = None, *, color_variation: Optional[int] = None, coord_mode: Optional[CoordModeRelativeTo] = None, scale_height: Optional[int] = None, scale_width: Optional[int] = None, transparent: Optional[str] = None, icon: Optional[int] = None) -> Optional[Tuple[int, int]]: ...
4✔
2672
    @overload
4✔
2673
    async def image_search(self, image_path: str, upper_bound: Tuple[Union[int, str], Union[int, str]] = (0, 0), lower_bound: Optional[Tuple[Union[int, str], Union[int, str]]] = None, *, color_variation: Optional[int] = None, coord_mode: Optional[CoordModeRelativeTo] = None, scale_height: Optional[int] = None, scale_width: Optional[int] = None, transparent: Optional[str] = None, icon: Optional[int] = None, blocking: Literal[False]) -> AsyncFutureResult[Optional[Tuple[int, int]]]: ...
4✔
2674
    @overload
4✔
2675
    async def image_search(self, image_path: str, upper_bound: Tuple[Union[int, str], Union[int, str]] = (0, 0), lower_bound: Optional[Tuple[Union[int, str], Union[int, str]]] = None, *, color_variation: Optional[int] = None, coord_mode: Optional[CoordModeRelativeTo] = None, scale_height: Optional[int] = None, scale_width: Optional[int] = None, transparent: Optional[str] = None, icon: Optional[int] = None, blocking: Literal[True]) -> Optional[Tuple[int, int]]: ...
4✔
2676
    @overload
4✔
2677
    async def image_search(self, image_path: str, upper_bound: Tuple[Union[int, str], Union[int, str]] = (0, 0), lower_bound: Optional[Tuple[Union[int, str], Union[int, str]]] = None, *, color_variation: Optional[int] = None, coord_mode: Optional[CoordModeRelativeTo] = None, scale_height: Optional[int] = None, scale_width: Optional[int] = None, transparent: Optional[str] = None, icon: Optional[int] = None, blocking: bool = True) -> Union[Tuple[int, int], None, AsyncFutureResult[Optional[Tuple[int, int]]]]: ...
4✔
2678
    # fmt: on
2679
    async def image_search(
4✔
2680
        self,
2681
        image_path: str,
2682
        upper_bound: Tuple[Union[int, str], Union[int, str]] = (0, 0),
2683
        lower_bound: Optional[Tuple[Union[int, str], Union[int, str]]] = None,
2684
        *,
2685
        color_variation: Optional[int] = None,
2686
        coord_mode: Optional[CoordModeRelativeTo] = None,
2687
        scale_height: Optional[int] = None,
2688
        scale_width: Optional[int] = None,
2689
        transparent: Optional[str] = None,
2690
        icon: Optional[int] = None,
2691
        blocking: bool = True,
2692
    ) -> Union[Tuple[int, int], None, AsyncFutureResult[Optional[Tuple[int, int]]]]:
2693
        """
2694
        Analog for `ImageSearch <https://www.autohotkey.com/docs/commands/ImageSearch.htm>`_
2695
        """
2696

2697
        if scale_height and not scale_width:
×
2698
            scale_width = -1
×
2699
        elif scale_width and not scale_height:
×
2700
            scale_height = -1
×
2701

2702
        options: List[Union[str, int]] = []
×
2703
        if icon:
×
2704
            options.append(f'Icon{icon}')
×
2705
        if color_variation is not None:
×
2706
            options.append(color_variation)
×
2707
        if transparent is not None:
×
2708
            options.append(f'Trans{transparent}')
×
2709
        if scale_width:
×
2710
            options.append(f'w{scale_width}')
×
2711
            options.append(f'h{scale_height}')
×
2712

2713
        x1, y1 = upper_bound
×
2714
        if lower_bound:
×
2715
            x2, y2 = lower_bound
×
2716
        else:
2717
            x2, y2 = ('A_ScreenWidth', 'A_ScreenHeight')
×
2718

2719
        args = [str(x1), str(y1), str(x2), str(y2)]
×
2720
        if options:
×
2721
            opts = ' '.join(f'*{opt}' for opt in options)
×
2722
            args.append(opts + f' {image_path}')
×
2723
        else:
2724
            args.append(image_path)
×
2725

2726
        if coord_mode is not None:
×
2727
            args.append(coord_mode)
×
2728

2729
        resp = await self._transport.function_call('AHKImageSearch', args, blocking=blocking)
×
2730
        return resp
×
2731

2732
    async def mouse_drag(
4✔
2733
        self,
2734
        x: int,
2735
        y: int,
2736
        *,
2737
        from_position: Optional[Tuple[int, int]] = None,
2738
        speed: Optional[int] = None,
2739
        button: MouseButton = 1,
2740
        relative: Optional[bool] = None,
2741
        blocking: bool = True,
2742
        coord_mode: Optional[CoordModeRelativeTo] = None,
2743
    ) -> None:
2744
        """
2745
        Analog for `MouseClickDrag <https://www.autohotkey.com/docs/commands/MouseClickDrag.htm>`_
2746
        """
2747
        if from_position:
×
2748
            x1, y1 = from_position
×
2749
            args = [str(button), str(x1), str(y1), str(x), str(y)]
×
2750
        else:
2751
            args = [str(button), '', '', str(x), str(y)]
×
2752

2753
        if speed:
×
2754
            args.append(str(speed))
×
2755
        else:
2756
            args.append('')
×
2757

2758
        if relative:
×
2759
            args.append('R')
×
2760
        else:
2761
            args.append('')
×
2762

2763
        if coord_mode:
×
2764
            args.append(coord_mode)
×
2765

2766
        await self._transport.function_call('AHKMouseClickDrag', args, blocking=blocking)
×
2767

2768
    # fmt: off
2769
    @overload
4✔
2770
    async def pixel_get_color(self, x: int, y: int, *, coord_mode: Optional[CoordModeRelativeTo] = None, alt: bool = False, slow: bool = False, rgb: bool = True) -> str: ...
4✔
2771
    @overload
4✔
2772
    async def pixel_get_color(self, x: int, y: int, *, coord_mode: Optional[CoordModeRelativeTo] = None, alt: bool = False, slow: bool = False, rgb: bool = True, blocking: Literal[True]) -> str: ...
4✔
2773
    @overload
4✔
2774
    async def pixel_get_color(self, x: int, y: int, *, coord_mode: Optional[CoordModeRelativeTo] = None, alt: bool = False, slow: bool = False, rgb: bool = True, blocking: Literal[False]) -> AsyncFutureResult[str]: ...
4✔
2775
    @overload
4✔
2776
    async def pixel_get_color(self, x: int, y: int, *, coord_mode: Optional[CoordModeRelativeTo] = None, alt: bool = False, slow: bool = False, rgb: bool = True, blocking: bool = True) -> Union[str, AsyncFutureResult[str]]: ...
4✔
2777
    # fmt: on
2778
    async def pixel_get_color(
4✔
2779
        self,
2780
        x: int,
2781
        y: int,
2782
        *,
2783
        coord_mode: Optional[CoordModeRelativeTo] = None,
2784
        alt: bool = False,
2785
        slow: bool = False,
2786
        rgb: bool = True,
2787
        blocking: bool = True,
2788
    ) -> Union[str, AsyncFutureResult[str]]:
2789
        """
2790
        Analog for `PixelGetColor <https://www.autohotkey.com/docs/commands/PixelGetColor.htm>`_
2791
        """
2792
        args = [str(x), str(y), coord_mode or '']
×
2793

2794
        options = ' '.join(word for word, val in zip(('Alt', 'Slow', 'RGB'), (alt, slow, rgb)) if val)
×
2795
        args.append(options)
×
2796

2797
        resp = await self._transport.function_call('AHKPixelGetColor', args, blocking=blocking)
×
2798
        return resp
×
2799

2800
    # fmt: off
2801
    @overload
4✔
2802
    async def pixel_search(self, search_region_start: Tuple[int, int], search_region_end: Tuple[int, int], color: Union[str, int], variation: int = 0, *, coord_mode: Optional[CoordModeRelativeTo] = None, fast: bool = True, rgb: bool = True) -> Optional[Tuple[int, int]]: ...
4✔
2803
    @overload
4✔
2804
    async def pixel_search(self, search_region_start: Tuple[int, int], search_region_end: Tuple[int, int], color: Union[str, int], variation: int = 0, *, coord_mode: Optional[CoordModeRelativeTo] = None, fast: bool = True, rgb: bool = True, blocking: Literal[True]) -> Optional[Tuple[int, int]]: ...
4✔
2805
    @overload
4✔
2806
    async def pixel_search(self, search_region_start: Tuple[int, int], search_region_end: Tuple[int, int], color: Union[str, int], variation: int = 0, *, coord_mode: Optional[CoordModeRelativeTo] = None, fast: bool = True, rgb: bool = True, blocking: Literal[False]) -> AsyncFutureResult[Optional[Tuple[int, int]]]: ...
4✔
2807
    @overload
4✔
2808
    async def pixel_search(self, search_region_start: Tuple[int, int], search_region_end: Tuple[int, int], color: Union[str, int], variation: int = 0, *, coord_mode: Optional[CoordModeRelativeTo] = None, fast: bool = True, rgb: bool = True, blocking: bool = True) -> Union[Optional[Tuple[int, int]], AsyncFutureResult[Optional[Tuple[int, int]]]]: ...
4✔
2809
    # fmt: on
2810
    async def pixel_search(
4✔
2811
        self,
2812
        search_region_start: Tuple[int, int],
2813
        search_region_end: Tuple[int, int],
2814
        color: Union[str, int],
2815
        variation: int = 0,
2816
        *,
2817
        coord_mode: Optional[CoordModeRelativeTo] = None,
2818
        fast: bool = True,
2819
        rgb: bool = True,
2820
        blocking: bool = True,
2821
    ) -> Union[Optional[Tuple[int, int]], AsyncFutureResult[Optional[Tuple[int, int]]]]:
2822
        """
2823
        Analog for `PixelSearch <https://www.autohotkey.com/docs/commands/PixelSearch.htm>`_
2824
        """
2825
        x1, y1 = search_region_start
×
2826
        x2, y2 = search_region_end
×
2827
        args = [str(x1), str(y1), str(x2), str(y2), str(color), str(variation)]
×
2828
        mode = ' '.join(word for word, val in zip(('Fast', 'RGB'), (fast, rgb)) if val)
×
2829
        args.append(mode)
×
2830
        args.append(coord_mode or '')
×
2831
        resp = await self._transport.function_call('AHKPixelSearch', args, blocking=blocking)
×
2832
        return resp
×
2833

2834
    # fmt: off
2835
    @overload
4✔
2836
    async def win_close(self, title: str = '', text: str = '', seconds_to_wait: Optional[int] = None, exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None) -> None: ...
4✔
2837
    @overload
4✔
2838
    async def win_close(self, title: str = '', text: str = '', seconds_to_wait: Optional[int] = None, exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: Literal[True]) -> None: ...
4✔
2839
    @overload
4✔
2840
    async def win_close(self, title: str = '', text: str = '', seconds_to_wait: Optional[int] = None, exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: Literal[False]) -> AsyncFutureResult[None]: ...
4✔
2841
    @overload
4✔
2842
    async def win_close(self, title: str = '', text: str = '', seconds_to_wait: Optional[int] = None, exclude_title: str = '', exclude_text: str = '', *, blocking: bool = True, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None) -> Union[None, AsyncFutureResult[None]]: ...
4✔
2843
    # fmt: on
2844
    async def win_close(
4✔
2845
        self,
2846
        title: str = '',
2847
        text: str = '',
2848
        seconds_to_wait: Optional[int] = None,
2849
        exclude_title: str = '',
2850
        exclude_text: str = '',
2851
        *,
2852
        blocking: bool = True,
2853
        title_match_mode: Optional[TitleMatchMode] = None,
2854
        detect_hidden_windows: Optional[bool] = None,
2855
    ) -> Union[None, AsyncFutureResult[None]]:
2856
        """
2857
        Analog for `WinClose <https://www.autohotkey.com/docs/commands/WinClose.htm>`_
2858
        """
2859
        args = self._format_win_args(
4✔
2860
            title=title,
2861
            text=text,
2862
            exclude_title=exclude_title,
2863
            exclude_text=exclude_text,
2864
            title_match_mode=title_match_mode,
2865
            detect_hidden_windows=detect_hidden_windows,
2866
        )
2867
        args.append(str(seconds_to_wait) if seconds_to_wait else '')
4✔
2868

2869
        resp = await self._transport.function_call('AHKWinClose', args, engine=self, blocking=blocking)
4✔
2870
        return resp
4✔
2871

2872
    # fmt: off
2873
    @overload
4✔
2874
    async def win_kill(self, title: str = '', text: str = '', seconds_to_wait: Optional[int] = None, exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None) -> None: ...
4✔
2875
    @overload
4✔
2876
    async def win_kill(self, title: str = '', text: str = '', seconds_to_wait: Optional[int] = None, exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: Literal[False]) -> Union[None, AsyncFutureResult[None]]: ...
4✔
2877
    @overload
4✔
2878
    async def win_kill(self, title: str = '', text: str = '', seconds_to_wait: Optional[int] = None, exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: Literal[True]) -> None: ...
4✔
2879
    @overload
4✔
2880
    async def win_kill(self, title: str = '', text: str = '', seconds_to_wait: Optional[int] = None, exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: bool = True,) -> Union[None, AsyncFutureResult[None]]: ...
4✔
2881
    # fmt: on
2882
    async def win_kill(
4✔
2883
        self,
2884
        title: str = '',
2885
        text: str = '',
2886
        seconds_to_wait: Optional[int] = None,
2887
        exclude_title: str = '',
2888
        exclude_text: str = '',
2889
        *,
2890
        title_match_mode: Optional[TitleMatchMode] = None,
2891
        detect_hidden_windows: Optional[bool] = None,
2892
        blocking: bool = True,
2893
    ) -> Union[None, AsyncFutureResult[None]]:
2894
        """
2895
        Analog for `WinKill <https://www.autohotkey.com/docs/commands/WinKill.htm>`_
2896
        """
2897
        args = self._format_win_args(
×
2898
            title=title,
2899
            text=text,
2900
            exclude_title=exclude_title,
2901
            exclude_text=exclude_text,
2902
            title_match_mode=title_match_mode,
2903
            detect_hidden_windows=detect_hidden_windows,
2904
        )
2905
        args.append(str(seconds_to_wait) if seconds_to_wait else '')
×
2906

2907
        resp = await self._transport.function_call('AHKWinKill', args, engine=self, blocking=blocking)
×
2908
        return resp
×
2909

2910
    # fmt: off
2911
    @overload
4✔
2912
    async def win_minimize(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None) -> None: ...
4✔
2913
    @overload
4✔
2914
    async def win_minimize(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: Literal[False]) -> Union[None, AsyncFutureResult[None]]: ...
4✔
2915
    @overload
4✔
2916
    async def win_minimize(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: Literal[True]) -> None: ...
4✔
2917
    @overload
4✔
2918
    async def win_minimize(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: bool = True,) -> Union[None, AsyncFutureResult[None]]: ...
4✔
2919
    # fmt: on
2920
    async def win_minimize(
4✔
2921
        self,
2922
        title: str = '',
2923
        text: str = '',
2924
        exclude_title: str = '',
2925
        exclude_text: str = '',
2926
        *,
2927
        title_match_mode: Optional[TitleMatchMode] = None,
2928
        detect_hidden_windows: Optional[bool] = None,
2929
        blocking: bool = True,
2930
    ) -> Union[None, AsyncFutureResult[None]]:
2931
        """
2932
        Analog for `WinMinimize <https://www.autohotkey.com/docs/commands/WinMinimize.htm>`_
2933
        """
2934
        args = self._format_win_args(
×
2935
            title=title,
2936
            text=text,
2937
            exclude_title=exclude_title,
2938
            exclude_text=exclude_text,
2939
            title_match_mode=title_match_mode,
2940
            detect_hidden_windows=detect_hidden_windows,
2941
        )
2942
        resp = await self._transport.function_call('AHKWinMinimize', args, engine=self, blocking=blocking)
×
2943
        return resp
×
2944

2945
    # fmt: off
2946
    @overload
4✔
2947
    async def win_maximize(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None) -> None: ...
4✔
2948
    @overload
4✔
2949
    async def win_maximize(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: Literal[False]) -> Union[None, AsyncFutureResult[None]]: ...
4✔
2950
    @overload
4✔
2951
    async def win_maximize(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: Literal[True]) -> None: ...
4✔
2952
    @overload
4✔
2953
    async def win_maximize(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: bool = True,) -> Union[None, AsyncFutureResult[None]]: ...
4✔
2954
    # fmt: on
2955
    async def win_maximize(
4✔
2956
        self,
2957
        title: str = '',
2958
        text: str = '',
2959
        exclude_title: str = '',
2960
        exclude_text: str = '',
2961
        *,
2962
        title_match_mode: Optional[TitleMatchMode] = None,
2963
        detect_hidden_windows: Optional[bool] = None,
2964
        blocking: bool = True,
2965
    ) -> Union[None, AsyncFutureResult[None]]:
2966
        """
2967
        Analog for `WinMaximize <https://www.autohotkey.com/docs/commands/WinMaximize.htm>`_
2968
        """
2969
        args = self._format_win_args(
×
2970
            title=title,
2971
            text=text,
2972
            exclude_title=exclude_title,
2973
            exclude_text=exclude_text,
2974
            title_match_mode=title_match_mode,
2975
            detect_hidden_windows=detect_hidden_windows,
2976
        )
2977
        resp = await self._transport.function_call('AHKWinMaximize', args, engine=self, blocking=blocking)
×
2978
        return resp
×
2979

2980
    # fmt: off
2981
    @overload
4✔
2982
    async def win_restore(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None) -> None: ...
4✔
2983
    @overload
4✔
2984
    async def win_restore(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: Literal[False]) -> Union[None, AsyncFutureResult[None]]: ...
4✔
2985
    @overload
4✔
2986
    async def win_restore(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: Literal[True]) -> None: ...
4✔
2987
    @overload
4✔
2988
    async def win_restore(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: bool = True,) -> Union[None, AsyncFutureResult[None]]: ...
4✔
2989
    # fmt: on
2990
    async def win_restore(
4✔
2991
        self,
2992
        title: str = '',
2993
        text: str = '',
2994
        exclude_title: str = '',
2995
        exclude_text: str = '',
2996
        *,
2997
        title_match_mode: Optional[TitleMatchMode] = None,
2998
        detect_hidden_windows: Optional[bool] = None,
2999
        blocking: bool = True,
3000
    ) -> Union[None, AsyncFutureResult[None]]:
3001
        """
3002
        Analog for `WinRestore <https://www.autohotkey.com/docs/commands/WinRestore.htm>`_
3003
        """
3004
        args = self._format_win_args(
×
3005
            title=title,
3006
            text=text,
3007
            exclude_title=exclude_title,
3008
            exclude_text=exclude_text,
3009
            title_match_mode=title_match_mode,
3010
            detect_hidden_windows=detect_hidden_windows,
3011
        )
3012
        resp = await self._transport.function_call('AHKWinRestore', args, engine=self, blocking=blocking)
×
3013
        return resp
×
3014

3015
    # fmt: off
3016
    @overload
4✔
3017
    async def win_wait(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, timeout: Optional[int] = None) -> AsyncWindow: ...
4✔
3018
    @overload
4✔
3019
    async def win_wait(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, timeout: Optional[int] = None, blocking: Literal[False]) -> AsyncFutureResult[AsyncWindow]: ...
4✔
3020
    @overload
4✔
3021
    async def win_wait(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, timeout: Optional[int] = None, blocking: Literal[True]) -> AsyncWindow: ...
4✔
3022
    @overload
4✔
3023
    async def win_wait(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, timeout: Optional[int] = None, blocking: bool = True) -> Union[AsyncWindow, AsyncFutureResult[AsyncWindow]]: ...
4✔
3024
    # fmt: on
3025
    async def win_wait(
4✔
3026
        self,
3027
        title: str = '',
3028
        text: str = '',
3029
        exclude_title: str = '',
3030
        exclude_text: str = '',
3031
        *,
3032
        title_match_mode: Optional[TitleMatchMode] = None,
3033
        detect_hidden_windows: Optional[bool] = None,
3034
        timeout: Optional[int] = None,
3035
        blocking: bool = True,
3036
    ) -> Union[AsyncWindow, AsyncFutureResult[AsyncWindow]]:
3037
        """
3038
        Analog for `WinWait <https://www.autohotkey.com/docs/commands/WinWait.htm>`_
3039
        """
3040
        args = self._format_win_args(
4✔
3041
            title=title,
3042
            text=text,
3043
            exclude_title=exclude_title,
3044
            exclude_text=exclude_text,
3045
            title_match_mode=title_match_mode,
3046
            detect_hidden_windows=detect_hidden_windows,
3047
        )
3048
        args.append(str(timeout) if timeout else '')
4✔
3049
        resp = await self._transport.function_call('AHKWinWait', args, blocking=blocking, engine=self)
4✔
3050
        return resp
4✔
3051

3052
    # fmt: off
3053
    @overload
4✔
3054
    async def win_wait_active(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, timeout: Optional[int] = None) -> AsyncWindow: ...
4✔
3055
    @overload
4✔
3056
    async def win_wait_active(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, timeout: Optional[int] = None, blocking: Literal[False]) -> AsyncFutureResult[AsyncWindow]: ...
4✔
3057
    @overload
4✔
3058
    async def win_wait_active(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, timeout: Optional[int] = None, blocking: Literal[True]) -> AsyncWindow: ...
4✔
3059
    @overload
4✔
3060
    async def win_wait_active(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, timeout: Optional[int] = None, blocking: bool = True) -> Union[AsyncWindow, AsyncFutureResult[AsyncWindow]]: ...
4✔
3061
    # fmt: on
3062
    async def win_wait_active(
4✔
3063
        self,
3064
        title: str = '',
3065
        text: str = '',
3066
        exclude_title: str = '',
3067
        exclude_text: str = '',
3068
        *,
3069
        title_match_mode: Optional[TitleMatchMode] = None,
3070
        detect_hidden_windows: Optional[bool] = None,
3071
        timeout: Optional[int] = None,
3072
        blocking: bool = True,
3073
    ) -> Union[AsyncWindow, AsyncFutureResult[AsyncWindow]]:
3074
        """
3075
        Analog for `WinWaitActive <https://www.autohotkey.com/docs/commands/WinWaitActive.htm>`_
3076
        """
3077
        args = self._format_win_args(
×
3078
            title=title,
3079
            text=text,
3080
            exclude_title=exclude_title,
3081
            exclude_text=exclude_text,
3082
            title_match_mode=title_match_mode,
3083
            detect_hidden_windows=detect_hidden_windows,
3084
        )
3085
        args.append(str(timeout) if timeout else '')
×
3086
        resp = await self._transport.function_call('AHKWinWaitActive', args, blocking=blocking, engine=self)
×
3087
        return resp
×
3088

3089
    # fmt: off
3090
    @overload
4✔
3091
    async def win_wait_not_active(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, timeout: Optional[int] = None) -> AsyncWindow: ...
4✔
3092
    @overload
4✔
3093
    async def win_wait_not_active(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, timeout: Optional[int] = None, blocking: Literal[False]) -> AsyncFutureResult[AsyncWindow]: ...
4✔
3094
    @overload
4✔
3095
    async def win_wait_not_active(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, timeout: Optional[int] = None, blocking: Literal[True]) -> AsyncWindow: ...
4✔
3096
    @overload
4✔
3097
    async def win_wait_not_active(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, timeout: Optional[int] = None, blocking: bool = True) -> Union[AsyncWindow, AsyncFutureResult[AsyncWindow]]: ...
4✔
3098
    # fmt: on
3099
    async def win_wait_not_active(
4✔
3100
        self,
3101
        title: str = '',
3102
        text: str = '',
3103
        exclude_title: str = '',
3104
        exclude_text: str = '',
3105
        *,
3106
        title_match_mode: Optional[TitleMatchMode] = None,
3107
        detect_hidden_windows: Optional[bool] = None,
3108
        timeout: Optional[int] = None,
3109
        blocking: bool = True,
3110
    ) -> Union[AsyncWindow, AsyncFutureResult[AsyncWindow]]:
3111
        """
3112
        Analog for `WinWaitNotActive <https://www.autohotkey.com/docs/commands/WinWaitActive.htm>`_
3113
        """
3114
        args = self._format_win_args(
×
3115
            title=title,
3116
            text=text,
3117
            exclude_title=exclude_title,
3118
            exclude_text=exclude_text,
3119
            title_match_mode=title_match_mode,
3120
            detect_hidden_windows=detect_hidden_windows,
3121
        )
3122
        args.append(str(timeout) if timeout else '')
×
3123
        resp = await self._transport.function_call('AHKWinWaitNotActive', args, blocking=blocking, engine=self)
×
3124
        return resp
×
3125

3126
    # fmt: off
3127
    @overload
4✔
3128
    async def win_wait_close(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, timeout: Optional[int] = None) -> None: ...
4✔
3129
    @overload
4✔
3130
    async def win_wait_close(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, timeout: Optional[int] = None, blocking: Literal[False]) -> AsyncFutureResult[None]: ...
4✔
3131
    @overload
4✔
3132
    async def win_wait_close(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, timeout: Optional[int] = None, blocking: Literal[True]) -> None: ...
4✔
3133
    @overload
4✔
3134
    async def win_wait_close(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, timeout: Optional[int] = None, blocking: bool = True) -> Union[None, AsyncFutureResult[None]]: ...
4✔
3135
    # fmt: on
3136
    async def win_wait_close(
4✔
3137
        self,
3138
        title: str = '',
3139
        text: str = '',
3140
        exclude_title: str = '',
3141
        exclude_text: str = '',
3142
        *,
3143
        title_match_mode: Optional[TitleMatchMode] = None,
3144
        detect_hidden_windows: Optional[bool] = None,
3145
        timeout: Optional[int] = None,
3146
        blocking: bool = True,
3147
    ) -> Union[None, AsyncFutureResult[None]]:
3148
        """
3149
        Analog for `WinWaitClose <https://www.autohotkey.com/docs/commands/WinWaitClose.htm>`_
3150
        """
3151
        args = self._format_win_args(
×
3152
            title=title,
3153
            text=text,
3154
            exclude_title=exclude_title,
3155
            exclude_text=exclude_text,
3156
            title_match_mode=title_match_mode,
3157
            detect_hidden_windows=detect_hidden_windows,
3158
        )
3159
        args.append(str(timeout) if timeout else '')
×
3160
        resp = await self._transport.function_call('AHKWinWaitClose', args, blocking=blocking, engine=self)
×
3161
        return resp
×
3162

3163
    # fmt: off
3164
    @overload
4✔
3165
    async def win_show(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None) -> None: ...
4✔
3166
    @overload
4✔
3167
    async def win_show(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: Literal[False]) -> AsyncFutureResult[None]: ...
4✔
3168
    @overload
4✔
3169
    async def win_show(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: Literal[True]) -> None: ...
4✔
3170
    @overload
4✔
3171
    async def win_show(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: bool = True) -> Union[None, AsyncFutureResult[None]]: ...
4✔
3172
    # fmt: on
3173
    async def win_show(
4✔
3174
        self,
3175
        title: str = '',
3176
        text: str = '',
3177
        exclude_title: str = '',
3178
        exclude_text: str = '',
3179
        *,
3180
        title_match_mode: Optional[TitleMatchMode] = None,
3181
        detect_hidden_windows: Optional[bool] = None,
3182
        blocking: bool = True,
3183
    ) -> Union[None, AsyncFutureResult[None]]:
3184
        """
3185
        Analog for `WinShow <https://www.autohotkey.com/docs/commands/WinShow.htm>`_
3186
        """
3187
        args = self._format_win_args(
×
3188
            title=title,
3189
            text=text,
3190
            exclude_title=exclude_title,
3191
            exclude_text=exclude_text,
3192
            title_match_mode=title_match_mode,
3193
            detect_hidden_windows=detect_hidden_windows,
3194
        )
3195
        resp = await self._transport.function_call('AHKWinShow', args, blocking=blocking)
×
3196
        return resp
×
3197

3198
    # fmt: off
3199
    @overload
4✔
3200
    async def win_hide(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None) -> None: ...
4✔
3201
    @overload
4✔
3202
    async def win_hide(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: Literal[False]) -> AsyncFutureResult[None]: ...
4✔
3203
    @overload
4✔
3204
    async def win_hide(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: Literal[True]) -> None: ...
4✔
3205
    @overload
4✔
3206
    async def win_hide(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: bool = True) -> Union[None, AsyncFutureResult[None]]: ...
4✔
3207
    # fmt: on
3208
    async def win_hide(
4✔
3209
        self,
3210
        title: str = '',
3211
        text: str = '',
3212
        exclude_title: str = '',
3213
        exclude_text: str = '',
3214
        *,
3215
        title_match_mode: Optional[TitleMatchMode] = None,
3216
        detect_hidden_windows: Optional[bool] = None,
3217
        blocking: bool = True,
3218
    ) -> Union[None, AsyncFutureResult[None]]:
3219
        """
3220
        Analog for `WinHide <https://www.autohotkey.com/docs/commands/WinHide.htm>`_
3221
        """
3222
        args = self._format_win_args(
×
3223
            title=title,
3224
            text=text,
3225
            exclude_title=exclude_title,
3226
            exclude_text=exclude_text,
3227
            title_match_mode=title_match_mode,
3228
            detect_hidden_windows=detect_hidden_windows,
3229
        )
3230
        resp = await self._transport.function_call('AHKWinHide', args, blocking=blocking)
×
3231
        return resp
×
3232

3233
    # fmt: off
3234
    @overload
4✔
3235
    async def win_is_active(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None) -> bool: ...
4✔
3236
    @overload
4✔
3237
    async def win_is_active(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: Literal[True]) -> bool: ...
4✔
3238
    @overload
4✔
3239
    async def win_is_active(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: Literal[False]) -> AsyncFutureResult[bool]: ...
4✔
3240
    @overload
4✔
3241
    async def win_is_active(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: bool = True) -> Union[bool, AsyncFutureResult[bool]]: ...
4✔
3242
    # fmt: on
3243
    async def win_is_active(
4✔
3244
        self,
3245
        title: str = '',
3246
        text: str = '',
3247
        exclude_title: str = '',
3248
        exclude_text: str = '',
3249
        *,
3250
        title_match_mode: Optional[TitleMatchMode] = None,
3251
        detect_hidden_windows: Optional[bool] = None,
3252
        blocking: bool = True,
3253
    ) -> Union[bool, AsyncFutureResult[bool]]:
3254
        """
3255
        Check if a window is active.
3256

3257
        Uses `WinActive <https://www.autohotkey.com/docs/v1/lib/WinActive.htm>`_
3258
        """
3259
        args = self._format_win_args(
4✔
3260
            title=title,
3261
            text=text,
3262
            exclude_title=exclude_title,
3263
            exclude_text=exclude_text,
3264
            title_match_mode=title_match_mode,
3265
            detect_hidden_windows=detect_hidden_windows,
3266
        )
3267
        resp = await self._transport.function_call('AHKWinIsActive', args, blocking=blocking)
4✔
3268
        return resp
4✔
3269

3270
    # fmt: off
3271
    @overload
4✔
3272
    async def win_move(self, x: int, y: int, *, width: Optional[int] = None, height: Optional[int] = None, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None) -> None: ...
4✔
3273
    @overload
4✔
3274
    async def win_move(self, x: int, y: int, *, width: Optional[int] = None, height: Optional[int] = None, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: Literal[True]) -> None: ...
4✔
3275
    @overload
4✔
3276
    async def win_move(self, x: int, y: int, *, width: Optional[int] = None, height: Optional[int] = None, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: Literal[False]) -> AsyncFutureResult[None]: ...
4✔
3277
    @overload
4✔
3278
    async def win_move(self, x: int, y: int, *, width: Optional[int] = None, height: Optional[int] = None, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: bool = True) -> Union[None, AsyncFutureResult[None]]: ...
4✔
3279
    # fmt: on
3280
    async def win_move(
4✔
3281
        self,
3282
        x: int,
3283
        y: int,
3284
        *,
3285
        width: Optional[int] = None,
3286
        height: Optional[int] = None,
3287
        title: str = '',
3288
        text: str = '',
3289
        exclude_title: str = '',
3290
        exclude_text: str = '',
3291
        title_match_mode: Optional[TitleMatchMode] = None,
3292
        detect_hidden_windows: Optional[bool] = None,
3293
        blocking: bool = True,
3294
    ) -> Union[None, AsyncFutureResult[None]]:
3295
        """
3296
        Analog for `WinMove <https://www.autohotkey.com/docs/commands/WinMove.htm>`_
3297
        """
3298
        args = self._format_win_args(
4✔
3299
            title=title,
3300
            text=text,
3301
            exclude_title=exclude_title,
3302
            exclude_text=exclude_text,
3303
            title_match_mode=title_match_mode,
3304
            detect_hidden_windows=detect_hidden_windows,
3305
        )
3306
        args.append(str(x))
4✔
3307
        args.append(str(y))
4✔
3308
        args.append(str(width) if width is not None else '')
4✔
3309
        args.append(str(height) if height is not None else '')
4✔
3310
        resp = await self._transport.function_call('AHKWinMove', args, blocking=blocking)
4✔
3311
        return resp
4✔
3312

3313
    # fmt: off
3314
    @overload
4✔
3315
    async def get_clipboard(self) -> str: ...
4✔
3316
    @overload
4✔
3317
    async def get_clipboard(self, *, blocking: Literal[False]) -> AsyncFutureResult[str]: ...
4✔
3318
    @overload
4✔
3319
    async def get_clipboard(self, *, blocking: Literal[True]) -> str: ...
4✔
3320
    @overload
4✔
3321
    async def get_clipboard(self, *, blocking: bool = True) -> Union[str, AsyncFutureResult[str]]: ...
4✔
3322
    # fmt: on
3323
    async def get_clipboard(self, *, blocking: bool = True) -> Union[str, AsyncFutureResult[str]]:
4✔
3324
        """
3325
        Get the string contents of the clipboard
3326
        """
3327
        return await self._transport.function_call('AHKGetClipboard', blocking=blocking)
4✔
3328

3329
    async def set_clipboard(self, s: str, *, blocking: bool = True) -> Union[None, AsyncFutureResult[None]]:
4✔
3330
        """
3331
        Set the contents of the clipboard
3332
        """
3333
        args = [s]
4✔
3334
        return await self._transport.function_call('AHKSetClipboard', args, blocking=blocking)
4✔
3335

3336
    async def get_clipboard_all(self, *, blocking: bool = True) -> Union[bytes, AsyncFutureResult[bytes]]:
4✔
3337
        """
3338
        Get the full binary contents of the keyboard. The return value is intended to be used with :py:meth:`set_clipboard_all`
3339
        """
3340
        return await self._transport.function_call('AHKGetClipboardAll', blocking=blocking)
4✔
3341

3342
    # fmt: off
3343
    @overload
4✔
3344
    async def set_clipboard_all(self, contents: bytes) -> None: ...
4✔
3345
    @overload
4✔
3346
    async def set_clipboard_all(self, contents: bytes, *, blocking: Literal[False]) -> AsyncFutureResult[None]: ...
4✔
3347
    @overload
4✔
3348
    async def set_clipboard_all(self, contents: bytes, *, blocking: Literal[True]) -> None: ...
4✔
3349
    @overload
4✔
3350
    async def set_clipboard_all(self, contents: bytes, *, blocking: bool = True) -> Union[None, AsyncFutureResult[None]]: ...
4✔
3351
    # fmt: on
3352
    async def set_clipboard_all(
4✔
3353
        self, contents: bytes, *, blocking: bool = True
3354
    ) -> Union[None, AsyncFutureResult[None]]:
3355
        """
3356
        Set the full binary contents of the clipboard. Expects bytes object as returned by :py:meth:`get_clipboard_all`
3357
        """
3358
        # TODO: figure out how to do this without a tempfile
3359
        if not isinstance(contents, bytes):
4✔
3360
            raise ValueError('Malformed data. Can only set bytes as returned by get_clipboard_all')
×
3361
        if not contents:
4✔
3362
            raise ValueError('bytes must be nonempty. If you want to clear the clipboard, use `set_clipboard`')
×
3363
        with tempfile.NamedTemporaryFile(prefix='ahk-python', suffix='.clip', mode='wb', delete=False) as f:
4✔
3364
            f.write(contents)
4✔
3365

3366
        args = [f'*c {f.name}']
4✔
3367
        try:
4✔
3368
            resp = await self._transport.function_call('AHKSetClipboardAll', args, blocking=blocking)
4✔
3369
            return resp
4✔
3370
        finally:
3371
            try:
4✔
3372
                os.remove(f.name)
4✔
3373
            except Exception:
×
3374
                pass
×
3375

3376
    def on_clipboard_change(
4✔
3377
        self, callback: Callable[[int], Any], ex_handler: Optional[Callable[[int, Exception], Any]] = None
3378
    ) -> None:
3379
        """
3380
        call a function in response to clipboard change.
3381
        Uses `OnClipboardChange() <https://www.autohotkey.com/docs/commands/OnClipboardChange.htm#function>`_
3382
        """
3383
        self._transport.on_clipboard_change(callback, ex_handler)
4✔
3384

3385
    # fmt: off
3386
    @overload
4✔
3387
    async def clip_wait(self, timeout: Optional[float] = None, wait_for_any_data: bool = False) -> None: ...
4✔
3388
    @overload
4✔
3389
    async def clip_wait(self, timeout: Optional[float] = None, wait_for_any_data: bool = False, *, blocking: Literal[False]) -> AsyncFutureResult[None]: ...
4✔
3390
    @overload
4✔
3391
    async def clip_wait(self, timeout: Optional[float] = None, wait_for_any_data: bool = False, *, blocking: Literal[True]) -> None: ...
4✔
3392
    @overload
4✔
3393
    async def clip_wait(self, timeout: Optional[float] = None, wait_for_any_data: bool = False, *, blocking: bool = True) -> Union[None, AsyncFutureResult[None]]: ...
4✔
3394
    # fmt: on
3395
    async def clip_wait(
4✔
3396
        self, timeout: Optional[float] = None, wait_for_any_data: bool = False, *, blocking: bool = True
3397
    ) -> Union[None, AsyncFutureResult[None]]:
3398
        """
3399
        Wait until the clipboard contents change
3400

3401
        Analog for `ClipWait <https://www.autohotkey.com/docs/v1/lib/ClipWait.htm>`_
3402
        """
3403
        args = [str(timeout) if timeout else '']
×
3404
        if wait_for_any_data:
×
3405
            args.append('1')
×
3406
        return await self._transport.function_call('AHKClipWait', args, blocking=blocking)
×
3407

3408
    async def block_input(
4✔
3409
        self,
3410
        value: Literal['On', 'Off', 'Default', 'Send', 'Mouse', 'MouseMove', 'MouseMoveOff', 'SendAndMouse'],
3411
        /,  # flake8: noqa
3412
    ) -> None:
3413
        """
3414
        Analog for `BlockInput <https://www.autohotkey.com/docs/commands/BlockInput.htm>`_
3415
        """
3416
        await self._transport.function_call('AHKBlockInput', args=[value])
×
3417

3418
    # fmt: off
3419
    @overload
4✔
3420
    async def reg_delete(self, key_name: str, value_name: Optional[str] = None) -> None: ...
4✔
3421
    @overload
4✔
3422
    async def reg_delete(self, key_name: str, value_name: Optional[str] = None, *, blocking: Literal[False]) -> Union[None, AsyncFutureResult[None]]: ...
4✔
3423
    @overload
4✔
3424
    async def reg_delete(self, key_name: str, value_name: Optional[str] = None, *, blocking: Literal[True]) -> None: ...
4✔
3425
    @overload
4✔
3426
    async def reg_delete(self, key_name: str, value_name: Optional[str] = None, *, blocking: bool = True) -> Union[None, AsyncFutureResult[None]]: ...
4✔
3427
    # fmt: on
3428
    async def reg_delete(
4✔
3429
        self, key_name: str, value_name: Optional[str] = None, *, blocking: bool = True
3430
    ) -> Union[None, AsyncFutureResult[None]]:
3431
        """
3432
        Analog for `RegDelete <https://www.autohotkey.com/docs/commands/RegDelete.htm>`_
3433
        """
3434
        args = [key_name, value_name if value_name is not None else '']
4✔
3435
        return await self._transport.function_call('AHKRegDelete', args, blocking=blocking)
4✔
3436

3437
    # fmt: off
3438
    @overload
4✔
3439
    async def reg_write(self, value_type: Literal['REG_SZ', 'REG_EXPAND_SZ', 'REG_MULTI_SZ', 'REG_DWORD', 'REG_BINARY'], key_name: str, value_name: Optional[str] = None, value: Optional[str] = None) -> None: ...
4✔
3440
    @overload
4✔
3441
    async def reg_write(self, value_type: Literal['REG_SZ', 'REG_EXPAND_SZ', 'REG_MULTI_SZ', 'REG_DWORD', 'REG_BINARY'], key_name: str, value_name: Optional[str] = None, value: Optional[str] = None, *, blocking: Literal[False]) -> AsyncFutureResult[None]: ...
4✔
3442
    @overload
4✔
3443
    async def reg_write(self, value_type: Literal['REG_SZ', 'REG_EXPAND_SZ', 'REG_MULTI_SZ', 'REG_DWORD', 'REG_BINARY'], key_name: str, value_name: Optional[str] = None, value: Optional[str] = None, *, blocking: Literal[True]) -> None: ...
4✔
3444
    @overload
4✔
3445
    async def reg_write(self, value_type: Literal['REG_SZ', 'REG_EXPAND_SZ', 'REG_MULTI_SZ', 'REG_DWORD', 'REG_BINARY'], key_name: str, value_name: Optional[str] = None, value: Optional[str] = None, *, blocking: bool = True) -> Union[None, AsyncFutureResult[None]]: ...
4✔
3446
    # fmt: on
3447
    async def reg_write(
4✔
3448
        self,
3449
        value_type: Literal['REG_SZ', 'REG_EXPAND_SZ', 'REG_MULTI_SZ', 'REG_DWORD', 'REG_BINARY'],
3450
        key_name: str,
3451
        value_name: Optional[str] = None,
3452
        value: Optional[str] = None,
3453
        *,
3454
        blocking: bool = True,
3455
    ) -> Union[None, AsyncFutureResult[None]]:
3456
        """
3457
        Analog for `RegWrite <https://www.autohotkey.com/docs/commands/RegWrite.htm>`_
3458
        """
3459
        args = [value_type, key_name]
4✔
3460
        if value_name is not None:
4✔
3461
            args.append(value_name)
4✔
3462
        else:
3463
            args.append('')
4✔
3464
        if value is not None:
4✔
3465
            args.append(value)
4✔
3466
        return await self._transport.function_call('AHKRegWrite', args, blocking=blocking)
4✔
3467

3468
    # fmt: off
3469
    @overload
4✔
3470
    async def reg_read(self, key_name: str, value_name: Optional[str] = None) -> str: ...
4✔
3471
    @overload
4✔
3472
    async def reg_read(self, key_name: str, value_name: Optional[str] = None, *, blocking: Literal[False]) -> AsyncFutureResult[str]: ...
4✔
3473
    @overload
4✔
3474
    async def reg_read(self, key_name: str, value_name: Optional[str] = None, *, blocking: Literal[True]) -> str: ...
4✔
3475
    @overload
4✔
3476
    async def reg_read(self, key_name: str, value_name: Optional[str] = None, *, blocking: bool = True) -> Union[str, AsyncFutureResult[str]]: ...
4✔
3477
    # fmt: on
3478
    async def reg_read(
4✔
3479
        self, key_name: str, value_name: Optional[str] = None, *, blocking: bool = True
3480
    ) -> Union[str, AsyncFutureResult[str]]:
3481
        """
3482
        Analog for `RegRead <https://www.autohotkey.com/docs/commands/RegRead.htm>`_
3483
        """
3484
        args = [key_name]
4✔
3485
        if value_name is not None:
4✔
3486
            args.append(value_name)
4✔
3487
        return await self._transport.function_call('AHKRegRead', args, blocking=blocking)
4✔
3488

3489
    async def block_forever(self) -> NoReturn:
4✔
3490
        """
3491
        Blocks (sleeps) forever. Utility method to prevent script from exiting.
3492
        """
3493
        while True:
3494
            await async_sleep(1)
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc