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

spyoungtech / ahk / 5973736624

25 Aug 2023 08:31AM UTC coverage: 75.028% (+0.2%) from 74.796%
5973736624

Pull #232

github

spyoungtech
prepare 1.4.0rc1
Pull Request #232: Add interfaces for extension authoring

134 of 134 new or added lines in 7 files covered. (100.0%)

4765 of 6351 relevant lines covered (75.03%)

3.0 hits per line

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

66.78
/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 functools import partial
4✔
10
from typing import Any
4✔
11
from typing import Awaitable
4✔
12
from typing import Callable
4✔
13
from typing import Coroutine
4✔
14
from typing import List
4✔
15
from typing import Literal
4✔
16
from typing import NoReturn
4✔
17
from typing import Optional
4✔
18
from typing import overload
4✔
19
from typing import Tuple
4✔
20
from typing import Type
4✔
21
from typing import Union
4✔
22

23
from .._hotkey import Hotkey
4✔
24
from .._hotkey import Hotstring
4✔
25
from .._utils import MsgBoxButtons
4✔
26
from .._utils import MsgBoxDefaultButton
4✔
27
from .._utils import MsgBoxIcon
4✔
28
from .._utils import MsgBoxModality
4✔
29
from .._utils import MsgBoxOtherOptions
4✔
30
from .._utils import type_escape
4✔
31
from ..directives import Directive
4✔
32

33
if sys.version_info < (3, 10):
4✔
34
    from typing_extensions import TypeAlias
2✔
35
else:
36
    from typing import TypeAlias
2✔
37

38
from ..extensions import Extension, _extension_method_registry, _ExtensionMethodRegistry
4✔
39
from ..keys import Key
4✔
40
from .transport import AsyncDaemonProcessTransport
4✔
41
from .transport import AsyncFutureResult
4✔
42
from .transport import AsyncTransport
4✔
43
from .window import AsyncControl
4✔
44
from .window import AsyncWindow
4✔
45

46
# from .window import AsyncGui
47
from ahk.message import Position
4✔
48

49

50
async_sleep = asyncio.sleep  # unasync: remove
4✔
51
sleep = time.sleep
4✔
52

53
AsyncFilterFunc: TypeAlias = Callable[[AsyncWindow], Awaitable[bool]]  # unasync: remove
4✔
54
SyncFilterFunc: TypeAlias = Callable[[AsyncWindow], bool]
4✔
55

56
CoordModeTargets: TypeAlias = Union[
4✔
57
    Literal['ToolTip'], Literal['Pixel'], Literal['Mouse'], Literal['Caret'], Literal['Menu']
58
]
59
CoordModeRelativeTo: TypeAlias = Union[Literal['Screen', 'Relative', 'Window', 'Client', '']]
4✔
60

61
CoordMode: TypeAlias = Union[CoordModeTargets, Tuple[CoordModeTargets, CoordModeRelativeTo]]
4✔
62

63
MatchModes: TypeAlias = Literal[1, 2, 3, 'RegEx', '']
4✔
64
MatchSpeeds: TypeAlias = Literal['Fast', 'Slow', '']
4✔
65

66
TitleMatchMode: TypeAlias = Optional[
4✔
67
    Union[MatchModes, MatchSpeeds, Tuple[Union[MatchModes, MatchSpeeds], Union[MatchSpeeds, MatchModes]]]
68
]
69

70
_BUTTONS: dict[Union[str, int], str] = {
4✔
71
    1: 'L',
72
    2: 'R',
73
    3: 'M',
74
    'left': 'L',
75
    'right': 'R',
76
    'middle': 'M',
77
    'wheelup': 'WU',
78
    'wheeldown': 'WD',
79
    'wheelleft': 'WL',
80
    'wheelright': 'WR',
81
}
82

83
MouseButton: TypeAlias = Union[
4✔
84
    int,
85
    Literal[
86
        'L',
87
        'R',
88
        'M',
89
        'left',
90
        'right',
91
        'middle',
92
        'wheelup',
93
        'WU',
94
        'wheeldown',
95
        'WD',
96
        'wheelleft',
97
        'WL',
98
        'wheelright',
99
        'WR',
100
    ],
101
]
102

103
AsyncPropertyReturnTupleIntInt: TypeAlias = Coroutine[None, None, Tuple[int, int]]  # unasync: remove
4✔
104
SyncPropertyReturnTupleIntInt: TypeAlias = Tuple[int, int]
4✔
105

106
AsyncPropertyReturnOptionalAsyncWindow: TypeAlias = Coroutine[None, None, Optional[AsyncWindow]]  # unasync: remove
4✔
107
SyncPropertyReturnOptionalAsyncWindow: TypeAlias = Optional[AsyncWindow]
4✔
108

109
_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✔
110

111

112
def _resolve_button(button: Union[str, int]) -> str:
4✔
113
    """
114
    Resolve a string of a button name to a canonical name used for AHK script
115
    :param button:
116
    :type button: str
117
    :return:
118
    """
119
    if isinstance(button, str):
×
120
        button = button.lower()
×
121

122
    if button in _BUTTONS:
×
123
        resolved_button = _BUTTONS[button]
×
124
    elif isinstance(button, int) and button > 3:
×
125
        #  for addtional mouse buttons
126
        resolved_button = f'X{button-3}'
×
127
    else:
128
        assert isinstance(button, str)
×
129
        resolved_button = button
×
130
    return resolved_button
×
131

132

133
class AsyncAHK:
4✔
134
    def __init__(
4✔
135
        self,
136
        *,
137
        TransportClass: Optional[Type[AsyncTransport]] = None,
138
        directives: Optional[list[Directive | Type[Directive]]] = None,
139
        executable_path: str = '',
140
        extensions: list[Extension] | None | Literal['auto'] = None,
141
    ):
142
        self._extension_registry: _ExtensionMethodRegistry
4✔
143
        self._extensions: list[Extension]
4✔
144
        if extensions == 'auto':
4✔
145
            is_async = False
4✔
146
            is_async = True  # unasync: remove
4✔
147
            if is_async:
4✔
148
                methods = _extension_method_registry.async_methods
4✔
149
            else:
150
                methods = _extension_method_registry.sync_methods
×
151
            extensions = list(set(entry.extension for name, entry in methods.items()))
4✔
152

153
            self._extension_registry = _extension_method_registry
4✔
154
            self._extensions = extensions
4✔
155
        else:
156
            self._extensions = extensions or []
4✔
157
            self._extension_registry = _ExtensionMethodRegistry(sync_methods={}, async_methods={})
4✔
158
            for ext in self._extensions:
4✔
159
                self._extension_registry.merge(ext._extension_method_registry)
4✔
160

161
        if TransportClass is None:
4✔
162
            TransportClass = AsyncDaemonProcessTransport
4✔
163
        assert TransportClass is not None
4✔
164
        transport = TransportClass(executable_path=executable_path, directives=directives, extensions=extensions)
4✔
165
        self._transport: AsyncTransport = transport
4✔
166

167
    def __getattr__(self, name: str) -> Callable[..., Any]:
4✔
168
        is_async = False
4✔
169
        is_async = True  # unasync: remove
4✔
170
        if is_async:
4✔
171
            if name in self._extension_registry.async_methods:
4✔
172
                method = self._extension_registry.async_methods[name].method
4✔
173
                return partial(method, self)
4✔
174
        else:
175
            if name in self._extension_registry.sync_methods:
×
176
                method = self._extension_registry.sync_methods[name].method
×
177
                return partial(method, self)
×
178

179
        raise AttributeError(f'{self.__class__.__name__!r} object has no attribute {name!r}')
4✔
180

181
    def add_hotkey(
4✔
182
        self, keyname: str, callback: Callable[[], Any], ex_handler: Optional[Callable[[str, Exception], Any]] = None
183
    ) -> None:
184
        """
185
        Register a function to be called when a hotkey is pressed.
186

187
        Key notes:
188

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

194
        :param keyname: the key trigger for the hotkey, such as ``#n`` (win+n)
195
        :param callback: callback function to call when the hotkey is triggered
196
        :param ex_handler: a function which accepts two parameters: the keyname for the hotkey and the exception raised by the callback function.
197
        :return:
198
        """
199
        hotkey = Hotkey(keyname, callback, ex_handler=ex_handler)
4✔
200
        with warnings.catch_warnings(record=True) as caught_warnings:
4✔
201
            self._transport.add_hotkey(hotkey=hotkey)
4✔
202
        if caught_warnings:
4✔
203
            for warning in caught_warnings:
×
204
                warnings.warn(warning.message, warning.category, stacklevel=2)
×
205
        return None
4✔
206

207
    async def function_call(self, function_name: str, args: list[str], blocking: bool = True) -> Any:
4✔
208
        """
209
        Call an AHK function defined in the daemon script. This method is intended for use by extension authors.
210
        """
211
        return await self._transport.function_call(function_name, args, blocking=blocking, engine=self)  # type: ignore[call-overload]
4✔
212

213
    def add_hotstring(
4✔
214
        self,
215
        trigger: str,
216
        replacement_or_callback: Union[str, Callable[[], Any]],
217
        ex_handler: Optional[Callable[[str, Exception], Any]] = None,
218
        options: str = '',
219
    ) -> None:
220
        """
221
        Register a hotstring, e.g., `::btw::by the way`
222

223
        Key notes:
224

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

228
        :param trigger: the trigger phrase for the hotstring, e.g., ``btw``
229
        :param replacement_or_callback: the replacement phrase (e.g., ``by the way``) or a Python callable to execute in response to the hotstring trigger
230
        :param ex_handler: a function which accepts two parameters: the hotstring and the exception raised by the callback function.
231
        :param options: the hotstring options -- same meanings as in AutoHotkey.
232
        :return:
233
        """
234
        hotstring = Hotstring(trigger, replacement_or_callback, ex_handler=ex_handler, options=options)
4✔
235
        with warnings.catch_warnings(record=True) as caught_warnings:
4✔
236
            self._transport.add_hotstring(hotstring=hotstring)
4✔
237
        if caught_warnings:
4✔
238
            for warning in caught_warnings:
×
239
                warnings.warn(warning.message, warning.category, stacklevel=2)
×
240
        return None
4✔
241

242
    def remove_hotkey(self, keyname: str) -> None:
4✔
243
        def _() -> None:
4✔
244
            return None
×
245

246
        h = Hotkey(keyname=keyname, callback=_)  # XXX: this can probably be avoided
4✔
247
        self._transport.remove_hotkey(hotkey=h)
4✔
248
        return None
4✔
249

250
    def clear_hotkeys(self) -> None:
4✔
251
        self._transport.clear_hotkeys()
4✔
252
        return None
4✔
253

254
    def remove_hotstring(self, trigger: str) -> None:
4✔
255
        hs = Hotstring(trigger=trigger, replacement_or_callback='')  # XXX: this can probably be avoided
4✔
256
        self._transport.remove_hotstring(hs)
4✔
257
        return None
4✔
258

259
    def clear_hotstrings(self) -> None:
4✔
260
        self._transport.clear_hotstrings()
4✔
261
        return None
4✔
262

263
    async def set_title_match_mode(self, title_match_mode: TitleMatchMode, /) -> None:
4✔
264
        """
265
        Sets the default title match mode
266

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

269
        Reference: https://www.autohotkey.com/docs/commands/SetTitleMatchMode.htm
270

271
        :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.
272
        :return: None
273
        """
274

275
        args = []
4✔
276
        if isinstance(title_match_mode, tuple):
4✔
277
            (match_mode, match_speed) = title_match_mode
4✔
278
        elif title_match_mode in (1, 2, 3, 'RegEx'):
4✔
279
            match_mode = title_match_mode
4✔
280
            match_speed = ''
4✔
281
        elif title_match_mode in ('Fast', 'Slow'):
4✔
282
            match_mode = ''
4✔
283
            match_speed = title_match_mode
4✔
284
        else:
285
            raise ValueError(
×
286
                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}"
287
            )
288
        args.append(str(match_mode))
4✔
289
        args.append(str(match_speed))
4✔
290
        await self._transport.function_call('AHKSetTitleMatchMode', args)
4✔
291
        return None
4✔
292

293
    async def get_title_match_mode(self) -> str:
4✔
294
        """
295
        Get the title match mode.
296

297
        I.E. the current value of ``A_TitleMatchMode``
298

299
        """
300
        resp = await self._transport.function_call('AHKGetTitleMatchMode')
4✔
301
        return resp
4✔
302

303
    async def get_title_match_speed(self) -> str:
4✔
304
        """
305
        Get the title match mode speed.
306

307
        I.E. the current value of ``A_TitleMatchModeSpeed``
308

309
        """
310
        resp = await self._transport.function_call('AHKGetTitleMatchSpeed')
4✔
311
        return resp
4✔
312

313
    async def set_coord_mode(self, target: CoordModeTargets, relative_to: CoordModeRelativeTo = 'Screen') -> None:
4✔
314
        """
315
        Analog of `CoordMode <https://www.autohotkey.com/docs/commands/CoordMode.htm>`_
316
        """
317
        args = [str(target), str(relative_to)]
×
318
        await self._transport.function_call('AHKSetCoordMode', args)
×
319
        return None
×
320

321
    async def get_coord_mode(self, target: CoordModeTargets) -> str:
4✔
322
        """
323
        Analog for ``A_CoordMode<target>``
324
        """
325
        args = [str(target)]
×
326
        resp = await self._transport.function_call('AHKGetCoordMode', args)
×
327
        return resp
×
328

329
    # fmt: off
330
    @overload
4✔
331
    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✔
332
    @overload
4✔
333
    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✔
334
    @overload
4✔
335
    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✔
336
    @overload
4✔
337
    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✔
338
    # fmt: on
339
    async def control_click(
4✔
340
        self,
341
        button: Literal['L', 'R', 'M', 'LEFT', 'RIGHT', 'MIDDLE'] = 'L',
342
        click_count: int = 1,
343
        options: str = '',
344
        control: str = '',
345
        title: str = '',
346
        text: str = '',
347
        exclude_title: str = '',
348
        exclude_text: str = '',
349
        *,
350
        title_match_mode: Optional[TitleMatchMode] = None,
351
        detect_hidden_windows: Optional[bool] = None,
352
        blocking: bool = True,
353
    ) -> Union[None, AsyncFutureResult[None]]:
354
        """
355
        Analog for `ControlClick <https://www.autohotkey.com/docs/commands/ControlClick.htm>`_
356
        """
357
        args = [control, title, text, str(button), str(click_count), options, exclude_title, exclude_text]
×
358
        if detect_hidden_windows is not None:
×
359
            if detect_hidden_windows is True:
×
360
                args.append('On')
×
361
            elif detect_hidden_windows is False:
×
362
                args.append('Off')
×
363
            else:
364
                raise TypeError(
×
365
                    f'Invalid value for parameter detect_hidden_windows. Expected boolean or None, got {detect_hidden_windows!r}'
366
                )
367
        else:
368
            args.append('')
×
369
        if title_match_mode is not None:
×
370
            if isinstance(title_match_mode, tuple):
×
371
                match_mode, match_speed = title_match_mode
×
372
            elif title_match_mode in (1, 2, 3, 'RegEx'):
×
373
                match_mode = title_match_mode
×
374
                match_speed = ''
×
375
            elif title_match_mode in ('Fast', 'Slow'):
×
376
                match_mode = ''
×
377
                match_speed = title_match_mode
×
378
            else:
379
                raise ValueError(
×
380
                    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}"
381
                )
382
            args.append(str(match_mode))
×
383
            args.append(str(match_speed))
×
384
        else:
385
            args.append('')
×
386
            args.append('')
×
387
        resp = await self._transport.function_call('AHKControlClick', args=args, blocking=blocking)
×
388

389
        return resp
×
390

391
    # fmt: off
392
    @overload
4✔
393
    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✔
394
    @overload
4✔
395
    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✔
396
    @overload
4✔
397
    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✔
398
    @overload
4✔
399
    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✔
400
    # fmt: on
401
    async def control_get_text(
4✔
402
        self,
403
        *,
404
        control: str = '',
405
        title: str = '',
406
        text: str = '',
407
        exclude_title: str = '',
408
        exclude_text: str = '',
409
        title_match_mode: Optional[TitleMatchMode] = None,
410
        detect_hidden_windows: Optional[bool] = None,
411
        blocking: bool = True,
412
    ) -> Union[str, AsyncFutureResult[str]]:
413
        """
414
        Analog for `ControlGetText <https://www.autohotkey.com/docs/commands/ControlGetText.htm>`_
415
        """
416
        args = [control, title, text, exclude_title, exclude_text]
×
417
        if detect_hidden_windows is not None:
×
418
            if detect_hidden_windows is True:
×
419
                args.append('On')
×
420
            elif detect_hidden_windows is False:
×
421
                args.append('Off')
×
422
            else:
423
                raise TypeError(
×
424
                    f'Invalid value for parameter detect_hidden_windows. Expected boolean or None, got {detect_hidden_windows!r}'
425
                )
426
        else:
427
            args.append('')
×
428
        if title_match_mode is not None:
×
429
            if isinstance(title_match_mode, tuple):
×
430
                match_mode, match_speed = title_match_mode
×
431
            elif title_match_mode in (1, 2, 3, 'RegEx'):
×
432
                match_mode = title_match_mode
×
433
                match_speed = ''
×
434
            elif title_match_mode in ('Fast', 'Slow'):
×
435
                match_mode = ''
×
436
                match_speed = title_match_mode
×
437
            else:
438
                raise ValueError(
×
439
                    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}"
440
                )
441
            args.append(str(match_mode))
×
442
            args.append(str(match_speed))
×
443
        else:
444
            args.append('')
×
445
            args.append('')
×
446
        resp = await self._transport.function_call('AHKControlGetText', args, blocking=blocking)
×
447
        return resp
×
448

449
    # fmt: off
450
    @overload
4✔
451
    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✔
452
    @overload
4✔
453
    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✔
454
    @overload
4✔
455
    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✔
456
    @overload
4✔
457
    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✔
458
    # fmt: on
459
    async def control_get_position(
4✔
460
        self,
461
        control: str = '',
462
        title: str = '',
463
        text: str = '',
464
        exclude_title: str = '',
465
        exclude_text: str = '',
466
        *,
467
        title_match_mode: Optional[TitleMatchMode] = None,
468
        detect_hidden_windows: Optional[bool] = None,
469
        blocking: bool = True,
470
    ) -> Union[Position, AsyncFutureResult[Position]]:
471
        """
472
        Analog to `ControlGetPos <https://www.autohotkey.com/docs/commands/ControlGetPos.htm>`_
473
        """
474
        args = [control, title, text, exclude_title, exclude_text]
4✔
475
        if detect_hidden_windows is not None:
4✔
476
            if detect_hidden_windows is True:
4✔
477
                args.append('On')
4✔
478
            elif detect_hidden_windows is False:
×
479
                args.append('Off')
×
480
            else:
481
                raise TypeError(
×
482
                    f'Invalid value for parameter detect_hidden_windows. Expected boolean or None, got {detect_hidden_windows!r}'
483
                )
484
        else:
485
            args.append('')
×
486
        if title_match_mode is not None:
4✔
487
            if isinstance(title_match_mode, tuple):
4✔
488
                match_mode, match_speed = title_match_mode
4✔
489
            elif title_match_mode in (1, 2, 3, 'RegEx'):
×
490
                match_mode = title_match_mode
×
491
                match_speed = ''
×
492
            elif title_match_mode in ('Fast', 'Slow'):
×
493
                match_mode = ''
×
494
                match_speed = title_match_mode
×
495
            else:
496
                raise ValueError(
×
497
                    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}"
498
                )
499
            args.append(str(match_mode))
4✔
500
            args.append(str(match_speed))
4✔
501
        else:
502
            args.append('')
×
503
            args.append('')
×
504

505
        resp = await self._transport.function_call('AHKControlGetPos', args, blocking=blocking)
4✔
506
        return resp
4✔
507

508
    # fmt: off
509
    @overload
4✔
510
    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✔
511
    @overload
4✔
512
    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✔
513
    @overload
4✔
514
    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✔
515
    @overload
4✔
516
    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✔
517
    # fmt: on
518
    async def control_send(
4✔
519
        self,
520
        keys: str,
521
        control: str = '',
522
        title: str = '',
523
        text: str = '',
524
        exclude_title: str = '',
525
        exclude_text: str = '',
526
        *,
527
        title_match_mode: Optional[TitleMatchMode] = None,
528
        detect_hidden_windows: Optional[bool] = None,
529
        blocking: bool = True,
530
    ) -> Union[None, AsyncFutureResult[None]]:
531
        """
532
        Analog for `ControlSend <https://www.autohotkey.com/docs/commands/ControlSend.htm>`_
533
        """
534
        args = [control, keys, title, text, exclude_title, exclude_text]
4✔
535
        if detect_hidden_windows is not None:
4✔
536
            if detect_hidden_windows is True:
4✔
537
                args.append('On')
4✔
538
            elif detect_hidden_windows is False:
×
539
                args.append('Off')
×
540
            else:
541
                raise TypeError(
×
542
                    f'Invalid value for parameter detect_hidden_windows. Expected boolean or None, got {detect_hidden_windows!r}'
543
                )
544
        else:
545
            args.append('')
×
546
        if title_match_mode is not None:
4✔
547
            if isinstance(title_match_mode, tuple):
4✔
548
                match_mode, match_speed = title_match_mode
4✔
549
            elif title_match_mode in (1, 2, 3, 'RegEx'):
×
550
                match_mode = title_match_mode
×
551
                match_speed = ''
×
552
            elif title_match_mode in ('Fast', 'Slow'):
×
553
                match_mode = ''
×
554
                match_speed = title_match_mode
×
555
            else:
556
                raise ValueError(
×
557
                    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}"
558
                )
559
            args.append(str(match_mode))
4✔
560
            args.append(str(match_speed))
4✔
561
        else:
562
            args.append('')
×
563
            args.append('')
×
564
        resp = await self._transport.function_call('AHKControlSend', args, blocking=blocking)
4✔
565
        return resp
4✔
566

567
    # TODO: raw option for control_send
568

569
    def start_hotkeys(self) -> None:
4✔
570
        """
571
        Start the Autohotkey process for triggering hotkeys
572

573
        """
574
        return self._transport.start_hotkeys()
4✔
575

576
    def stop_hotkeys(self) -> None:
4✔
577
        """
578
        Stop the Autohotkey process for triggering hotkeys/hotstrings
579

580
        """
581
        return self._transport.stop_hotkeys()
4✔
582

583
    async def set_detect_hidden_windows(self, value: bool) -> None:
4✔
584
        """
585
        Analog for `DetectHiddenWindows <https://www.autohotkey.com/docs/commands/DetectHiddenWindows.htm>`_
586

587
        :param value: The setting value. ``True`` to turn on hidden window detection, ``False`` to turn it off.
588
        """
589

590
        if value not in (True, False):
4✔
591
            raise TypeError(f'detect hidden windows must be a boolean, got object of type {type(value)}')
×
592
        args = []
4✔
593
        if value is True:
4✔
594
            args.append('On')
4✔
595
        else:
596
            args.append('Off')
×
597
        await self._transport.function_call('AHKSetDetectHiddenWindows', args=args)
4✔
598
        return None
4✔
599

600
    @staticmethod
4✔
601
    def _format_win_args(
4✔
602
        title: str,
603
        text: str,
604
        exclude_title: str,
605
        exclude_text: str,
606
        title_match_mode: Optional[TitleMatchMode] = None,
607
        detect_hidden_windows: Optional[bool] = None,
608
    ) -> List[str]:
609
        args = [title, text, exclude_title, exclude_text]
4✔
610
        if detect_hidden_windows is not None:
4✔
611
            if detect_hidden_windows is True:
4✔
612
                args.append('On')
4✔
613
            elif detect_hidden_windows is False:
4✔
614
                args.append('Off')
4✔
615
            else:
616
                raise TypeError(
×
617
                    f'Invalid value for parameter detect_hidden_windows. Expected boolean or None, got {detect_hidden_windows!r}'
618
                )
619
        else:
620
            args.append('')
4✔
621
        if title_match_mode is not None:
4✔
622
            if isinstance(title_match_mode, tuple):
4✔
623
                match_mode, match_speed = title_match_mode
4✔
624
            elif title_match_mode in (1, 2, 3, 'RegEx'):
×
625
                match_mode = title_match_mode
×
626
                match_speed = ''
×
627
            elif title_match_mode in ('Fast', 'Slow'):
×
628
                match_mode = ''
×
629
                match_speed = title_match_mode
×
630
            else:
631
                raise ValueError(
×
632
                    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}"
633
                )
634
            args.append(str(match_mode))
4✔
635
            args.append(str(match_speed))
4✔
636
        else:
637
            args.append('')
4✔
638
            args.append('')
4✔
639
        return args
4✔
640

641
    # fmt: off
642
    @overload
4✔
643
    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✔
644
    @overload
4✔
645
    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✔
646
    @overload
4✔
647
    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✔
648
    @overload
4✔
649
    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✔
650
    # fmt: on
651
    async def list_windows(
4✔
652
        self,
653
        title: str = '',
654
        text: str = '',
655
        exclude_title: str = '',
656
        exclude_text: str = '',
657
        *,
658
        title_match_mode: Optional[TitleMatchMode] = None,
659
        detect_hidden_windows: Optional[bool] = None,
660
        blocking: bool = True,
661
    ) -> Union[List[AsyncWindow], AsyncFutureResult[List[AsyncWindow]]]:
662
        """
663
        Enumerate all windows matching the criteria.
664

665
        Analog for `WinGet List subcommand <https://www.autohotkey.com/docs/v1/lib/WinGet.htm#List>_`
666
        """
667
        args = self._format_win_args(
4✔
668
            title=title,
669
            text=text,
670
            exclude_title=exclude_title,
671
            exclude_text=exclude_text,
672
            title_match_mode=title_match_mode,
673
            detect_hidden_windows=detect_hidden_windows,
674
        )
675
        resp = await self._transport.function_call('AHKWindowList', args, engine=self, blocking=blocking)
4✔
676
        return resp
4✔
677

678
    # fmt: off
679
    @overload
4✔
680
    async def get_mouse_position(self, coord_mode: Optional[CoordModeRelativeTo] = None, *, blocking: Literal[True]) -> Tuple[int, int]: ...
4✔
681
    @overload
4✔
682
    async def get_mouse_position(self, coord_mode: Optional[CoordModeRelativeTo] = None, *, blocking: Literal[False]) -> AsyncFutureResult[Tuple[int, int]]: ...
4✔
683
    @overload
4✔
684
    async def get_mouse_position(self, coord_mode: Optional[CoordModeRelativeTo] = None) -> Tuple[int, int]: ...
4✔
685
    @overload
4✔
686
    async def get_mouse_position(self, coord_mode: Optional[CoordModeRelativeTo] = None, *, blocking: bool = True) -> Union[Tuple[int, int], AsyncFutureResult[Tuple[int, int]]]: ...
4✔
687
    # fmt: on
688
    async def get_mouse_position(
4✔
689
        self, coord_mode: Optional[CoordModeRelativeTo] = None, *, blocking: bool = True
690
    ) -> Union[Tuple[int, int], AsyncFutureResult[Tuple[int, int]]]:
691
        """
692
        Analog for `MouseGetPos <https://www.autohotkey.com/docs/commands/MouseGetPos.htm>`_
693
        """
694
        if coord_mode:
4✔
695
            args = [str(coord_mode)]
×
696
        else:
697
            args = []
4✔
698
        resp = await self._transport.function_call('AHKMouseGetPos', args, blocking=blocking)
4✔
699
        return resp
4✔
700

701
    @property
4✔
702
    def mouse_position(self) -> AsyncPropertyReturnTupleIntInt:
4✔
703
        """
704
        Convenience property for :py:meth:`get_mouse_position`
705

706
        Setter accepts a tuple of x,y coordinates passed to :py:meth:`mouse_mouse`
707
        """
708
        warnings.warn(  # unasync: remove
×
709
            _PROPERTY_DEPRECATION_WARNING_MESSAGE.format('mouse_position'), category=DeprecationWarning, stacklevel=2
710
        )
711
        return self.get_mouse_position()
×
712

713
    @mouse_position.setter
4✔
714
    def mouse_position(self, new_position: Tuple[int, int]) -> None:
4✔
715
        """
716
        Convenience setter for ``mouse_move``
717

718
        :param new_position: a tuple of x,y coordinates to move to
719
        """
720
        raise RuntimeError('Use of the mouse_position setter is not supported in the async API.')  # unasync: remove
×
721
        x, y = new_position
722
        return self.mouse_move(x=x, y=y, speed=0, relative=False)
723

724
    # fmt: off
725
    @overload
4✔
726
    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✔
727
    @overload
4✔
728
    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✔
729
    @overload
4✔
730
    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✔
731
    @overload
4✔
732
    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✔
733
    # fmt: on
734
    async def mouse_move(
4✔
735
        self,
736
        x: Optional[Union[str, int]] = None,
737
        y: Optional[Union[str, int]] = None,
738
        *,
739
        speed: Optional[int] = None,
740
        relative: bool = False,
741
        blocking: bool = True,
742
    ) -> Union[None, AsyncFutureResult[None]]:
743
        """
744
        Analog for `MouseMove <https://www.autohotkey.com/docs/commands/MouseMove.htm>`_
745
        """
746
        if relative and (x is None or y is None):
4✔
747
            x = x or 0
×
748
            y = y or 0
×
749
        elif not relative and (x is None or y is None):
4✔
750
            posx, posy = await self.get_mouse_position()
×
751
            x = x or posx
×
752
            y = y or posy
×
753

754
        if speed is None:
4✔
755
            speed = 2
4✔
756
        args = [str(x), str(y), str(speed)]
4✔
757
        if relative:
4✔
758
            args.append('R')
4✔
759
        resp = await self._transport.function_call('AHKMouseMove', args, blocking=blocking)
4✔
760
        return resp
4✔
761

762
    async def a_run_script(self, *args: Any, **kwargs: Any) -> Union[str, AsyncFutureResult[str]]:
4✔
763
        """
764
        Deprecated. Use :py:meth:`run_script` instead.
765
        """
766
        warnings.warn('a_run_script is deprecated. Use run_script instead.', DeprecationWarning, stacklevel=2)
×
767
        return await self.run_script(*args, **kwargs)
×
768

769
    # fmt: off
770
    @overload
4✔
771
    async def get_active_window(self) -> Optional[AsyncWindow]: ...
4✔
772
    @overload
4✔
773
    async def get_active_window(self, blocking: Literal[True]) -> Optional[AsyncWindow]: ...
4✔
774
    @overload
4✔
775
    async def get_active_window(self, blocking: Literal[False]) -> AsyncFutureResult[Optional[AsyncWindow]]: ...
4✔
776
    @overload
4✔
777
    async def get_active_window(self, blocking: bool = True) -> Union[Optional[AsyncWindow], AsyncFutureResult[Optional[AsyncWindow]]]: ...
4✔
778
    # fmt: on
779
    async def get_active_window(
4✔
780
        self, blocking: bool = True
781
    ) -> Union[Optional[AsyncWindow], AsyncFutureResult[Optional[AsyncWindow]]]:
782
        """
783
        Gets the currently active window.
784
        """
785
        return await self.win_get(
4✔
786
            title='A', detect_hidden_windows=False, title_match_mode=(1, 'Fast'), blocking=blocking
787
        )
788

789
    @property
4✔
790
    def active_window(self) -> AsyncPropertyReturnOptionalAsyncWindow:
4✔
791
        """
792
        Gets the currently active window. Convenience property for :py:meth:`get_active_window`
793
        """
794
        warnings.warn(  # unasync: remove
×
795
            _PROPERTY_DEPRECATION_WARNING_MESSAGE.format('active_window'), category=DeprecationWarning, stacklevel=2
796
        )
797
        return self.get_active_window()
×
798

799
    async def find_windows(
4✔
800
        self,
801
        func: Optional[AsyncFilterFunc] = None,
802
        *,
803
        title_match_mode: Optional[TitleMatchMode] = None,
804
        title: str = '',
805
        text: str = '',
806
        exclude_title: str = '',
807
        exclude_text: str = '',
808
        exact: Optional[bool] = None,
809
    ) -> List[AsyncWindow]:
810
        if exact is not None and title_match_mode is not None:
×
811
            raise TypeError('exact and match_mode parameters are mutually exclusive')
×
812
        if exact is not None:
×
813
            warnings.warn('exact parameter is deprecated. Use match_mode=3 instead', stacklevel=2)
×
814
            if exact:
×
815
                title_match_mode = (3, 'Fast')
×
816
            else:
817
                title_match_mode = (1, 'Fast')
×
818
        elif title_match_mode is None:
×
819
            title_match_mode = (1, 'Fast')
×
820

821
        windows = await self.list_windows(
×
822
            title=title,
823
            text=text,
824
            exclude_title=exclude_title,
825
            exclude_text=exclude_text,
826
            title_match_mode=title_match_mode,
827
        )
828
        if func is None:
×
829
            return windows
×
830
        else:
831
            ret: List[AsyncWindow] = []
×
832
            for win in windows:
×
833
                match = await func(win)
×
834
                if match:
×
835
                    ret.append(win)
×
836
            return ret
×
837

838
    async def find_windows_by_class(
4✔
839
        self, class_name: str, *, exact: Optional[bool] = None, title_match_mode: Optional[TitleMatchMode] = None
840
    ) -> List[AsyncWindow]:
841
        with warnings.catch_warnings(record=True) as caught_warnings:
×
842
            ret = await self.find_windows(
×
843
                title=f'ahk_class {class_name}', title_match_mode=title_match_mode, exact=exact
844
            )
845
        if caught_warnings:
×
846
            for warning in caught_warnings:
×
847
                warnings.warn(warning.message, warning.category, stacklevel=2)
×
848
        return ret
×
849

850
    async def find_windows_by_text(
4✔
851
        self, text: str, exact: Optional[bool] = None, title_match_mode: Optional[TitleMatchMode] = None
852
    ) -> List[AsyncWindow]:
853
        with warnings.catch_warnings(record=True) as caught_warnings:
×
854
            ret = await self.find_windows(text=text, exact=exact, title_match_mode=title_match_mode)
×
855
        if caught_warnings:
×
856
            for warning in caught_warnings:
×
857
                warnings.warn(warning.message, warning.category, stacklevel=2)
×
858
        return ret
×
859

860
    async def find_windows_by_title(
4✔
861
        self, title: str, exact: Optional[bool] = None, title_match_mode: Optional[TitleMatchMode] = None
862
    ) -> List[AsyncWindow]:
863
        with warnings.catch_warnings(record=True) as caught_warnings:
×
864
            ret = await self.find_windows(title=title, exact=exact, title_match_mode=title_match_mode)
×
865
        if caught_warnings:
×
866
            for warning in caught_warnings:
×
867
                warnings.warn(warning.message, warning.category, stacklevel=2)
×
868
        return ret
×
869

870
    async def find_window(
4✔
871
        self,
872
        func: Optional[AsyncFilterFunc] = None,
873
        *,
874
        title_match_mode: Optional[TitleMatchMode] = None,
875
        title: str = '',
876
        text: str = '',
877
        exclude_title: str = '',
878
        exclude_text: str = '',
879
        exact: Optional[bool] = None,
880
    ) -> Optional[AsyncWindow]:
881
        with warnings.catch_warnings(record=True) as caught_warnings:
×
882
            windows = await self.find_windows(
×
883
                func,
884
                title=title,
885
                text=text,
886
                exclude_title=exclude_title,
887
                exclude_text=exclude_text,
888
                exact=exact,
889
                title_match_mode=title_match_mode,
890
            )
891
        if caught_warnings:
×
892
            for warning in caught_warnings:
×
893
                warnings.warn(warning.message, warning.category, stacklevel=2)
×
894
        return windows[0] if windows else None
×
895

896
    async def find_window_by_class(
4✔
897
        self, class_name: str, exact: Optional[bool] = None, title_match_mode: Optional[TitleMatchMode] = None
898
    ) -> Optional[AsyncWindow]:
899
        with warnings.catch_warnings(record=True) as caught_warnings:
×
900
            windows = await self.find_windows_by_class(
×
901
                class_name=class_name, exact=exact, title_match_mode=title_match_mode
902
            )
903
        if caught_warnings:
×
904
            for warning in caught_warnings:
×
905
                warnings.warn(warning.message, warning.category, stacklevel=2)
×
906
        return windows[0] if windows else None
×
907

908
    async def find_window_by_text(
4✔
909
        self, text: str, exact: Optional[bool] = None, title_match_mode: Optional[TitleMatchMode] = None
910
    ) -> Optional[AsyncWindow]:
911
        with warnings.catch_warnings(record=True) as caught_warnings:
×
912
            windows = await self.find_windows_by_text(text=text, exact=exact, title_match_mode=title_match_mode)
×
913
        if caught_warnings:
×
914
            for warning in caught_warnings:
×
915
                warnings.warn(warning.message, warning.category, stacklevel=2)
×
916
        return windows[0] if windows else None
×
917

918
    async def find_window_by_title(
4✔
919
        self, title: str, exact: Optional[bool] = None, title_match_mode: Optional[TitleMatchMode] = None
920
    ) -> Optional[AsyncWindow]:
921
        with warnings.catch_warnings(record=True) as caught_warnings:
×
922
            windows = await self.find_windows_by_title(title=title, exact=exact, title_match_mode=title_match_mode)
×
923
        if caught_warnings:
×
924
            for warning in caught_warnings:
×
925
                warnings.warn(warning.message, warning.category, stacklevel=2)
×
926
        return windows[0] if windows else None
×
927

928
    async def get_volume(self, device_number: int = 1) -> float:
4✔
929
        """
930
        Analog for `SoundGetWaveVolume <https://www.autohotkey.com/docs/commands/SoundGetWaveVolume.htm>`_
931
        """
932
        args = [str(device_number)]
×
933
        response = await self._transport.function_call('AHKGetVolume', args)
×
934
        return response
×
935

936
    # fmt: off
937
    @overload
4✔
938
    async def key_down(self, key: Union[str, Key]) -> None: ...
4✔
939
    @overload
4✔
940
    async def key_down(self, key: Union[str, Key], *, blocking: Literal[True]) -> None: ...
4✔
941
    @overload
4✔
942
    async def key_down(self, key: Union[str, Key], *, blocking: Literal[False]) -> AsyncFutureResult[None]: ...
4✔
943
    @overload
4✔
944
    async def key_down(self, key: Union[str, Key], *, blocking: bool = True) -> Union[None, AsyncFutureResult[None]]: ...
4✔
945
    # fmt: on
946
    async def key_down(self, key: Union[str, Key], *, blocking: bool = True) -> Union[None, AsyncFutureResult[None]]:
4✔
947
        """
948
        Shortcut for :py:meth:`send_input` but transforms specified key to perform a key "DOWN" only (no release)
949
        """
950
        if isinstance(key, str):
4✔
951
            key = Key(key_name=key)
4✔
952
        if blocking:
4✔
953
            await self.send_input(key.DOWN, blocking=True)
4✔
954
            return None
4✔
955
        else:
956
            return await self.send_input(key.DOWN, blocking=False)
×
957

958
    # fmt: off
959
    @overload
4✔
960
    async def key_press(self, key: Union[str, Key], *, release: bool = True) -> None: ...
4✔
961
    @overload
4✔
962
    async def key_press(self, key: Union[str, Key], *, blocking: Literal[True], release: bool = True) -> None: ...
4✔
963
    @overload
4✔
964
    async def key_press(self, key: Union[str, Key], *, blocking: Literal[False], release: bool = True) -> AsyncFutureResult[None]: ...
4✔
965
    @overload
4✔
966
    async def key_press(self, key: Union[str, Key], *, release: bool = True, blocking: bool = True) -> Union[None, AsyncFutureResult[None]]: ...
4✔
967
    # fmt: on
968
    async def key_press(
4✔
969
        self, key: Union[str, Key], *, release: bool = True, blocking: bool = True
970
    ) -> Union[None, AsyncFutureResult[None]]:
971
        """
972
        Press (and release) a key. Sends `:py:meth:`key_down` then, if ``release`` is ``True`` (the default), sends
973
        :py:meth:`key_up` subsequently.
974
        """
975
        if blocking:
4✔
976
            await self.key_down(key, blocking=True)
4✔
977
            if release:
4✔
978
                await self.key_up(key, blocking=True)
4✔
979
            return None
4✔
980
        else:
981
            d = await self.key_down(key, blocking=False)
×
982
            if release:
×
983
                return await self.key_up(key, blocking=False)
×
984
            return d
×
985

986
    # fmt: off
987
    @overload
4✔
988
    async def key_release(self, key: Union[str, Key]) -> None: ...
4✔
989
    @overload
4✔
990
    async def key_release(self, key: Union[str, Key], *, blocking: Literal[True]) -> None: ...
4✔
991
    @overload
4✔
992
    async def key_release(self, key: Union[str, Key], *, blocking: Literal[False]) -> AsyncFutureResult[None]: ...
4✔
993
    @overload
4✔
994
    async def key_release(self, key: Union[str, Key], *, blocking: bool = True) -> Union[None, AsyncFutureResult[None]]: ...
4✔
995
    # fmt: on
996
    async def key_release(self, key: Union[str, Key], *, blocking: bool = True) -> Union[None, AsyncFutureResult[None]]:
4✔
997
        """
998
        Alias for :py:meth:`key_up`
999
        """
1000
        if blocking:
×
1001
            await self.key_up(key=key, blocking=True)
×
1002
            return None
×
1003
        else:
1004
            return await self.key_up(key=key, blocking=False)
×
1005

1006
    # fmt: off
1007
    @overload
4✔
1008
    async def key_state(self, key_name: str, *, mode: Optional[Literal['T', 'P']] = None) -> Union[float, int, str, None]: ...
4✔
1009
    @overload
4✔
1010
    async def key_state(self, key_name: str, *, mode: Optional[Literal['T', 'P']] = None, blocking: Literal[True]) -> Union[float, int, str, None]: ...
4✔
1011
    @overload
4✔
1012
    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✔
1013
    @overload
4✔
1014
    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✔
1015
    # fmt: on
1016
    async def key_state(
4✔
1017
        self, key_name: str, *, mode: Optional[Literal['T', 'P']] = None, blocking: bool = True
1018
    ) -> Union[
1019
        int,
1020
        float,
1021
        str,
1022
        None,
1023
        AsyncFutureResult[str],
1024
        AsyncFutureResult[int],
1025
        AsyncFutureResult[float],
1026
        AsyncFutureResult[None],
1027
    ]:
1028
        """
1029
        Analog for `GetKeyState <https://www.autohotkey.com/docs/commands/GetKeyState.htm#command>`_
1030
        """
1031
        args: List[str] = [key_name]
4✔
1032
        if mode is not None:
4✔
1033
            if mode not in ('T', 'P'):
4✔
1034
                raise ValueError(f'Invalid value for mode parameter. Mode must be `T` or `P`. Got {mode!r}')
×
1035
            args.append(mode)
4✔
1036
        resp = await self._transport.function_call('AHKKeyState', args, blocking=blocking)
4✔
1037
        return resp
4✔
1038

1039
    # fmt: off
1040
    @overload
4✔
1041
    async def key_up(self, key: Union[str, Key]) -> None: ...
4✔
1042
    @overload
4✔
1043
    async def key_up(self, key: Union[str, Key], *, blocking: Literal[True]) -> None: ...
4✔
1044
    @overload
4✔
1045
    async def key_up(self, key: Union[str, Key], *, blocking: Literal[False]) -> AsyncFutureResult[None]: ...
4✔
1046
    @overload
4✔
1047
    async def key_up(self, key: Union[str, Key], blocking: bool = True) -> Union[None, AsyncFutureResult[None]]: ...
4✔
1048
    # fmt: on
1049
    async def key_up(self, key: Union[str, Key], blocking: bool = True) -> Union[None, AsyncFutureResult[None]]:
4✔
1050
        """
1051
        Shortcut for :py:meth:`send_input` but transforms specified key to perform a key "UP" only. Useful if the key
1052
        was previously pressed down but not released.
1053
        """
1054
        if isinstance(key, str):
4✔
1055
            key = Key(key_name=key)
4✔
1056
        if blocking:
4✔
1057
            await self.send_input(key.UP, blocking=True)
4✔
1058
            return None
4✔
1059
        else:
1060
            return await self.send_input(key.UP, blocking=False)
×
1061

1062
    # fmt: off
1063
    @overload
4✔
1064
    async def key_wait(self, key_name: str, *, timeout: Optional[int] = None, logical_state: bool = False, released: bool = False) -> int: ...
4✔
1065
    @overload
4✔
1066
    async def key_wait(self, key_name: str, *, blocking: Literal[True], timeout: Optional[int] = None, logical_state: bool = False, released: bool = False) -> int: ...
4✔
1067
    @overload
4✔
1068
    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✔
1069
    @overload
4✔
1070
    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✔
1071
    # fmt: on
1072
    async def key_wait(
4✔
1073
        self,
1074
        key_name: str,
1075
        *,
1076
        timeout: Optional[int] = None,
1077
        logical_state: bool = False,
1078
        released: bool = False,
1079
        blocking: bool = True,
1080
    ) -> Union[int, AsyncFutureResult[int]]:
1081
        """
1082
        Analog for `KeyWait <https://www.autohotkey.com/docs/commands/KeyWait.htm>`_
1083
        """
1084
        options = ''
×
1085
        if not released:
×
1086
            options += 'D'
×
1087
        if logical_state:
×
1088
            options += 'L'
×
1089
        if timeout:
×
1090
            options += f'T{timeout}'
×
1091
        args = [key_name]
×
1092
        if options:
×
1093
            args.append(options)
×
1094

1095
        resp = await self._transport.function_call('AHKKeyWait', args, blocking=blocking)
×
1096
        return resp
×
1097

1098
    async def run_script(
4✔
1099
        self, script_text_or_path: str, /, *, blocking: bool = True, timeout: Optional[int] = None
1100
    ) -> Union[str, AsyncFutureResult[str]]:
1101
        """
1102
        Run an AutoHotkey script.
1103
        Can either be a path to a script (``.ahk``) file or a string containing script contents
1104
        """
1105
        return await self._transport.run_script(script_text_or_path, blocking=blocking, timeout=timeout)
4✔
1106

1107
    async def set_send_level(self, level: int) -> None:
4✔
1108
        """
1109
        Analog for `SendLevel <https://www.autohotkey.com/docs/commands/SendLevel.htm>`_
1110
        """
1111
        if not isinstance(level, int):
4✔
1112
            raise TypeError('level must be an integer between 0 and 100')
×
1113
        if not 0 <= level <= 100:
4✔
1114
            raise ValueError('level value must be between 0 and 100')
×
1115
        args = [str(level)]
4✔
1116
        await self._transport.function_call('AHKSetSendLevel', args)
4✔
1117

1118
    async def get_send_level(self) -> int:
4✔
1119
        """
1120
        Get the current `SendLevel <https://www.autohotkey.com/docs/commands/SendLevel.htm>`_
1121
        (I.E. the value of ``A_SendLevel``)
1122
        """
1123
        resp = await self._transport.function_call('AHKGetSendLevel')
×
1124
        return resp
×
1125

1126
    # fmt: off
1127
    @overload
4✔
1128
    async def send(self, s: str, *, raw: bool = False, key_delay: Optional[int] = None, key_press_duration: Optional[int] = None) -> None: ...
4✔
1129
    @overload
4✔
1130
    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✔
1131
    @overload
4✔
1132
    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✔
1133
    @overload
4✔
1134
    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✔
1135
    # fmt: on
1136
    async def send(
4✔
1137
        self,
1138
        s: str,
1139
        *,
1140
        raw: bool = False,
1141
        key_delay: Optional[int] = None,
1142
        key_press_duration: Optional[int] = None,
1143
        blocking: bool = True,
1144
    ) -> Union[None, AsyncFutureResult[None]]:
1145
        """
1146
        Analog for `Send <https://www.autohotkey.com/docs/v1/lib/Send.htm>`_
1147
        """
1148
        args = [s]
4✔
1149
        if key_delay:
4✔
1150
            args.append(str(key_delay))
×
1151
        else:
1152
            args.append('')
4✔
1153
        if key_press_duration:
4✔
1154
            args.append(str(key_press_duration))
×
1155
        else:
1156
            args.append('')
4✔
1157

1158
        if raw:
4✔
1159
            raw_resp = await self._transport.function_call('AHKSendRaw', args=args, blocking=blocking)
×
1160
            return raw_resp
×
1161
        else:
1162
            resp = await self._transport.function_call('AHKSend', args=args, blocking=blocking)
4✔
1163
            return resp
4✔
1164

1165
    # fmt: off
1166
    @overload
4✔
1167
    async def send_raw(self, s: str, *, key_delay: Optional[int] = None, key_press_duration: Optional[int] = None) -> None: ...
4✔
1168
    @overload
4✔
1169
    async def send_raw(self, s: str, *, key_delay: Optional[int] = None, key_press_duration: Optional[int] = None, blocking: Literal[True]) -> None: ...
4✔
1170
    @overload
4✔
1171
    async def send_raw(self, s: str, *, key_delay: Optional[int] = None, key_press_duration: Optional[int] = None, blocking: Literal[False]) -> AsyncFutureResult[None]: ...
4✔
1172
    @overload
4✔
1173
    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✔
1174
    # fmt: on
1175
    async def send_raw(
4✔
1176
        self,
1177
        s: str,
1178
        *,
1179
        key_delay: Optional[int] = None,
1180
        key_press_duration: Optional[int] = None,
1181
        blocking: bool = True,
1182
    ) -> Union[None, AsyncFutureResult[None]]:
1183
        """
1184
        Analog for `SendRaw <https://www.autohotkey.com/docs/v1/lib/Send.htm>`_
1185
        """
1186
        resp = await self.send(
×
1187
            s, raw=True, key_delay=key_delay, key_press_duration=key_press_duration, blocking=blocking
1188
        )
1189
        return resp
×
1190

1191
    # fmt: off
1192
    @overload
4✔
1193
    async def send_input(self, s: str) -> None: ...
4✔
1194
    @overload
4✔
1195
    async def send_input(self, s: str, *, blocking: Literal[True]) -> None: ...
4✔
1196
    @overload
4✔
1197
    async def send_input(self, s: str, *, blocking: Literal[False]) -> AsyncFutureResult[None]: ...
4✔
1198
    @overload
4✔
1199
    async def send_input(self, s: str, *, blocking: bool = True) -> Union[None, AsyncFutureResult[None]]: ...
4✔
1200
    # fmt: on
1201
    async def send_input(self, s: str, *, blocking: bool = True) -> Union[None, AsyncFutureResult[None]]:
4✔
1202
        """
1203
        Analog for `SendInput <https://www.autohotkey.com/docs/v1/lib/Send.htm>`_
1204
        """
1205
        args = [s]
4✔
1206
        resp = await self._transport.function_call('AHKSendInput', args, blocking=blocking)
4✔
1207
        return resp
4✔
1208

1209
    # fmt: off
1210
    @overload
4✔
1211
    async def type(self, s: str) -> None: ...
4✔
1212
    @overload
4✔
1213
    async def type(self, s: str, *, blocking: Literal[True]) -> None: ...
4✔
1214
    @overload
4✔
1215
    async def type(self, s: str, *, blocking: Literal[False]) -> AsyncFutureResult[None]: ...
4✔
1216
    @overload
4✔
1217
    async def type(self, s: str, *, blocking: bool = True) -> Union[None, AsyncFutureResult[None]]: ...
4✔
1218
    # fmt: on
1219
    async def type(self, s: str, *, blocking: bool = True) -> Union[None, AsyncFutureResult[None]]:
4✔
1220
        """
1221
        Like :py:meth:`send_input` but performs necessary escapes for you.
1222
        """
1223
        resp = await self.send_input(type_escape(s), blocking=blocking)
4✔
1224
        return resp
4✔
1225

1226
    # fmt: off
1227
    @overload
4✔
1228
    async def send_play(self, s: str, *, key_delay: Optional[int] = None, key_press_duration: Optional[int] = None) -> None: ...
4✔
1229
    @overload
4✔
1230
    async def send_play(self, s: str, *, key_delay: Optional[int] = None, key_press_duration: Optional[int] = None, blocking: Literal[True]) -> None: ...
4✔
1231
    @overload
4✔
1232
    async def send_play(self, s: str, *, key_delay: Optional[int] = None, key_press_duration: Optional[int] = None, blocking: Literal[False]) -> AsyncFutureResult[None]: ...
4✔
1233
    @overload
4✔
1234
    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✔
1235
    # fmt: on
1236
    async def send_play(
4✔
1237
        self,
1238
        s: str,
1239
        *,
1240
        key_delay: Optional[int] = None,
1241
        key_press_duration: Optional[int] = None,
1242
        blocking: bool = True,
1243
    ) -> Union[None, AsyncFutureResult[None]]:
1244
        """
1245
        Analog for `SendPlay <https://www.autohotkey.com/docs/v1/lib/Send.htm>`_
1246
        """
1247
        args = [s]
×
1248
        if key_delay:
×
1249
            args.append(str(key_delay))
×
1250
        else:
1251
            args.append('')
×
1252
        if key_press_duration:
×
1253
            args.append(str(key_press_duration))
×
1254
        else:
1255
            args.append('')
×
1256

1257
        resp = await self._transport.function_call('AHKSendPlay', args=args, blocking=blocking)
×
1258
        return resp
×
1259

1260
    # fmt: off
1261
    @overload
4✔
1262
    async def set_capslock_state(self, state: Optional[Literal[0, 1, 'On', 'Off', 'AlwaysOn', 'AlwaysOff']] = None) -> None: ...
4✔
1263
    @overload
4✔
1264
    async def set_capslock_state(self, state: Optional[Literal[0, 1, 'On', 'Off', 'AlwaysOn', 'AlwaysOff']] = None, *, blocking: Literal[True]) -> None: ...
4✔
1265
    @overload
4✔
1266
    async def set_capslock_state(self, state: Optional[Literal[0, 1, 'On', 'Off', 'AlwaysOn', 'AlwaysOff']] = None, *, blocking: Literal[False]) -> AsyncFutureResult[None]: ...
4✔
1267
    @overload
4✔
1268
    async def set_capslock_state(self, state: Optional[Literal[0, 1, 'On', 'Off', 'AlwaysOn', 'AlwaysOff']] = None, *, blocking: bool = True) -> Union[None, AsyncFutureResult[None]]: ...
4✔
1269
    # fmt: on
1270
    async def set_capslock_state(
4✔
1271
        self, state: Optional[Literal[0, 1, 'On', 'Off', 'AlwaysOn', 'AlwaysOff']] = None, *, blocking: bool = True
1272
    ) -> Union[None, AsyncFutureResult[None]]:
1273
        """
1274
        Analog for `SetCapsLockState <https://www.autohotkey.com/docs/commands/SetNumScrollCapsLockState.htm>`_
1275
        """
1276
        args: List[str] = []
4✔
1277
        if state is not None:
4✔
1278
            if str(state).lower() not in ('1', '0', 'on', 'off', 'alwayson', 'alwaysoff'):
4✔
1279
                raise ValueError(
×
1280
                    f'Invalid value for state. Must be one of On, Off, AlwaysOn, AlwaysOff or None. Got {state!r}'
1281
                )
1282
            args.append(str(state))
4✔
1283

1284
        resp = await self._transport.function_call('AHKSetCapsLockState', args, blocking=blocking)
4✔
1285
        return resp
4✔
1286

1287
    # fmt: off
1288
    @overload
4✔
1289
    async def set_volume(self, value: int, device_number: int = 1) -> None: ...
4✔
1290
    @overload
4✔
1291
    async def set_volume(self, value: int, device_number: int = 1, *, blocking: Literal[False]) -> AsyncFutureResult[None]: ...
4✔
1292
    @overload
4✔
1293
    async def set_volume(self, value: int, device_number: int = 1, *, blocking: Literal[True]) -> None: ...
4✔
1294
    @overload
4✔
1295
    async def set_volume(self, value: int, device_number: int = 1, *, blocking: bool = True) -> Union[None, AsyncFutureResult[None]]: ...
4✔
1296
    # fmt: on
1297
    async def set_volume(
4✔
1298
        self, value: int, device_number: int = 1, *, blocking: bool = True
1299
    ) -> Union[None, AsyncFutureResult[None]]:
1300
        """
1301
        Analog for `SoundSetWaveVolume <https://www.autohotkey.com/docs/commands/SoundSetWaveVolume.htm>`_
1302
        """
1303
        args = [str(device_number), str(value)]
×
1304
        return await self._transport.function_call('AHKSetVolume', args, blocking=blocking)
×
1305

1306
    # fmt: off
1307
    @overload
4✔
1308
    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✔
1309
    @overload
4✔
1310
    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✔
1311
    @overload
4✔
1312
    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✔
1313
    @overload
4✔
1314
    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✔
1315
    # fmt: on
1316
    async def show_traytip(
4✔
1317
        self,
1318
        title: str,
1319
        text: str,
1320
        second: float = 1.0,
1321
        type_id: int = 1,
1322
        *,
1323
        silent: bool = False,
1324
        large_icon: bool = False,
1325
        blocking: bool = True,
1326
    ) -> Union[None, AsyncFutureResult[None]]:
1327
        """
1328
        Analog for `TrayTip <https://www.autohotkey.com/docs/commands/TrayTip.htm>`_
1329
        """
1330
        option = type_id + (16 if silent else 0) + (32 if large_icon else 0)
×
1331
        args = [title, text, str(second), str(option)]
×
1332
        return await self._transport.function_call('AHKTrayTip', args, blocking=blocking)
×
1333

1334
    # fmt: off
1335
    @overload
4✔
1336
    async def show_error_traytip(self, title: str, text: str, second: float = 1.0, *, silent: bool = False, large_icon: bool = False) -> None: ...
4✔
1337
    @overload
4✔
1338
    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✔
1339
    @overload
4✔
1340
    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✔
1341
    @overload
4✔
1342
    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✔
1343
    # fmt: on
1344
    async def show_error_traytip(
4✔
1345
        self,
1346
        title: str,
1347
        text: str,
1348
        second: float = 1.0,
1349
        *,
1350
        silent: bool = False,
1351
        large_icon: bool = False,
1352
        blocking: bool = True,
1353
    ) -> Union[None, AsyncFutureResult[None]]:
1354
        """
1355
        Convenience method for :py:meth:`show_traytip` for error-style messages
1356
        """
1357
        return await self.show_traytip(
×
1358
            title=title, text=text, second=second, type_id=3, silent=silent, large_icon=large_icon, blocking=blocking
1359
        )
1360

1361
    # fmt: off
1362
    @overload
4✔
1363
    async def show_info_traytip(self, title: str, text: str, second: float = 1.0, *, silent: bool = False, large_icon: bool = False) -> None: ...
4✔
1364
    @overload
4✔
1365
    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✔
1366
    @overload
4✔
1367
    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✔
1368
    @overload
4✔
1369
    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✔
1370
    # fmt: on
1371
    async def show_info_traytip(
4✔
1372
        self,
1373
        title: str,
1374
        text: str,
1375
        second: float = 1.0,
1376
        *,
1377
        silent: bool = False,
1378
        large_icon: bool = False,
1379
        blocking: bool = True,
1380
    ) -> Union[None, AsyncFutureResult[None]]:
1381
        """
1382
        Convenience method for :py:meth:`show_traytip` for info-style messages
1383
        """
1384
        return await self.show_traytip(
×
1385
            title=title, text=text, second=second, type_id=1, silent=silent, large_icon=large_icon, blocking=blocking
1386
        )
1387

1388
    # fmt: off
1389
    @overload
4✔
1390
    async def show_warning_traytip(self, title: str, text: str, second: float = 1.0, *, silent: bool = False, large_icon: bool = False) -> None: ...
4✔
1391
    @overload
4✔
1392
    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✔
1393
    @overload
4✔
1394
    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✔
1395
    @overload
4✔
1396
    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✔
1397
    # fmt: on
1398
    async def show_warning_traytip(
4✔
1399
        self,
1400
        title: str,
1401
        text: str,
1402
        second: float = 1.0,
1403
        *,
1404
        silent: bool = False,
1405
        large_icon: bool = False,
1406
        blocking: bool = True,
1407
    ) -> Union[None, AsyncFutureResult[None]]:
1408
        """
1409
        Convenience method for :py:meth:`show_traytip` for warning-style messages
1410
        """
1411
        return await self.show_traytip(
×
1412
            title=title, text=text, second=second, type_id=2, silent=silent, large_icon=large_icon, blocking=blocking
1413
        )
1414

1415
    async def show_tooltip(
4✔
1416
        self,
1417
        text: str = '',
1418
        x: Optional[int] = None,
1419
        y: Optional[int] = None,
1420
        which: int = 1,
1421
    ) -> None:
1422
        """
1423
        Analog for `ToolTip <https://www.autohotkey.com/docs/commands/ToolTip.htm>`_
1424
        """
1425
        if which not in range(1, 21):
×
1426
            raise ValueError('which must be an integer between 1 and 20')
×
1427
        args = [text]
×
1428
        if x is not None:
×
1429
            args.append(str(x))
×
1430
        else:
1431
            args.append('')
×
1432
        if y is not None:
×
1433
            args.append(str(y))
×
1434
        else:
1435
            args.append('')
×
1436
        await self._transport.function_call('AHKShowToolTip', args)
×
1437

1438
    async def hide_tooltip(self, which: int = 1) -> None:
4✔
1439
        await self.show_tooltip(which=which)
×
1440

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

1446
        Uses the `Tip subcommand <https://www.autohotkey.com/docs/v1/lib/Menu.htm#Tip>`_
1447
        """
1448

1449
        args = [value]
×
1450
        await self._transport.function_call('AHKMenuTrayTip', args)
×
1451
        return None
×
1452

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

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

1460
        If called with no parameters, the tray icon will be reset to the original default.
1461
        """
1462
        args = [filename, str(icon_number)]
×
1463
        if freeze is True:
×
1464
            args.append('1')
×
1465
        elif freeze is False:
×
1466
            args.append('0')
×
1467
        await self._transport.function_call('AHKMenuTrayIcon', args)
×
1468
        return None
×
1469

1470
    async def menu_tray_icon_show(self) -> None:
4✔
1471
        """
1472
        Show ('unhide') the tray icon previously hidden by :py:class:`~ahk.directives.NoTrayIcon` directive.
1473
        Does not affect tray icon for AHK processes started with :py:meth:`run_script` or ``blocking=False``
1474
        """
1475
        await self._transport.function_call('AHKMenuTrayShow')
×
1476
        return None
×
1477

1478
    # fmt: off
1479
    @overload
4✔
1480
    async def sound_beep(self, frequency: int = 523, duration: int = 150) -> None: ...
4✔
1481
    @overload
4✔
1482
    async def sound_beep(self, frequency: int = 523, duration: int = 150, *, blocking: Literal[False]) -> AsyncFutureResult[None]: ...
4✔
1483
    @overload
4✔
1484
    async def sound_beep(self, frequency: int = 523, duration: int = 150, *, blocking: Literal[True]) -> None: ...
4✔
1485
    @overload
4✔
1486
    async def sound_beep(self, frequency: int = 523, duration: int = 150, *, blocking: bool = True) -> Optional[AsyncFutureResult[None]]: ...
4✔
1487
    # fmt: on
1488
    async def sound_beep(
4✔
1489
        self, frequency: int = 523, duration: int = 150, *, blocking: bool = True
1490
    ) -> Optional[AsyncFutureResult[None]]:
1491
        """
1492
        Analog for `SoundBeep <https://www.autohotkey.com/docs/commands/SoundBeep.htm>`_
1493
        """
1494
        args = [str(frequency), str(duration)]
×
1495
        await self._transport.function_call('AHKSoundBeep', args, blocking=blocking)
×
1496
        return None
×
1497

1498
    # fmt: off
1499
    @overload
4✔
1500
    async def sound_get(self, device_number: int = 1, component_type: str = 'MASTER', control_type: str = 'VOLUME') -> str: ...
4✔
1501
    @overload
4✔
1502
    async def sound_get(self, device_number: int = 1, component_type: str = 'MASTER', control_type: str = 'VOLUME', *, blocking: Literal[False]) -> AsyncFutureResult[str]: ...
4✔
1503
    @overload
4✔
1504
    async def sound_get(self, device_number: int = 1, component_type: str = 'MASTER', control_type: str = 'VOLUME', *, blocking: Literal[True]) -> str: ...
4✔
1505
    @overload
4✔
1506
    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✔
1507
    # fmt: on
1508
    async def sound_get(
4✔
1509
        self,
1510
        device_number: int = 1,
1511
        component_type: str = 'MASTER',
1512
        control_type: str = 'VOLUME',
1513
        *,
1514
        blocking: bool = True,
1515
    ) -> Union[str, AsyncFutureResult[str]]:
1516
        """
1517
        Analog for `SoundGet <https://www.autohotkey.com/docs/commands/SoundGet.htm>`_
1518
        """
1519
        args = [str(device_number), component_type, control_type]
×
1520
        return await self._transport.function_call('AHKSoundGet', args, blocking=blocking)
×
1521

1522
    # fmt: off
1523
    @overload
4✔
1524
    async def sound_play(self, filename: str) -> None: ...
4✔
1525
    @overload
4✔
1526
    async def sound_play(self, filename: str, *, blocking: Literal[False]) -> AsyncFutureResult[None]: ...
4✔
1527
    @overload
4✔
1528
    async def sound_play(self, filename: str, *, blocking: Literal[True]) -> None: ...
4✔
1529
    @overload
4✔
1530
    async def sound_play(self, filename: str, *, blocking: bool = True) -> Union[None, AsyncFutureResult[None]]: ...
4✔
1531
    # fmt: on
1532
    async def sound_play(self, filename: str, *, blocking: bool = True) -> Union[None, AsyncFutureResult[None]]:
4✔
1533
        """
1534
        Analog for `SoundPlay <https://www.autohotkey.com/docs/commands/SoundPlay.htm>`_
1535
        """
1536
        return await self._transport.function_call('AHKSoundPlay', [filename], blocking=blocking)
×
1537

1538
    async def sound_set(
4✔
1539
        self,
1540
        value: Union[str, int, float],
1541
        device_number: int = 1,
1542
        component_type: str = 'MASTER',
1543
        control_type: str = 'VOLUME',
1544
        *,
1545
        blocking: bool = True,
1546
    ) -> Union[None, AsyncFutureResult[None]]:
1547
        """
1548
        Analog for `SoundSet <https://www.autohotkey.com/docs/commands/SoundSet.htm>`_
1549
        """
1550
        args = [str(device_number), component_type, control_type, str(value)]
×
1551
        return await self._transport.function_call('AHKSoundSet', args, blocking=blocking)
×
1552

1553
    # fmt: off
1554
    @overload
4✔
1555
    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✔
1556
    @overload
4✔
1557
    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✔
1558
    @overload
4✔
1559
    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✔
1560
    @overload
4✔
1561
    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✔
1562
    # fmt: on
1563
    async def win_get(
4✔
1564
        self,
1565
        title: str = '',
1566
        text: str = '',
1567
        exclude_title: str = '',
1568
        exclude_text: str = '',
1569
        *,
1570
        title_match_mode: Optional[TitleMatchMode] = None,
1571
        detect_hidden_windows: Optional[bool] = None,
1572
        blocking: bool = True,
1573
    ) -> Union[AsyncWindow, None, AsyncFutureResult[Union[None, AsyncWindow]]]:
1574
        """
1575
        Analog for `WinGet <https://www.autohotkey.com/docs/commands/WinGet.htm>`_
1576
        """
1577
        args = self._format_win_args(
4✔
1578
            title=title,
1579
            text=text,
1580
            exclude_title=exclude_title,
1581
            exclude_text=exclude_text,
1582
            title_match_mode=title_match_mode,
1583
            detect_hidden_windows=detect_hidden_windows,
1584
        )
1585
        resp = await self._transport.function_call('AHKWinGetID', args, blocking=blocking, engine=self)
4✔
1586
        return resp
4✔
1587

1588
    # fmt: off
1589
    @overload
4✔
1590
    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✔
1591
    @overload
4✔
1592
    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✔
1593
    @overload
4✔
1594
    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✔
1595
    @overload
4✔
1596
    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✔
1597
    # fmt: on
1598
    async def win_get_text(
4✔
1599
        self,
1600
        title: str = '',
1601
        text: str = '',
1602
        exclude_title: str = '',
1603
        exclude_text: str = '',
1604
        *,
1605
        title_match_mode: Optional[TitleMatchMode] = None,
1606
        detect_hidden_windows: Optional[bool] = None,
1607
        blocking: bool = True,
1608
    ) -> Union[str, AsyncFutureResult[str]]:
1609
        args = self._format_win_args(
4✔
1610
            title=title,
1611
            text=text,
1612
            exclude_title=exclude_title,
1613
            exclude_text=exclude_text,
1614
            title_match_mode=title_match_mode,
1615
            detect_hidden_windows=detect_hidden_windows,
1616
        )
1617
        resp = await self._transport.function_call('AHKWinGetText', args, blocking=blocking)
4✔
1618
        return resp
4✔
1619

1620
    # fmt: off
1621
    @overload
4✔
1622
    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✔
1623
    @overload
4✔
1624
    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✔
1625
    @overload
4✔
1626
    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✔
1627
    @overload
4✔
1628
    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✔
1629
    # fmt: on
1630
    async def win_get_title(
4✔
1631
        self,
1632
        title: str = '',
1633
        text: str = '',
1634
        exclude_title: str = '',
1635
        exclude_text: str = '',
1636
        *,
1637
        title_match_mode: Optional[TitleMatchMode] = None,
1638
        detect_hidden_windows: Optional[bool] = None,
1639
        blocking: bool = True,
1640
    ) -> Union[str, AsyncFutureResult[str]]:
1641
        args = self._format_win_args(
4✔
1642
            title=title,
1643
            text=text,
1644
            exclude_title=exclude_title,
1645
            exclude_text=exclude_text,
1646
            title_match_mode=title_match_mode,
1647
            detect_hidden_windows=detect_hidden_windows,
1648
        )
1649
        resp = await self._transport.function_call('AHKWinGetTitle', args, blocking=blocking)
4✔
1650
        return resp
4✔
1651

1652
    # fmt: off
1653
    @overload
4✔
1654
    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✔
1655
    @overload
4✔
1656
    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✔
1657
    @overload
4✔
1658
    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✔
1659
    @overload
4✔
1660
    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✔
1661
    # fmt: on
1662
    async def win_get_class(
4✔
1663
        self,
1664
        title: str = '',
1665
        text: str = '',
1666
        exclude_title: str = '',
1667
        exclude_text: str = '',
1668
        *,
1669
        title_match_mode: Optional[TitleMatchMode] = None,
1670
        detect_hidden_windows: Optional[bool] = None,
1671
        blocking: bool = True,
1672
    ) -> Union[str, AsyncFutureResult[str]]:
1673
        """
1674
        Analog for `WinGetClass <https://www.autohotkey.com/docs/commands/WinGetClass.htm>`_
1675
        """
1676
        args = self._format_win_args(
4✔
1677
            title=title,
1678
            text=text,
1679
            exclude_title=exclude_title,
1680
            exclude_text=exclude_text,
1681
            title_match_mode=title_match_mode,
1682
            detect_hidden_windows=detect_hidden_windows,
1683
        )
1684
        resp = await self._transport.function_call('AHKWinGetClass', args, blocking=blocking)
4✔
1685
        return resp
4✔
1686

1687
    # fmt: off
1688
    @overload
4✔
1689
    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✔
1690
    @overload
4✔
1691
    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✔
1692
    @overload
4✔
1693
    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✔
1694
    @overload
4✔
1695
    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✔
1696
    # fmt: on
1697
    async def win_get_position(
4✔
1698
        self,
1699
        title: str = '',
1700
        text: str = '',
1701
        exclude_title: str = '',
1702
        exclude_text: str = '',
1703
        *,
1704
        title_match_mode: Optional[TitleMatchMode] = None,
1705
        detect_hidden_windows: Optional[bool] = None,
1706
        blocking: bool = True,
1707
    ) -> Union[Position, None, AsyncFutureResult[Union[Position, None]]]:
1708
        """
1709
        Analog for `WinGetPos <https://www.autohotkey.com/docs/commands/WinGetPos.htm>`_
1710
        """
1711
        args = self._format_win_args(
4✔
1712
            title=title,
1713
            text=text,
1714
            exclude_title=exclude_title,
1715
            exclude_text=exclude_text,
1716
            title_match_mode=title_match_mode,
1717
            detect_hidden_windows=detect_hidden_windows,
1718
        )
1719
        resp = await self._transport.function_call('AHKWinGetPos', args, blocking=blocking, engine=self)
4✔
1720
        return resp
4✔
1721

1722
    # fmt: off
1723
    @overload
4✔
1724
    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✔
1725
    @overload
4✔
1726
    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✔
1727
    @overload
4✔
1728
    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✔
1729
    @overload
4✔
1730
    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✔
1731
    # fmt: on
1732
    async def win_get_idlast(
4✔
1733
        self,
1734
        title: str = '',
1735
        text: str = '',
1736
        exclude_title: str = '',
1737
        exclude_text: str = '',
1738
        *,
1739
        title_match_mode: Optional[TitleMatchMode] = None,
1740
        detect_hidden_windows: Optional[bool] = None,
1741
        blocking: bool = True,
1742
    ) -> Union[AsyncWindow, None, AsyncFutureResult[Union[AsyncWindow, None]]]:
1743
        """
1744
        Like the IDLast subcommand for WinGet
1745
        """
1746
        args = self._format_win_args(
4✔
1747
            title=title,
1748
            text=text,
1749
            exclude_title=exclude_title,
1750
            exclude_text=exclude_text,
1751
            title_match_mode=title_match_mode,
1752
            detect_hidden_windows=detect_hidden_windows,
1753
        )
1754
        resp = await self._transport.function_call('AHKWinGetIDLast', args, blocking=blocking, engine=self)
4✔
1755
        return resp
4✔
1756

1757
    # fmt: off
1758
    @overload
4✔
1759
    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✔
1760
    @overload
4✔
1761
    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✔
1762
    @overload
4✔
1763
    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✔
1764
    @overload
4✔
1765
    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✔
1766
    # fmt: on
1767
    async def win_get_pid(
4✔
1768
        self,
1769
        title: str = '',
1770
        text: str = '',
1771
        exclude_title: str = '',
1772
        exclude_text: str = '',
1773
        *,
1774
        title_match_mode: Optional[TitleMatchMode] = None,
1775
        detect_hidden_windows: Optional[bool] = None,
1776
        blocking: bool = True,
1777
    ) -> Union[int, None, AsyncFutureResult[Union[int, None]]]:
1778
        """
1779
        Get a window by process ID.
1780

1781
        Like the pid subcommand for WinGet
1782
        """
1783
        args = self._format_win_args(
4✔
1784
            title=title,
1785
            text=text,
1786
            exclude_title=exclude_title,
1787
            exclude_text=exclude_text,
1788
            title_match_mode=title_match_mode,
1789
            detect_hidden_windows=detect_hidden_windows,
1790
        )
1791
        resp = await self._transport.function_call('AHKWinGetPID', args, blocking=blocking)
4✔
1792
        return resp
4✔
1793

1794
    # fmt: off
1795
    @overload
4✔
1796
    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✔
1797
    @overload
4✔
1798
    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✔
1799
    @overload
4✔
1800
    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✔
1801
    @overload
4✔
1802
    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✔
1803
    # fmt: on
1804
    async def win_get_process_name(
4✔
1805
        self,
1806
        title: str = '',
1807
        text: str = '',
1808
        exclude_title: str = '',
1809
        exclude_text: str = '',
1810
        *,
1811
        title_match_mode: Optional[TitleMatchMode] = None,
1812
        detect_hidden_windows: Optional[bool] = None,
1813
        blocking: bool = True,
1814
    ) -> Union[None, str, AsyncFutureResult[Optional[str]]]:
1815
        """
1816
        Get the process name of a window
1817

1818
        Analog for `ProcessName subcommand for WinGet <https://www.autohotkey.com/docs/v1/lib/WinGet.htm#ProcessName>`_
1819
        """
1820
        args = self._format_win_args(
4✔
1821
            title=title,
1822
            text=text,
1823
            exclude_title=exclude_title,
1824
            exclude_text=exclude_text,
1825
            title_match_mode=title_match_mode,
1826
            detect_hidden_windows=detect_hidden_windows,
1827
        )
1828
        resp = await self._transport.function_call('AHKWinGetProcessName', args, blocking=blocking)
4✔
1829
        return resp
4✔
1830

1831
    # fmt: off
1832
    @overload
4✔
1833
    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✔
1834
    @overload
4✔
1835
    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✔
1836
    @overload
4✔
1837
    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✔
1838
    @overload
4✔
1839
    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✔
1840
    # fmt: on
1841
    async def win_get_process_path(
4✔
1842
        self,
1843
        title: str = '',
1844
        text: str = '',
1845
        exclude_title: str = '',
1846
        exclude_text: str = '',
1847
        *,
1848
        title_match_mode: Optional[TitleMatchMode] = None,
1849
        detect_hidden_windows: Optional[bool] = None,
1850
        blocking: bool = True,
1851
    ) -> Union[str, None, Union[None, str, AsyncFutureResult[Optional[str]]]]:
1852
        """
1853
        Get the process path for a window.
1854

1855
        Analog for the `ProcessPath subcommand for WinGet <https://www.autohotkey.com/docs/v1/lib/WinGet.htm#ProcessPath>`_
1856
        """
1857
        args = self._format_win_args(
4✔
1858
            title=title,
1859
            text=text,
1860
            exclude_title=exclude_title,
1861
            exclude_text=exclude_text,
1862
            title_match_mode=title_match_mode,
1863
            detect_hidden_windows=detect_hidden_windows,
1864
        )
1865
        resp = await self._transport.function_call('AHKWinGetProcessPath', args, blocking=blocking)
4✔
1866
        return resp
4✔
1867

1868
    # fmt: off
1869
    @overload
4✔
1870
    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✔
1871
    @overload
4✔
1872
    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✔
1873
    @overload
4✔
1874
    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✔
1875
    @overload
4✔
1876
    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✔
1877
    # fmt: on
1878
    async def win_get_count(
4✔
1879
        self,
1880
        title: str = '',
1881
        text: str = '',
1882
        exclude_title: str = '',
1883
        exclude_text: str = '',
1884
        *,
1885
        title_match_mode: Optional[TitleMatchMode] = None,
1886
        detect_hidden_windows: Optional[bool] = None,
1887
        blocking: bool = True,
1888
    ) -> Union[int, AsyncFutureResult[int]]:
1889
        """
1890
        Analog for the `Count subcommand for WinGet <https://www.autohotkey.com/docs/v1/lib/WinGet.htm#Count>`_
1891
        """
1892
        args = self._format_win_args(
4✔
1893
            title=title,
1894
            text=text,
1895
            exclude_title=exclude_title,
1896
            exclude_text=exclude_text,
1897
            title_match_mode=title_match_mode,
1898
            detect_hidden_windows=detect_hidden_windows,
1899
        )
1900
        resp = await self._transport.function_call('AHKWinGetCount', args, blocking=blocking)
4✔
1901
        return resp
4✔
1902

1903
    # fmt: off
1904
    @overload
4✔
1905
    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✔
1906
    @overload
4✔
1907
    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✔
1908
    @overload
4✔
1909
    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✔
1910
    @overload
4✔
1911
    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✔
1912
    # fmt: on
1913
    async def win_get_minmax(
4✔
1914
        self,
1915
        title: str = '',
1916
        text: str = '',
1917
        exclude_title: str = '',
1918
        exclude_text: str = '',
1919
        *,
1920
        title_match_mode: Optional[TitleMatchMode] = None,
1921
        detect_hidden_windows: Optional[bool] = None,
1922
        blocking: bool = True,
1923
    ) -> Union[None, int, AsyncFutureResult[Optional[int]]]:
1924
        """
1925
        Analog for the `MinMax subcommand for WinGet <https://www.autohotkey.com/docs/v1/lib/WinGet.htm#MinMax>`_
1926
        """
1927
        args = self._format_win_args(
4✔
1928
            title=title,
1929
            text=text,
1930
            exclude_title=exclude_title,
1931
            exclude_text=exclude_text,
1932
            title_match_mode=title_match_mode,
1933
            detect_hidden_windows=detect_hidden_windows,
1934
        )
1935
        resp = await self._transport.function_call('AHKWinGetMinMax', args, blocking=blocking)
4✔
1936
        return resp
4✔
1937

1938
    # fmt: off
1939
    @overload
4✔
1940
    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✔
1941
    @overload
4✔
1942
    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✔
1943
    @overload
4✔
1944
    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✔
1945
    @overload
4✔
1946
    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✔
1947
    # fmt: on
1948
    async def win_get_control_list(
4✔
1949
        self,
1950
        title: str = '',
1951
        text: str = '',
1952
        exclude_title: str = '',
1953
        exclude_text: str = '',
1954
        *,
1955
        title_match_mode: Optional[TitleMatchMode] = None,
1956
        detect_hidden_windows: Optional[bool] = None,
1957
        blocking: bool = True,
1958
    ) -> Union[List[AsyncControl], None, AsyncFutureResult[Optional[List[AsyncControl]]]]:
1959
        """
1960
        Analog for the `ControlList subcommand for WinGet <https://www.autohotkey.com/docs/v1/lib/WinGet.htm#ControlList>`_
1961
        """
1962
        args = self._format_win_args(
4✔
1963
            title=title,
1964
            text=text,
1965
            exclude_title=exclude_title,
1966
            exclude_text=exclude_text,
1967
            title_match_mode=title_match_mode,
1968
            detect_hidden_windows=detect_hidden_windows,
1969
        )
1970
        resp = await self._transport.function_call('AHKWinGetControlList', args, blocking=blocking, engine=self)
4✔
1971
        return resp
4✔
1972

1973
    # fmt: off
1974
    @overload
4✔
1975
    async def win_get_from_mouse_position(self) -> Union[AsyncWindow, None]: ...
4✔
1976
    @overload
4✔
1977
    async def win_get_from_mouse_position(self, *, blocking: Literal[False]) -> AsyncFutureResult[Union[AsyncWindow, None]]: ...
4✔
1978
    @overload
4✔
1979
    async def win_get_from_mouse_position(self, *, blocking: Literal[True]) -> Union[AsyncWindow, None]: ...
4✔
1980
    @overload
4✔
1981
    async def win_get_from_mouse_position(self, *, blocking: bool = True) -> Union[Optional[AsyncWindow], AsyncFutureResult[Optional[AsyncWindow]]]: ...
4✔
1982
    # fmt: on
1983
    async def win_get_from_mouse_position(
4✔
1984
        self, *, blocking: bool = True
1985
    ) -> Union[Optional[AsyncWindow], AsyncFutureResult[Optional[AsyncWindow]]]:
1986
        resp = await self._transport.function_call('AHKWinFromMouse', blocking=blocking, engine=self)
×
1987
        return resp
×
1988

1989
    # fmt: off
1990
    @overload
4✔
1991
    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✔
1992
    @overload
4✔
1993
    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✔
1994
    @overload
4✔
1995
    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✔
1996
    @overload
4✔
1997
    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✔
1998
    # fmt: on
1999
    async def win_exists(
4✔
2000
        self,
2001
        title: str = '',
2002
        text: str = '',
2003
        exclude_title: str = '',
2004
        exclude_text: str = '',
2005
        *,
2006
        title_match_mode: Optional[TitleMatchMode] = None,
2007
        detect_hidden_windows: Optional[bool] = None,
2008
        blocking: bool = True,
2009
    ) -> Union[bool, AsyncFutureResult[bool]]:
2010
        args = self._format_win_args(
4✔
2011
            title=title,
2012
            text=text,
2013
            exclude_title=exclude_title,
2014
            exclude_text=exclude_text,
2015
            title_match_mode=title_match_mode,
2016
            detect_hidden_windows=detect_hidden_windows,
2017
        )
2018
        resp = await self._transport.function_call('AHKWinExist', args, blocking=blocking)
4✔
2019
        return resp
4✔
2020

2021
    # fmt: off
2022
    @overload
4✔
2023
    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✔
2024
    @overload
4✔
2025
    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✔
2026
    @overload
4✔
2027
    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✔
2028
    @overload
4✔
2029
    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✔
2030
    # fmt: on
2031
    async def win_activate(
4✔
2032
        self,
2033
        title: str = '',
2034
        text: str = '',
2035
        exclude_title: str = '',
2036
        exclude_text: str = '',
2037
        *,
2038
        title_match_mode: Optional[TitleMatchMode] = None,
2039
        detect_hidden_windows: Optional[bool] = None,
2040
        blocking: bool = True,
2041
    ) -> Union[None, AsyncFutureResult[None]]:
2042
        """
2043
        Analog for `WinActivate <https://www.autohotkey.com/docs/commands/WinActivate.htm>`_
2044
        """
2045
        args = self._format_win_args(
4✔
2046
            title=title,
2047
            text=text,
2048
            exclude_title=exclude_title,
2049
            exclude_text=exclude_text,
2050
            title_match_mode=title_match_mode,
2051
            detect_hidden_windows=detect_hidden_windows,
2052
        )
2053
        resp = await self._transport.function_call('AHKWinActivate', args, blocking=blocking)
4✔
2054
        return resp
4✔
2055

2056
    # fmt: off
2057
    @overload
4✔
2058
    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✔
2059
    @overload
4✔
2060
    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✔
2061
    @overload
4✔
2062
    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✔
2063
    @overload
4✔
2064
    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✔
2065
    # fmt: on
2066
    async def win_set_title(
4✔
2067
        self,
2068
        new_title: str,
2069
        title: str = '',
2070
        text: str = '',
2071
        exclude_title: str = '',
2072
        exclude_text: str = '',
2073
        *,
2074
        title_match_mode: Optional[TitleMatchMode] = None,
2075
        detect_hidden_windows: Optional[bool] = None,
2076
        blocking: bool = True,
2077
    ) -> Union[None, AsyncFutureResult[None]]:
2078
        """
2079
        Analog for `WinSetTitle <https://www.autohotkey.com/docs/commands/WinSetTitle.htm>`_
2080
        """
2081
        args = [new_title, title, text, exclude_title, exclude_text]
4✔
2082
        if detect_hidden_windows is not None:
4✔
2083
            if detect_hidden_windows is True:
4✔
2084
                args.append('On')
4✔
2085
            elif detect_hidden_windows is False:
×
2086
                args.append('Off')
×
2087
            else:
2088
                raise TypeError(
×
2089
                    f'Invalid value for parameter detect_hidden_windows. Expected boolean or None, got {detect_hidden_windows!r}'
2090
                )
2091
        else:
2092
            args.append('')
×
2093
        if title_match_mode is not None:
4✔
2094
            if isinstance(title_match_mode, tuple):
4✔
2095
                match_mode, match_speed = title_match_mode
4✔
2096
            elif title_match_mode in (1, 2, 3, 'RegEx'):
×
2097
                match_mode = title_match_mode
×
2098
                match_speed = ''
×
2099
            elif title_match_mode in ('Fast', 'Slow'):
×
2100
                match_mode = ''
×
2101
                match_speed = title_match_mode
×
2102
            else:
2103
                raise ValueError(
×
2104
                    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}"
2105
                )
2106
            args.append(str(match_mode))
4✔
2107
            args.append(str(match_speed))
4✔
2108
        else:
2109
            args.append('')
×
2110
            args.append('')
×
2111
        resp = await self._transport.function_call('AHKWinSetTitle', args, blocking=blocking)
4✔
2112
        return resp
4✔
2113

2114
    # fmt: off
2115
    @overload
4✔
2116
    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✔
2117
    @overload
4✔
2118
    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✔
2119
    @overload
4✔
2120
    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✔
2121
    @overload
4✔
2122
    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✔
2123
    # fmt: on
2124
    async def win_set_always_on_top(
4✔
2125
        self,
2126
        toggle: Literal['On', 'Off', 'Toggle', 1, -1, 0],
2127
        title: str = '',
2128
        text: str = '',
2129
        exclude_title: str = '',
2130
        exclude_text: str = '',
2131
        *,
2132
        title_match_mode: Optional[TitleMatchMode] = None,
2133
        detect_hidden_windows: Optional[bool] = None,
2134
        blocking: bool = True,
2135
    ) -> Union[None, AsyncFutureResult[None]]:
2136
        """
2137
        Analog for `AlwaysOnTop subcommand of WinSet <https://www.autohotkey.com/docs/v1/lib/WinSet.htm#AlwaysOnTop>`_
2138
        """
2139
        args = [str(toggle), title, text, exclude_title, exclude_text]
4✔
2140
        if detect_hidden_windows is not None:
4✔
2141
            if detect_hidden_windows is True:
4✔
2142
                args.append('On')
4✔
2143
            elif detect_hidden_windows is False:
×
2144
                args.append('Off')
×
2145
            else:
2146
                raise TypeError(
×
2147
                    f'Invalid value for parameter detect_hidden_windows. Expected boolean or None, got {detect_hidden_windows!r}'
2148
                )
2149
        else:
2150
            args.append('')
×
2151
        if title_match_mode is not None:
4✔
2152
            if isinstance(title_match_mode, tuple):
4✔
2153
                match_mode, match_speed = title_match_mode
4✔
2154
            elif title_match_mode in (1, 2, 3, 'RegEx'):
×
2155
                match_mode = title_match_mode
×
2156
                match_speed = ''
×
2157
            elif title_match_mode in ('Fast', 'Slow'):
×
2158
                match_mode = ''
×
2159
                match_speed = title_match_mode
×
2160
            else:
2161
                raise ValueError(
×
2162
                    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}"
2163
                )
2164
            args.append(str(match_mode))
4✔
2165
            args.append(str(match_speed))
4✔
2166
        else:
2167
            args.append('')
×
2168
            args.append('')
×
2169
        resp = await self._transport.function_call('AHKWinSetAlwaysOnTop', args, blocking=blocking)
4✔
2170
        return resp
4✔
2171

2172
    # fmt: off
2173
    @overload
4✔
2174
    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✔
2175
    @overload
4✔
2176
    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✔
2177
    @overload
4✔
2178
    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✔
2179
    @overload
4✔
2180
    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✔
2181
    # fmt: on
2182
    async def win_set_bottom(
4✔
2183
        self,
2184
        title: str = '',
2185
        text: str = '',
2186
        exclude_title: str = '',
2187
        exclude_text: str = '',
2188
        *,
2189
        title_match_mode: Optional[TitleMatchMode] = None,
2190
        detect_hidden_windows: Optional[bool] = None,
2191
        blocking: bool = True,
2192
    ) -> Union[None, AsyncFutureResult[None]]:
2193
        """
2194
        Analog for `Bottom subcommand of WinSet <https://www.autohotkey.com/docs/v1/lib/WinSet.htm#Bottom>`_
2195
        """
2196
        args = self._format_win_args(
4✔
2197
            title=title,
2198
            text=text,
2199
            exclude_title=exclude_title,
2200
            exclude_text=exclude_text,
2201
            title_match_mode=title_match_mode,
2202
            detect_hidden_windows=detect_hidden_windows,
2203
        )
2204
        resp = await self._transport.function_call('AHKWinSetBottom', args, blocking=blocking)
4✔
2205
        return resp
4✔
2206

2207
    # fmt: off
2208
    @overload
4✔
2209
    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✔
2210
    @overload
4✔
2211
    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✔
2212
    @overload
4✔
2213
    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✔
2214
    @overload
4✔
2215
    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✔
2216
    # fmt: on
2217
    async def win_set_top(
4✔
2218
        self,
2219
        title: str = '',
2220
        text: str = '',
2221
        exclude_title: str = '',
2222
        exclude_text: str = '',
2223
        *,
2224
        title_match_mode: Optional[TitleMatchMode] = None,
2225
        detect_hidden_windows: Optional[bool] = None,
2226
        blocking: bool = True,
2227
    ) -> Union[None, AsyncFutureResult[None]]:
2228
        """
2229
        Analog for `Top subcommand of WinSet <https://www.autohotkey.com/docs/v1/lib/WinSet.htm#Top>`_
2230
        """
2231
        args = self._format_win_args(
×
2232
            title=title,
2233
            text=text,
2234
            exclude_title=exclude_title,
2235
            exclude_text=exclude_text,
2236
            title_match_mode=title_match_mode,
2237
            detect_hidden_windows=detect_hidden_windows,
2238
        )
2239
        resp = await self._transport.function_call('AHKWinSetTop', args, blocking=blocking)
×
2240
        return resp
×
2241

2242
    # fmt: off
2243
    @overload
4✔
2244
    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✔
2245
    @overload
4✔
2246
    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✔
2247
    @overload
4✔
2248
    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✔
2249
    @overload
4✔
2250
    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✔
2251
    # fmt: on
2252
    async def win_set_disable(
4✔
2253
        self,
2254
        title: str = '',
2255
        text: str = '',
2256
        exclude_title: str = '',
2257
        exclude_text: str = '',
2258
        *,
2259
        title_match_mode: Optional[TitleMatchMode] = None,
2260
        detect_hidden_windows: Optional[bool] = None,
2261
        blocking: bool = True,
2262
    ) -> Union[None, AsyncFutureResult[None]]:
2263
        """
2264
        Analog for `Disable subcommand of WinSet <https://www.autohotkey.com/docs/v1/lib/WinSet.htm#Disable>`_
2265
        """
2266
        args = self._format_win_args(
×
2267
            title=title,
2268
            text=text,
2269
            exclude_title=exclude_title,
2270
            exclude_text=exclude_text,
2271
            title_match_mode=title_match_mode,
2272
            detect_hidden_windows=detect_hidden_windows,
2273
        )
2274
        resp = await self._transport.function_call('AHKWinSetDisable', args, blocking=blocking)
×
2275
        return resp
×
2276

2277
    # fmt: off
2278
    @overload
4✔
2279
    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✔
2280
    @overload
4✔
2281
    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✔
2282
    @overload
4✔
2283
    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✔
2284
    @overload
4✔
2285
    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✔
2286
    # fmt: on
2287
    async def win_set_enable(
4✔
2288
        self,
2289
        title: str = '',
2290
        text: str = '',
2291
        exclude_title: str = '',
2292
        exclude_text: str = '',
2293
        *,
2294
        title_match_mode: Optional[TitleMatchMode] = None,
2295
        detect_hidden_windows: Optional[bool] = None,
2296
        blocking: bool = True,
2297
    ) -> Union[None, AsyncFutureResult[None]]:
2298
        """
2299
        Analog for `Enable subcommand of WinSet <https://www.autohotkey.com/docs/v1/lib/WinSet.htm#Enable>`_
2300
        """
2301
        args = self._format_win_args(
×
2302
            title=title,
2303
            text=text,
2304
            exclude_title=exclude_title,
2305
            exclude_text=exclude_text,
2306
            title_match_mode=title_match_mode,
2307
            detect_hidden_windows=detect_hidden_windows,
2308
        )
2309
        resp = await self._transport.function_call('AHKWinSetEnable', args, blocking=blocking)
×
2310
        return resp
×
2311

2312
    # fmt: off
2313
    @overload
4✔
2314
    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✔
2315
    @overload
4✔
2316
    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✔
2317
    @overload
4✔
2318
    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✔
2319
    @overload
4✔
2320
    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✔
2321
    # fmt: on
2322
    async def win_set_redraw(
4✔
2323
        self,
2324
        title: str = '',
2325
        text: str = '',
2326
        exclude_title: str = '',
2327
        exclude_text: str = '',
2328
        *,
2329
        title_match_mode: Optional[TitleMatchMode] = None,
2330
        detect_hidden_windows: Optional[bool] = None,
2331
        blocking: bool = True,
2332
    ) -> Union[None, AsyncFutureResult[None]]:
2333
        """
2334
        Analog for `Redraw subcommand of WinSet <https://www.autohotkey.com/docs/v1/lib/WinSet.htm#Redraw>`_
2335
        """
2336

2337
        args = self._format_win_args(
×
2338
            title=title,
2339
            text=text,
2340
            exclude_title=exclude_title,
2341
            exclude_text=exclude_text,
2342
            title_match_mode=title_match_mode,
2343
            detect_hidden_windows=detect_hidden_windows,
2344
        )
2345
        resp = await self._transport.function_call('AHKWinSetRedraw', args, blocking=blocking)
×
2346
        return resp
×
2347

2348
    # fmt: off
2349
    @overload
4✔
2350
    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✔
2351
    @overload
4✔
2352
    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✔
2353
    @overload
4✔
2354
    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✔
2355
    @overload
4✔
2356
    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✔
2357
    # fmt: on
2358
    async def win_set_style(
4✔
2359
        self,
2360
        style: str,
2361
        title: str = '',
2362
        text: str = '',
2363
        exclude_title: str = '',
2364
        exclude_text: str = '',
2365
        *,
2366
        title_match_mode: Optional[TitleMatchMode] = None,
2367
        detect_hidden_windows: Optional[bool] = None,
2368
        blocking: bool = True,
2369
    ) -> Union[bool, AsyncFutureResult[bool]]:
2370
        """
2371
        Analog for `Style subcommand of WinSet <https://www.autohotkey.com/docs/v1/lib/WinSet.htm#Style>`_
2372
        """
2373

2374
        args = [style, title, text, exclude_title, exclude_text]
×
2375
        if detect_hidden_windows is not None:
×
2376
            if detect_hidden_windows is True:
×
2377
                args.append('On')
×
2378
            elif detect_hidden_windows is False:
×
2379
                args.append('Off')
×
2380
            else:
2381
                raise TypeError(
×
2382
                    f'Invalid value for parameter detect_hidden_windows. Expected boolean or None, got {detect_hidden_windows!r}'
2383
                )
2384
        else:
2385
            args.append('')
×
2386
        if title_match_mode is not None:
×
2387
            if isinstance(title_match_mode, tuple):
×
2388
                match_mode, match_speed = title_match_mode
×
2389
            elif title_match_mode in (1, 2, 3, 'RegEx'):
×
2390
                match_mode = title_match_mode
×
2391
                match_speed = ''
×
2392
            elif title_match_mode in ('Fast', 'Slow'):
×
2393
                match_mode = ''
×
2394
                match_speed = title_match_mode
×
2395
            else:
2396
                raise ValueError(
×
2397
                    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}"
2398
                )
2399
            args.append(str(match_mode))
×
2400
            args.append(str(match_speed))
×
2401
        else:
2402
            args.append('')
×
2403
            args.append('')
×
2404
        resp = await self._transport.function_call('AHKWinSetStyle', args, blocking=blocking)
×
2405
        return resp
×
2406

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

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

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

2581
    # fmt: off
2582
    @overload
4✔
2583
    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✔
2584
    @overload
4✔
2585
    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✔
2586
    @overload
4✔
2587
    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✔
2588
    @overload
4✔
2589
    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✔
2590
    # fmt: on
2591
    async def win_set_trans_color(
4✔
2592
        self,
2593
        color: Union[int, str],
2594
        title: str = '',
2595
        text: str = '',
2596
        exclude_title: str = '',
2597
        exclude_text: str = '',
2598
        *,
2599
        title_match_mode: Optional[TitleMatchMode] = None,
2600
        detect_hidden_windows: Optional[bool] = None,
2601
        blocking: bool = True,
2602
    ) -> Union[None, AsyncFutureResult[None]]:
2603
        """
2604
        Analog for `TransColor subcommand of WinSet <https://www.autohotkey.com/docs/v1/lib/WinSet.htm#TransColor>`_
2605
        """
2606
        args = [str(color), title, text, exclude_title, exclude_text]
×
2607
        if detect_hidden_windows is not None:
×
2608
            if detect_hidden_windows is True:
×
2609
                args.append('On')
×
2610
            elif detect_hidden_windows is False:
×
2611
                args.append('Off')
×
2612
            else:
2613
                raise TypeError(
×
2614
                    f'Invalid value for parameter detect_hidden_windows. Expected boolean or None, got {detect_hidden_windows!r}'
2615
                )
2616
        else:
2617
            args.append('')
×
2618
        if title_match_mode is not None:
×
2619
            if isinstance(title_match_mode, tuple):
×
2620
                match_mode, match_speed = title_match_mode
×
2621
            elif title_match_mode in (1, 2, 3, 'RegEx'):
×
2622
                match_mode = title_match_mode
×
2623
                match_speed = ''
×
2624
            elif title_match_mode in ('Fast', 'Slow'):
×
2625
                match_mode = ''
×
2626
                match_speed = title_match_mode
×
2627
            else:
2628
                raise ValueError(
×
2629
                    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}"
2630
                )
2631
            args.append(str(match_mode))
×
2632
            args.append(str(match_speed))
×
2633
        else:
2634
            args.append('')
×
2635
            args.append('')
×
2636
        resp = await self._transport.function_call('AHKWinSetTransColor', args, blocking=blocking)
×
2637
        return resp
×
2638

2639
    # alias for backwards compatibility
2640
    windows = list_windows
4✔
2641

2642
    # fmt: off
2643
    @overload
4✔
2644
    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✔
2645
    @overload
4✔
2646
    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✔
2647
    @overload
4✔
2648
    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✔
2649
    @overload
4✔
2650
    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✔
2651
    # fmt: on
2652
    async def right_click(
4✔
2653
        self,
2654
        x: Optional[Union[int, Tuple[int, int]]] = None,
2655
        y: Optional[int] = None,
2656
        click_count: Optional[int] = None,
2657
        direction: Optional[Literal['U', 'D', 'Up', 'Down']] = None,
2658
        *,
2659
        relative: Optional[bool] = None,
2660
        blocking: bool = True,
2661
        coord_mode: Optional[CoordModeRelativeTo] = None,
2662
    ) -> Union[None, AsyncFutureResult[None]]:
2663
        button = 'R'
×
2664
        return await self.click(
×
2665
            x,
2666
            y,
2667
            button=button,
2668
            click_count=click_count,
2669
            direction=direction,
2670
            relative=relative,
2671
            blocking=blocking,
2672
            coord_mode=coord_mode,
2673
        )
2674

2675
    # fmt: off
2676
    @overload
4✔
2677
    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✔
2678
    @overload
4✔
2679
    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✔
2680
    @overload
4✔
2681
    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✔
2682
    @overload
4✔
2683
    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✔
2684
    # fmt: on
2685
    async def click(
4✔
2686
        self,
2687
        x: Optional[Union[int, Tuple[int, int]]] = None,
2688
        y: Optional[int] = None,
2689
        button: Optional[Union[MouseButton, str]] = None,
2690
        click_count: Optional[int] = None,
2691
        direction: Optional[Literal['U', 'D', 'Up', 'Down']] = None,
2692
        *,
2693
        relative: Optional[bool] = None,
2694
        blocking: bool = True,
2695
        coord_mode: Optional[CoordModeRelativeTo] = None,
2696
    ) -> Union[None, AsyncFutureResult[None]]:
2697
        """
2698
        Analog for `Click <https://www.autohotkey.com/docs/commands/Click.htm>`_
2699
        """
2700
        if x or y:
×
2701
            if y is None and isinstance(x, tuple) and len(x) == 2:
×
2702
                #  allow position to be specified by a two-sequence tuple
2703
                x, y = x
×
2704
            assert x is not None and y is not None, 'If provided, position must be specified by x AND y'
×
2705
        if button is None:
×
2706
            button = 'L'
×
2707
        button = _resolve_button(button)
×
2708

2709
        if relative:
×
2710
            r = 'Rel'
×
2711
        else:
2712
            r = ''
×
2713
        if coord_mode is None:
×
2714
            coord_mode = ''
×
2715
        args = [str(x), str(y), button, str(click_count), direction or '', r, coord_mode]
×
2716
        resp = await self._transport.function_call('AHKClick', args, blocking=blocking)
×
2717
        return resp
×
2718

2719
    # fmt: off
2720
    @overload
4✔
2721
    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✔
2722
    @overload
4✔
2723
    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✔
2724
    @overload
4✔
2725
    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✔
2726
    @overload
4✔
2727
    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✔
2728
    # fmt: on
2729
    async def image_search(
4✔
2730
        self,
2731
        image_path: str,
2732
        upper_bound: Tuple[Union[int, str], Union[int, str]] = (0, 0),
2733
        lower_bound: Optional[Tuple[Union[int, str], Union[int, str]]] = None,
2734
        *,
2735
        color_variation: Optional[int] = None,
2736
        coord_mode: Optional[CoordModeRelativeTo] = None,
2737
        scale_height: Optional[int] = None,
2738
        scale_width: Optional[int] = None,
2739
        transparent: Optional[str] = None,
2740
        icon: Optional[int] = None,
2741
        blocking: bool = True,
2742
    ) -> Union[Tuple[int, int], None, AsyncFutureResult[Optional[Tuple[int, int]]]]:
2743
        """
2744
        Analog for `ImageSearch <https://www.autohotkey.com/docs/commands/ImageSearch.htm>`_
2745
        """
2746

2747
        if scale_height and not scale_width:
×
2748
            scale_width = -1
×
2749
        elif scale_width and not scale_height:
×
2750
            scale_height = -1
×
2751

2752
        options: List[Union[str, int]] = []
×
2753
        if icon:
×
2754
            options.append(f'Icon{icon}')
×
2755
        if color_variation is not None:
×
2756
            options.append(color_variation)
×
2757
        if transparent is not None:
×
2758
            options.append(f'Trans{transparent}')
×
2759
        if scale_width:
×
2760
            options.append(f'w{scale_width}')
×
2761
            options.append(f'h{scale_height}')
×
2762

2763
        x1, y1 = upper_bound
×
2764
        if lower_bound:
×
2765
            x2, y2 = lower_bound
×
2766
        else:
2767
            x2, y2 = ('A_ScreenWidth', 'A_ScreenHeight')
×
2768

2769
        args = [str(x1), str(y1), str(x2), str(y2)]
×
2770
        if options:
×
2771
            opts = ' '.join(f'*{opt}' for opt in options)
×
2772
            args.append(opts + f' {image_path}')
×
2773
        else:
2774
            args.append(image_path)
×
2775

2776
        if coord_mode is not None:
×
2777
            args.append(coord_mode)
×
2778

2779
        resp = await self._transport.function_call('AHKImageSearch', args, blocking=blocking)
×
2780
        return resp
×
2781

2782
    async def mouse_drag(
4✔
2783
        self,
2784
        x: int,
2785
        y: int,
2786
        *,
2787
        from_position: Optional[Tuple[int, int]] = None,
2788
        speed: Optional[int] = None,
2789
        button: MouseButton = 1,
2790
        relative: Optional[bool] = None,
2791
        blocking: bool = True,
2792
        coord_mode: Optional[CoordModeRelativeTo] = None,
2793
    ) -> None:
2794
        """
2795
        Analog for `MouseClickDrag <https://www.autohotkey.com/docs/commands/MouseClickDrag.htm>`_
2796
        """
2797
        if from_position:
×
2798
            x1, y1 = from_position
×
2799
            args = [str(button), str(x1), str(y1), str(x), str(y)]
×
2800
        else:
2801
            args = [str(button), '', '', str(x), str(y)]
×
2802

2803
        if speed:
×
2804
            args.append(str(speed))
×
2805
        else:
2806
            args.append('')
×
2807

2808
        if relative:
×
2809
            args.append('R')
×
2810
        else:
2811
            args.append('')
×
2812

2813
        if coord_mode:
×
2814
            args.append(coord_mode)
×
2815

2816
        await self._transport.function_call('AHKMouseClickDrag', args, blocking=blocking)
×
2817

2818
    # fmt: off
2819
    @overload
4✔
2820
    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✔
2821
    @overload
4✔
2822
    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✔
2823
    @overload
4✔
2824
    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✔
2825
    @overload
4✔
2826
    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✔
2827
    # fmt: on
2828
    async def pixel_get_color(
4✔
2829
        self,
2830
        x: int,
2831
        y: int,
2832
        *,
2833
        coord_mode: Optional[CoordModeRelativeTo] = None,
2834
        alt: bool = False,
2835
        slow: bool = False,
2836
        rgb: bool = True,
2837
        blocking: bool = True,
2838
    ) -> Union[str, AsyncFutureResult[str]]:
2839
        """
2840
        Analog for `PixelGetColor <https://www.autohotkey.com/docs/commands/PixelGetColor.htm>`_
2841
        """
2842
        args = [str(x), str(y), coord_mode or '']
×
2843

2844
        options = ' '.join(word for word, val in zip(('Alt', 'Slow', 'RGB'), (alt, slow, rgb)) if val)
×
2845
        args.append(options)
×
2846

2847
        resp = await self._transport.function_call('AHKPixelGetColor', args, blocking=blocking)
×
2848
        return resp
×
2849

2850
    # fmt: off
2851
    @overload
4✔
2852
    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✔
2853
    @overload
4✔
2854
    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✔
2855
    @overload
4✔
2856
    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✔
2857
    @overload
4✔
2858
    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✔
2859
    # fmt: on
2860
    async def pixel_search(
4✔
2861
        self,
2862
        search_region_start: Tuple[int, int],
2863
        search_region_end: Tuple[int, int],
2864
        color: Union[str, int],
2865
        variation: int = 0,
2866
        *,
2867
        coord_mode: Optional[CoordModeRelativeTo] = None,
2868
        fast: bool = True,
2869
        rgb: bool = True,
2870
        blocking: bool = True,
2871
    ) -> Union[Optional[Tuple[int, int]], AsyncFutureResult[Optional[Tuple[int, int]]]]:
2872
        """
2873
        Analog for `PixelSearch <https://www.autohotkey.com/docs/commands/PixelSearch.htm>`_
2874
        """
2875
        x1, y1 = search_region_start
×
2876
        x2, y2 = search_region_end
×
2877
        args = [str(x1), str(y1), str(x2), str(y2), str(color), str(variation)]
×
2878
        mode = ' '.join(word for word, val in zip(('Fast', 'RGB'), (fast, rgb)) if val)
×
2879
        args.append(mode)
×
2880
        args.append(coord_mode or '')
×
2881
        resp = await self._transport.function_call('AHKPixelSearch', args, blocking=blocking)
×
2882
        return resp
×
2883

2884
    # fmt: off
2885
    @overload
4✔
2886
    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✔
2887
    @overload
4✔
2888
    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✔
2889
    @overload
4✔
2890
    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✔
2891
    @overload
4✔
2892
    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✔
2893
    # fmt: on
2894
    async def win_close(
4✔
2895
        self,
2896
        title: str = '',
2897
        text: str = '',
2898
        seconds_to_wait: Optional[int] = None,
2899
        exclude_title: str = '',
2900
        exclude_text: str = '',
2901
        *,
2902
        blocking: bool = True,
2903
        title_match_mode: Optional[TitleMatchMode] = None,
2904
        detect_hidden_windows: Optional[bool] = None,
2905
    ) -> Union[None, AsyncFutureResult[None]]:
2906
        """
2907
        Analog for `WinClose <https://www.autohotkey.com/docs/commands/WinClose.htm>`_
2908
        """
2909
        args = self._format_win_args(
4✔
2910
            title=title,
2911
            text=text,
2912
            exclude_title=exclude_title,
2913
            exclude_text=exclude_text,
2914
            title_match_mode=title_match_mode,
2915
            detect_hidden_windows=detect_hidden_windows,
2916
        )
2917
        args.append(str(seconds_to_wait) if seconds_to_wait else '')
4✔
2918

2919
        resp = await self._transport.function_call('AHKWinClose', args, engine=self, blocking=blocking)
4✔
2920
        return resp
4✔
2921

2922
    # fmt: off
2923
    @overload
4✔
2924
    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✔
2925
    @overload
4✔
2926
    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✔
2927
    @overload
4✔
2928
    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✔
2929
    @overload
4✔
2930
    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✔
2931
    # fmt: on
2932
    async def win_kill(
4✔
2933
        self,
2934
        title: str = '',
2935
        text: str = '',
2936
        seconds_to_wait: Optional[int] = None,
2937
        exclude_title: str = '',
2938
        exclude_text: str = '',
2939
        *,
2940
        title_match_mode: Optional[TitleMatchMode] = None,
2941
        detect_hidden_windows: Optional[bool] = None,
2942
        blocking: bool = True,
2943
    ) -> Union[None, AsyncFutureResult[None]]:
2944
        """
2945
        Analog for `WinKill <https://www.autohotkey.com/docs/commands/WinKill.htm>`_
2946
        """
2947
        args = self._format_win_args(
×
2948
            title=title,
2949
            text=text,
2950
            exclude_title=exclude_title,
2951
            exclude_text=exclude_text,
2952
            title_match_mode=title_match_mode,
2953
            detect_hidden_windows=detect_hidden_windows,
2954
        )
2955
        args.append(str(seconds_to_wait) if seconds_to_wait else '')
×
2956

2957
        resp = await self._transport.function_call('AHKWinKill', args, engine=self, blocking=blocking)
×
2958
        return resp
×
2959

2960
    # fmt: off
2961
    @overload
4✔
2962
    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✔
2963
    @overload
4✔
2964
    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✔
2965
    @overload
4✔
2966
    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✔
2967
    @overload
4✔
2968
    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✔
2969
    # fmt: on
2970
    async def win_minimize(
4✔
2971
        self,
2972
        title: str = '',
2973
        text: str = '',
2974
        exclude_title: str = '',
2975
        exclude_text: str = '',
2976
        *,
2977
        title_match_mode: Optional[TitleMatchMode] = None,
2978
        detect_hidden_windows: Optional[bool] = None,
2979
        blocking: bool = True,
2980
    ) -> Union[None, AsyncFutureResult[None]]:
2981
        """
2982
        Analog for `WinMinimize <https://www.autohotkey.com/docs/commands/WinMinimize.htm>`_
2983
        """
2984
        args = self._format_win_args(
×
2985
            title=title,
2986
            text=text,
2987
            exclude_title=exclude_title,
2988
            exclude_text=exclude_text,
2989
            title_match_mode=title_match_mode,
2990
            detect_hidden_windows=detect_hidden_windows,
2991
        )
2992
        resp = await self._transport.function_call('AHKWinMinimize', args, engine=self, blocking=blocking)
×
2993
        return resp
×
2994

2995
    # fmt: off
2996
    @overload
4✔
2997
    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✔
2998
    @overload
4✔
2999
    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✔
3000
    @overload
4✔
3001
    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✔
3002
    @overload
4✔
3003
    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✔
3004
    # fmt: on
3005
    async def win_maximize(
4✔
3006
        self,
3007
        title: str = '',
3008
        text: str = '',
3009
        exclude_title: str = '',
3010
        exclude_text: str = '',
3011
        *,
3012
        title_match_mode: Optional[TitleMatchMode] = None,
3013
        detect_hidden_windows: Optional[bool] = None,
3014
        blocking: bool = True,
3015
    ) -> Union[None, AsyncFutureResult[None]]:
3016
        """
3017
        Analog for `WinMaximize <https://www.autohotkey.com/docs/commands/WinMaximize.htm>`_
3018
        """
3019
        args = self._format_win_args(
×
3020
            title=title,
3021
            text=text,
3022
            exclude_title=exclude_title,
3023
            exclude_text=exclude_text,
3024
            title_match_mode=title_match_mode,
3025
            detect_hidden_windows=detect_hidden_windows,
3026
        )
3027
        resp = await self._transport.function_call('AHKWinMaximize', args, engine=self, blocking=blocking)
×
3028
        return resp
×
3029

3030
    # fmt: off
3031
    @overload
4✔
3032
    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✔
3033
    @overload
4✔
3034
    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✔
3035
    @overload
4✔
3036
    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✔
3037
    @overload
4✔
3038
    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✔
3039
    # fmt: on
3040
    async def win_restore(
4✔
3041
        self,
3042
        title: str = '',
3043
        text: str = '',
3044
        exclude_title: str = '',
3045
        exclude_text: str = '',
3046
        *,
3047
        title_match_mode: Optional[TitleMatchMode] = None,
3048
        detect_hidden_windows: Optional[bool] = None,
3049
        blocking: bool = True,
3050
    ) -> Union[None, AsyncFutureResult[None]]:
3051
        """
3052
        Analog for `WinRestore <https://www.autohotkey.com/docs/commands/WinRestore.htm>`_
3053
        """
3054
        args = self._format_win_args(
×
3055
            title=title,
3056
            text=text,
3057
            exclude_title=exclude_title,
3058
            exclude_text=exclude_text,
3059
            title_match_mode=title_match_mode,
3060
            detect_hidden_windows=detect_hidden_windows,
3061
        )
3062
        resp = await self._transport.function_call('AHKWinRestore', args, engine=self, blocking=blocking)
×
3063
        return resp
×
3064

3065
    # fmt: off
3066
    @overload
4✔
3067
    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✔
3068
    @overload
4✔
3069
    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✔
3070
    @overload
4✔
3071
    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✔
3072
    @overload
4✔
3073
    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✔
3074
    # fmt: on
3075
    async def win_wait(
4✔
3076
        self,
3077
        title: str = '',
3078
        text: str = '',
3079
        exclude_title: str = '',
3080
        exclude_text: str = '',
3081
        *,
3082
        title_match_mode: Optional[TitleMatchMode] = None,
3083
        detect_hidden_windows: Optional[bool] = None,
3084
        timeout: Optional[int] = None,
3085
        blocking: bool = True,
3086
    ) -> Union[AsyncWindow, AsyncFutureResult[AsyncWindow]]:
3087
        """
3088
        Analog for `WinWait <https://www.autohotkey.com/docs/commands/WinWait.htm>`_
3089
        """
3090
        args = self._format_win_args(
4✔
3091
            title=title,
3092
            text=text,
3093
            exclude_title=exclude_title,
3094
            exclude_text=exclude_text,
3095
            title_match_mode=title_match_mode,
3096
            detect_hidden_windows=detect_hidden_windows,
3097
        )
3098
        args.append(str(timeout) if timeout else '')
4✔
3099
        resp = await self._transport.function_call('AHKWinWait', args, blocking=blocking, engine=self)
4✔
3100
        return resp
4✔
3101

3102
    # fmt: off
3103
    @overload
4✔
3104
    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✔
3105
    @overload
4✔
3106
    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✔
3107
    @overload
4✔
3108
    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✔
3109
    @overload
4✔
3110
    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✔
3111
    # fmt: on
3112
    async def win_wait_active(
4✔
3113
        self,
3114
        title: str = '',
3115
        text: str = '',
3116
        exclude_title: str = '',
3117
        exclude_text: str = '',
3118
        *,
3119
        title_match_mode: Optional[TitleMatchMode] = None,
3120
        detect_hidden_windows: Optional[bool] = None,
3121
        timeout: Optional[int] = None,
3122
        blocking: bool = True,
3123
    ) -> Union[AsyncWindow, AsyncFutureResult[AsyncWindow]]:
3124
        """
3125
        Analog for `WinWaitActive <https://www.autohotkey.com/docs/commands/WinWaitActive.htm>`_
3126
        """
3127
        args = self._format_win_args(
×
3128
            title=title,
3129
            text=text,
3130
            exclude_title=exclude_title,
3131
            exclude_text=exclude_text,
3132
            title_match_mode=title_match_mode,
3133
            detect_hidden_windows=detect_hidden_windows,
3134
        )
3135
        args.append(str(timeout) if timeout else '')
×
3136
        resp = await self._transport.function_call('AHKWinWaitActive', args, blocking=blocking, engine=self)
×
3137
        return resp
×
3138

3139
    # fmt: off
3140
    @overload
4✔
3141
    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✔
3142
    @overload
4✔
3143
    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✔
3144
    @overload
4✔
3145
    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✔
3146
    @overload
4✔
3147
    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✔
3148
    # fmt: on
3149
    async def win_wait_not_active(
4✔
3150
        self,
3151
        title: str = '',
3152
        text: str = '',
3153
        exclude_title: str = '',
3154
        exclude_text: str = '',
3155
        *,
3156
        title_match_mode: Optional[TitleMatchMode] = None,
3157
        detect_hidden_windows: Optional[bool] = None,
3158
        timeout: Optional[int] = None,
3159
        blocking: bool = True,
3160
    ) -> Union[AsyncWindow, AsyncFutureResult[AsyncWindow]]:
3161
        """
3162
        Analog for `WinWaitNotActive <https://www.autohotkey.com/docs/commands/WinWaitActive.htm>`_
3163
        """
3164
        args = self._format_win_args(
×
3165
            title=title,
3166
            text=text,
3167
            exclude_title=exclude_title,
3168
            exclude_text=exclude_text,
3169
            title_match_mode=title_match_mode,
3170
            detect_hidden_windows=detect_hidden_windows,
3171
        )
3172
        args.append(str(timeout) if timeout else '')
×
3173
        resp = await self._transport.function_call('AHKWinWaitNotActive', args, blocking=blocking, engine=self)
×
3174
        return resp
×
3175

3176
    # fmt: off
3177
    @overload
4✔
3178
    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✔
3179
    @overload
4✔
3180
    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✔
3181
    @overload
4✔
3182
    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✔
3183
    @overload
4✔
3184
    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✔
3185
    # fmt: on
3186
    async def win_wait_close(
4✔
3187
        self,
3188
        title: str = '',
3189
        text: str = '',
3190
        exclude_title: str = '',
3191
        exclude_text: str = '',
3192
        *,
3193
        title_match_mode: Optional[TitleMatchMode] = None,
3194
        detect_hidden_windows: Optional[bool] = None,
3195
        timeout: Optional[int] = None,
3196
        blocking: bool = True,
3197
    ) -> Union[None, AsyncFutureResult[None]]:
3198
        """
3199
        Analog for `WinWaitClose <https://www.autohotkey.com/docs/commands/WinWaitClose.htm>`_
3200
        """
3201
        args = self._format_win_args(
×
3202
            title=title,
3203
            text=text,
3204
            exclude_title=exclude_title,
3205
            exclude_text=exclude_text,
3206
            title_match_mode=title_match_mode,
3207
            detect_hidden_windows=detect_hidden_windows,
3208
        )
3209
        args.append(str(timeout) if timeout else '')
×
3210
        resp = await self._transport.function_call('AHKWinWaitClose', args, blocking=blocking, engine=self)
×
3211
        return resp
×
3212

3213
    # fmt: off
3214
    @overload
4✔
3215
    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✔
3216
    @overload
4✔
3217
    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✔
3218
    @overload
4✔
3219
    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✔
3220
    @overload
4✔
3221
    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✔
3222
    # fmt: on
3223
    async def win_show(
4✔
3224
        self,
3225
        title: str = '',
3226
        text: str = '',
3227
        exclude_title: str = '',
3228
        exclude_text: str = '',
3229
        *,
3230
        title_match_mode: Optional[TitleMatchMode] = None,
3231
        detect_hidden_windows: Optional[bool] = None,
3232
        blocking: bool = True,
3233
    ) -> Union[None, AsyncFutureResult[None]]:
3234
        """
3235
        Analog for `WinShow <https://www.autohotkey.com/docs/commands/WinShow.htm>`_
3236
        """
3237
        args = self._format_win_args(
×
3238
            title=title,
3239
            text=text,
3240
            exclude_title=exclude_title,
3241
            exclude_text=exclude_text,
3242
            title_match_mode=title_match_mode,
3243
            detect_hidden_windows=detect_hidden_windows,
3244
        )
3245
        resp = await self._transport.function_call('AHKWinShow', args, blocking=blocking)
×
3246
        return resp
×
3247

3248
    # fmt: off
3249
    @overload
4✔
3250
    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✔
3251
    @overload
4✔
3252
    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✔
3253
    @overload
4✔
3254
    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✔
3255
    @overload
4✔
3256
    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✔
3257
    # fmt: on
3258
    async def win_hide(
4✔
3259
        self,
3260
        title: str = '',
3261
        text: str = '',
3262
        exclude_title: str = '',
3263
        exclude_text: str = '',
3264
        *,
3265
        title_match_mode: Optional[TitleMatchMode] = None,
3266
        detect_hidden_windows: Optional[bool] = None,
3267
        blocking: bool = True,
3268
    ) -> Union[None, AsyncFutureResult[None]]:
3269
        """
3270
        Analog for `WinHide <https://www.autohotkey.com/docs/commands/WinHide.htm>`_
3271
        """
3272
        args = self._format_win_args(
×
3273
            title=title,
3274
            text=text,
3275
            exclude_title=exclude_title,
3276
            exclude_text=exclude_text,
3277
            title_match_mode=title_match_mode,
3278
            detect_hidden_windows=detect_hidden_windows,
3279
        )
3280
        resp = await self._transport.function_call('AHKWinHide', args, blocking=blocking)
×
3281
        return resp
×
3282

3283
    # fmt: off
3284
    @overload
4✔
3285
    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✔
3286
    @overload
4✔
3287
    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✔
3288
    @overload
4✔
3289
    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✔
3290
    @overload
4✔
3291
    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✔
3292
    # fmt: on
3293
    async def win_is_active(
4✔
3294
        self,
3295
        title: str = '',
3296
        text: str = '',
3297
        exclude_title: str = '',
3298
        exclude_text: str = '',
3299
        *,
3300
        title_match_mode: Optional[TitleMatchMode] = None,
3301
        detect_hidden_windows: Optional[bool] = None,
3302
        blocking: bool = True,
3303
    ) -> Union[bool, AsyncFutureResult[bool]]:
3304
        """
3305
        Check if a window is active.
3306

3307
        Uses `WinActive <https://www.autohotkey.com/docs/v1/lib/WinActive.htm>`_
3308
        """
3309
        args = self._format_win_args(
4✔
3310
            title=title,
3311
            text=text,
3312
            exclude_title=exclude_title,
3313
            exclude_text=exclude_text,
3314
            title_match_mode=title_match_mode,
3315
            detect_hidden_windows=detect_hidden_windows,
3316
        )
3317
        resp = await self._transport.function_call('AHKWinIsActive', args, blocking=blocking)
4✔
3318
        return resp
4✔
3319

3320
    # fmt: off
3321
    @overload
4✔
3322
    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✔
3323
    @overload
4✔
3324
    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✔
3325
    @overload
4✔
3326
    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✔
3327
    @overload
4✔
3328
    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✔
3329
    # fmt: on
3330
    async def win_move(
4✔
3331
        self,
3332
        x: int,
3333
        y: int,
3334
        *,
3335
        width: Optional[int] = None,
3336
        height: Optional[int] = None,
3337
        title: str = '',
3338
        text: str = '',
3339
        exclude_title: str = '',
3340
        exclude_text: str = '',
3341
        title_match_mode: Optional[TitleMatchMode] = None,
3342
        detect_hidden_windows: Optional[bool] = None,
3343
        blocking: bool = True,
3344
    ) -> Union[None, AsyncFutureResult[None]]:
3345
        """
3346
        Analog for `WinMove <https://www.autohotkey.com/docs/commands/WinMove.htm>`_
3347
        """
3348
        args = self._format_win_args(
4✔
3349
            title=title,
3350
            text=text,
3351
            exclude_title=exclude_title,
3352
            exclude_text=exclude_text,
3353
            title_match_mode=title_match_mode,
3354
            detect_hidden_windows=detect_hidden_windows,
3355
        )
3356
        args.append(str(x))
4✔
3357
        args.append(str(y))
4✔
3358
        args.append(str(width) if width is not None else '')
4✔
3359
        args.append(str(height) if height is not None else '')
4✔
3360
        resp = await self._transport.function_call('AHKWinMove', args, blocking=blocking)
4✔
3361
        return resp
4✔
3362

3363
    # fmt: off
3364
    @overload
4✔
3365
    async def get_clipboard(self) -> str: ...
4✔
3366
    @overload
4✔
3367
    async def get_clipboard(self, *, blocking: Literal[False]) -> AsyncFutureResult[str]: ...
4✔
3368
    @overload
4✔
3369
    async def get_clipboard(self, *, blocking: Literal[True]) -> str: ...
4✔
3370
    @overload
4✔
3371
    async def get_clipboard(self, *, blocking: bool = True) -> Union[str, AsyncFutureResult[str]]: ...
4✔
3372
    # fmt: on
3373
    async def get_clipboard(self, *, blocking: bool = True) -> Union[str, AsyncFutureResult[str]]:
4✔
3374
        """
3375
        Get the string contents of the clipboard
3376
        """
3377
        return await self._transport.function_call('AHKGetClipboard', blocking=blocking)
4✔
3378

3379
    async def set_clipboard(self, s: str, *, blocking: bool = True) -> Union[None, AsyncFutureResult[None]]:
4✔
3380
        """
3381
        Set the contents of the clipboard
3382
        """
3383
        args = [s]
4✔
3384
        return await self._transport.function_call('AHKSetClipboard', args, blocking=blocking)
4✔
3385

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

3392
    # fmt: off
3393
    @overload
4✔
3394
    async def set_clipboard_all(self, contents: bytes) -> None: ...
4✔
3395
    @overload
4✔
3396
    async def set_clipboard_all(self, contents: bytes, *, blocking: Literal[False]) -> AsyncFutureResult[None]: ...
4✔
3397
    @overload
4✔
3398
    async def set_clipboard_all(self, contents: bytes, *, blocking: Literal[True]) -> None: ...
4✔
3399
    @overload
4✔
3400
    async def set_clipboard_all(self, contents: bytes, *, blocking: bool = True) -> Union[None, AsyncFutureResult[None]]: ...
4✔
3401
    # fmt: on
3402
    async def set_clipboard_all(
4✔
3403
        self, contents: bytes, *, blocking: bool = True
3404
    ) -> Union[None, AsyncFutureResult[None]]:
3405
        """
3406
        Set the full binary contents of the clipboard. Expects bytes object as returned by :py:meth:`get_clipboard_all`
3407
        """
3408
        # TODO: figure out how to do this without a tempfile
3409
        if not isinstance(contents, bytes):
4✔
3410
            raise ValueError('Malformed data. Can only set bytes as returned by get_clipboard_all')
×
3411
        if not contents:
4✔
3412
            raise ValueError('bytes must be nonempty. If you want to clear the clipboard, use `set_clipboard`')
×
3413
        with tempfile.NamedTemporaryFile(prefix='ahk-python', suffix='.clip', mode='wb', delete=False) as f:
4✔
3414
            f.write(contents)
4✔
3415

3416
        args = [f'*c {f.name}']
4✔
3417
        try:
4✔
3418
            resp = await self._transport.function_call('AHKSetClipboardAll', args, blocking=blocking)
4✔
3419
            return resp
4✔
3420
        finally:
3421
            try:
4✔
3422
                os.remove(f.name)
4✔
3423
            except Exception:
×
3424
                pass
×
3425

3426
    def on_clipboard_change(
4✔
3427
        self, callback: Callable[[int], Any], ex_handler: Optional[Callable[[int, Exception], Any]] = None
3428
    ) -> None:
3429
        """
3430
        call a function in response to clipboard change.
3431
        Uses `OnClipboardChange() <https://www.autohotkey.com/docs/commands/OnClipboardChange.htm#function>`_
3432
        """
3433
        self._transport.on_clipboard_change(callback, ex_handler)
4✔
3434

3435
    # fmt: off
3436
    @overload
4✔
3437
    async def clip_wait(self, timeout: Optional[float] = None, wait_for_any_data: bool = False) -> None: ...
4✔
3438
    @overload
4✔
3439
    async def clip_wait(self, timeout: Optional[float] = None, wait_for_any_data: bool = False, *, blocking: Literal[False]) -> AsyncFutureResult[None]: ...
4✔
3440
    @overload
4✔
3441
    async def clip_wait(self, timeout: Optional[float] = None, wait_for_any_data: bool = False, *, blocking: Literal[True]) -> None: ...
4✔
3442
    @overload
4✔
3443
    async def clip_wait(self, timeout: Optional[float] = None, wait_for_any_data: bool = False, *, blocking: bool = True) -> Union[None, AsyncFutureResult[None]]: ...
4✔
3444
    # fmt: on
3445
    async def clip_wait(
4✔
3446
        self, timeout: Optional[float] = None, wait_for_any_data: bool = False, *, blocking: bool = True
3447
    ) -> Union[None, AsyncFutureResult[None]]:
3448
        """
3449
        Wait until the clipboard contents change
3450

3451
        Analog for `ClipWait <https://www.autohotkey.com/docs/v1/lib/ClipWait.htm>`_
3452
        """
3453
        args = [str(timeout) if timeout else '']
×
3454
        if wait_for_any_data:
×
3455
            args.append('1')
×
3456
        return await self._transport.function_call('AHKClipWait', args, blocking=blocking)
×
3457

3458
    async def block_input(
4✔
3459
        self,
3460
        value: Literal['On', 'Off', 'Default', 'Send', 'Mouse', 'MouseMove', 'MouseMoveOff', 'SendAndMouse'],
3461
        /,  # flake8: noqa
3462
    ) -> None:
3463
        """
3464
        Analog for `BlockInput <https://www.autohotkey.com/docs/commands/BlockInput.htm>`_
3465
        """
3466
        await self._transport.function_call('AHKBlockInput', args=[value])
×
3467

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

3487
    # fmt: off
3488
    @overload
4✔
3489
    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✔
3490
    @overload
4✔
3491
    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✔
3492
    @overload
4✔
3493
    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✔
3494
    @overload
4✔
3495
    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✔
3496
    # fmt: on
3497
    async def reg_write(
4✔
3498
        self,
3499
        value_type: Literal['REG_SZ', 'REG_EXPAND_SZ', 'REG_MULTI_SZ', 'REG_DWORD', 'REG_BINARY'],
3500
        key_name: str,
3501
        value_name: Optional[str] = None,
3502
        value: Optional[str] = None,
3503
        *,
3504
        blocking: bool = True,
3505
    ) -> Union[None, AsyncFutureResult[None]]:
3506
        """
3507
        Analog for `RegWrite <https://www.autohotkey.com/docs/commands/RegWrite.htm>`_
3508
        """
3509
        args = [value_type, key_name]
4✔
3510
        if value_name is not None:
4✔
3511
            args.append(value_name)
4✔
3512
        else:
3513
            args.append('')
4✔
3514
        if value is not None:
4✔
3515
            args.append(value)
4✔
3516
        return await self._transport.function_call('AHKRegWrite', args, blocking=blocking)
4✔
3517

3518
    # fmt: off
3519
    @overload
4✔
3520
    async def reg_read(self, key_name: str, value_name: Optional[str] = None) -> str: ...
4✔
3521
    @overload
4✔
3522
    async def reg_read(self, key_name: str, value_name: Optional[str] = None, *, blocking: Literal[False]) -> AsyncFutureResult[str]: ...
4✔
3523
    @overload
4✔
3524
    async def reg_read(self, key_name: str, value_name: Optional[str] = None, *, blocking: Literal[True]) -> str: ...
4✔
3525
    @overload
4✔
3526
    async def reg_read(self, key_name: str, value_name: Optional[str] = None, *, blocking: bool = True) -> Union[str, AsyncFutureResult[str]]: ...
4✔
3527
    # fmt: on
3528
    async def reg_read(
4✔
3529
        self, key_name: str, value_name: Optional[str] = None, *, blocking: bool = True
3530
    ) -> Union[str, AsyncFutureResult[str]]:
3531
        """
3532
        Analog for `RegRead <https://www.autohotkey.com/docs/commands/RegRead.htm>`_
3533
        """
3534
        args = [key_name]
4✔
3535
        if value_name is not None:
4✔
3536
            args.append(value_name)
4✔
3537
        return await self._transport.function_call('AHKRegRead', args, blocking=blocking)
4✔
3538

3539
    # fmt: off
3540
    @overload
4✔
3541
    async def msg_box(self, text: str = '', title: str = 'Message', buttons: MsgBoxButtons = MsgBoxButtons.OK, icon: Optional[MsgBoxIcon] = None, default_button: Optional[MsgBoxDefaultButton] = None, modality: Optional[MsgBoxModality] = None, help_button: bool = False, text_right_justified: bool = False, right_to_left_reading: bool = False, timeout: Optional[int] = None) -> str: ...
4✔
3542
    @overload
4✔
3543
    async def msg_box(self, text: str = '', title: str = 'Message', buttons: MsgBoxButtons = MsgBoxButtons.OK, icon: Optional[MsgBoxIcon] = None, default_button: Optional[MsgBoxDefaultButton] = None, modality: Optional[MsgBoxModality] = None, help_button: bool = False, text_right_justified: bool = False, right_to_left_reading: bool = False, timeout: Optional[int] = None, *, blocking: Literal[False]) -> AsyncFutureResult[str]: ...
4✔
3544
    @overload
4✔
3545
    async def msg_box(self, text: str = '', title: str = 'Message', buttons: MsgBoxButtons = MsgBoxButtons.OK, icon: Optional[MsgBoxIcon] = None, default_button: Optional[MsgBoxDefaultButton] = None, modality: Optional[MsgBoxModality] = None, help_button: bool = False, text_right_justified: bool = False, right_to_left_reading: bool = False, timeout: Optional[int] = None, *, blocking: Literal[True]) -> str: ...
4✔
3546
    @overload
4✔
3547
    async def msg_box(self, text: str = '', title: str = 'Message', buttons: MsgBoxButtons = MsgBoxButtons.OK, icon: Optional[MsgBoxIcon] = None, default_button: Optional[MsgBoxDefaultButton] = None, modality: Optional[MsgBoxModality] = None, help_button: bool = False, text_right_justified: bool = False, right_to_left_reading: bool = False, timeout: Optional[int] = None, *, blocking: bool = True) -> Union[str, AsyncFutureResult[str]]: ...
4✔
3548
    # fmt: on
3549
    async def msg_box(
4✔
3550
        self,
3551
        text: str = '',
3552
        title: str = 'Message',
3553
        buttons: MsgBoxButtons = MsgBoxButtons.OK,
3554
        icon: Optional[MsgBoxIcon] = None,
3555
        default_button: Optional[MsgBoxDefaultButton] = None,
3556
        modality: Optional[MsgBoxModality] = None,
3557
        help_button: bool = False,
3558
        text_right_justified: bool = False,
3559
        right_to_left_reading: bool = False,
3560
        timeout: Optional[int] = None,
3561
        *,
3562
        blocking: bool = True,
3563
    ) -> Union[str, AsyncFutureResult[str]]:
3564
        options: int = int(buttons)
4✔
3565
        for opt in (icon, default_button, modality):
4✔
3566
            if opt is not None:
4✔
3567
                options += opt
×
3568
        if help_button:
4✔
3569
            options += MsgBoxOtherOptions.HELP_BUTTON
×
3570
        if text_right_justified:
4✔
3571
            options += MsgBoxOtherOptions.TEXT_RIGHT_JUSTIFIED
×
3572
        if right_to_left_reading:
4✔
3573
            options += MsgBoxOtherOptions.RIGHT_TO_LEFT_READING_ORDER
×
3574

3575
        args = [str(options), title, text]
4✔
3576
        if timeout is not None:
4✔
3577
            args.append(str(timeout))
4✔
3578
        return await self._transport.function_call('AHKMsgBox', args, blocking=blocking)
4✔
3579

3580
    # fmt: off
3581
    @overload
4✔
3582
    async def input_box(self, prompt: str = '', title: str = 'Input', default: str = '', hide: bool = False, width: Optional[int] = None, height: Optional[int] = None, x: Optional[int] = None, y: Optional[int] = None, locale: bool = True, timeout: Optional[int] = None) -> Union[None, str]: ...
4✔
3583
    @overload
4✔
3584
    async def input_box(self, prompt: str = '', title: str = 'Input', default: str = '', hide: bool = False, width: Optional[int] = None, height: Optional[int] = None, x: Optional[int] = None, y: Optional[int] = None, locale: bool = True, timeout: Optional[int] = None, *, blocking: Literal[False]) -> Union[AsyncFutureResult[str], AsyncFutureResult[None]]: ...
4✔
3585
    @overload
4✔
3586
    async def input_box(self, prompt: str = '', title: str = 'Input', default: str = '', hide: bool = False, width: Optional[int] = None, height: Optional[int] = None, x: Optional[int] = None, y: Optional[int] = None, locale: bool = True, timeout: Optional[int] = None, *, blocking: Literal[True]) -> Union[str, None]: ...
4✔
3587
    @overload
4✔
3588
    async def input_box(self, prompt: str = '', title: str = 'Input', default: str = '', hide: bool = False, width: Optional[int] = None, height: Optional[int] = None, x: Optional[int] = None, y: Optional[int] = None, locale: bool = True, timeout: Optional[int] = None, *, blocking: bool = True) -> Union[str, None, AsyncFutureResult[str], AsyncFutureResult[None]]: ...
4✔
3589
    # fmt: on
3590
    async def input_box(
4✔
3591
        self,
3592
        prompt: str = '',
3593
        title: str = 'Input',
3594
        default: str = '',
3595
        hide: bool = False,
3596
        width: Optional[int] = None,
3597
        height: Optional[int] = None,
3598
        x: Optional[int] = None,
3599
        y: Optional[int] = None,
3600
        locale: bool = True,
3601
        timeout: Optional[int] = None,
3602
        *,
3603
        blocking: bool = True,
3604
    ) -> Union[None, str, AsyncFutureResult[str], AsyncFutureResult[None]]:
3605
        """
3606
        Like AHK's ``InputBox``
3607

3608
        If the user presses Cancel or closes the box, ``None`` is returned.
3609
        Otherwise, the user's input is returned.
3610
        Raises a ``TimeoutError`` if a timeout is specified and expires.
3611
        """
3612
        args = [title, prompt]
4✔
3613
        if hide:
4✔
3614
            args.append('hide')
×
3615
        else:
3616
            args.append('')
4✔
3617
        for opt in (width, height, x, y):
4✔
3618
            if opt is not None:
4✔
3619
                args.append(str(opt))
×
3620
            else:
3621
                args.append('')
4✔
3622
        if locale:
4✔
3623
            args.append('Locale')
4✔
3624
        else:
3625
            args.append('')
×
3626
        if timeout is not None:
4✔
3627
            args.append(str(timeout))
4✔
3628
        else:
3629
            args.append('')
×
3630
        args.append(default)
4✔
3631
        return await self._transport.function_call('AHKInputBox', args, blocking=blocking)
4✔
3632

3633
    # fmt: off
3634
    @overload
4✔
3635
    async def file_select_box(self, title: str = 'Select File', multi: bool = False, root: str = '', filter: str = '', save_button: bool = False, file_must_exist: bool = False, path_must_exist: bool = False, prompt_create_new_file: bool = False, prompt_override_file: bool = False, follow_shortcuts: bool = True) -> Union[None, str]: ...
4✔
3636
    @overload
4✔
3637
    async def file_select_box(self, title: str = 'Select File', multi: bool = False, root: str = '', filter: str = '', save_button: bool = False, file_must_exist: bool = False, path_must_exist: bool = False, prompt_create_new_file: bool = False, prompt_override_file: bool = False, follow_shortcuts: bool = True, *, blocking: Literal[False]) -> Union[AsyncFutureResult[str], AsyncFutureResult[None]]: ...
4✔
3638
    @overload
4✔
3639
    async def file_select_box(self, title: str = 'Select File', multi: bool = False, root: str = '', filter: str = '', save_button: bool = False, file_must_exist: bool = False, path_must_exist: bool = False, prompt_create_new_file: bool = False, prompt_override_file: bool = False, follow_shortcuts: bool = True, *, blocking: Literal[True]) -> Union[str, None]: ...
4✔
3640
    @overload
4✔
3641
    async def file_select_box(self, title: str = 'Select File', multi: bool = False, root: str = '', filter: str = '', save_button: bool = False, file_must_exist: bool = False, path_must_exist: bool = False, prompt_create_new_file: bool = False, prompt_override_file: bool = False, follow_shortcuts: bool = True, *, blocking: bool = True) -> Union[str, None, AsyncFutureResult[str], AsyncFutureResult[None]]: ...
4✔
3642
    # fmt: on
3643
    async def file_select_box(
4✔
3644
        self,
3645
        title: str = 'Select File',
3646
        multi: bool = False,
3647
        root: str = '',
3648
        filter: str = '',
3649
        save_button: bool = False,
3650
        file_must_exist: bool = False,
3651
        path_must_exist: bool = False,
3652
        prompt_create_new_file: bool = False,
3653
        prompt_override_file: bool = False,
3654
        follow_shortcuts: bool = True,
3655
        *,
3656
        blocking: bool = True,
3657
    ) -> Union[str, None, AsyncFutureResult[str], AsyncFutureResult[None]]:
3658
        opts = 0
×
3659
        if file_must_exist:
×
3660
            opts += 1
×
3661
        if path_must_exist:
×
3662
            opts += 2
×
3663
        if prompt_create_new_file:
×
3664
            opts += 8
×
3665
        if prompt_override_file:
×
3666
            opts += 8
×
3667
        if not follow_shortcuts:
×
3668
            opts += 32
×
3669
        options = ''
×
3670
        if multi:
×
3671
            options += 'M'
×
3672
        if save_button:
×
3673
            options += 'S'
×
3674
        if opts:
×
3675
            options += str(opts)
×
3676
        args = [options, root, title, filter]
×
3677
        return await self._transport.function_call('AHKFileSelectFile', args, blocking=blocking)
×
3678

3679
    # fmt: off
3680
    @overload
4✔
3681
    async def folder_select_box(self, prompt: str = 'Select Folder', root: str = '', chroot: bool = False, enable_new_directories: bool = True, edit_field: bool = False, new_dialog_style: bool = False) -> Union[None, str]: ...
4✔
3682
    @overload
4✔
3683
    async def folder_select_box(self, prompt: str = 'Select Folder', root: str = '', chroot: bool = False, enable_new_directories: bool = True, edit_field: bool = False, new_dialog_style: bool = False, *, blocking: Literal[False]) -> Union[AsyncFutureResult[str], AsyncFutureResult[None]]: ...
4✔
3684
    @overload
4✔
3685
    async def folder_select_box(self, prompt: str = 'Select Folder', root: str = '', chroot: bool = False, enable_new_directories: bool = True, edit_field: bool = False, new_dialog_style: bool = False, *, blocking: Literal[True]) -> Union[str, None]: ...
4✔
3686
    @overload
4✔
3687
    async def folder_select_box(self, prompt: str = 'Select Folder', root: str = '', chroot: bool = False, enable_new_directories: bool = True, edit_field: bool = False, new_dialog_style: bool = False, *, blocking: bool = True) -> Union[str, None, AsyncFutureResult[str], AsyncFutureResult[None]]: ...
4✔
3688
    # fmt: on
3689
    async def folder_select_box(
4✔
3690
        self,
3691
        prompt: str = 'Select Folder',
3692
        root: str = '',
3693
        chroot: bool = False,
3694
        enable_new_directories: bool = True,
3695
        edit_field: bool = False,
3696
        new_dialog_style: bool = False,
3697
        *,
3698
        blocking: bool = True,
3699
    ) -> Union[str, None, AsyncFutureResult[str], AsyncFutureResult[None]]:
3700
        if not chroot:
×
3701
            starting_folder = '*'
×
3702
        else:
3703
            starting_folder = ''
×
3704
        starting_folder += root
×
3705
        if enable_new_directories:
×
3706
            opts = 1
×
3707
        else:
3708
            opts = 0
×
3709
        if edit_field:
×
3710
            opts += 2
×
3711
        if new_dialog_style:
×
3712
            opts += 4
×
3713
        args = [starting_folder, str(opts), prompt]
×
3714
        return await self._transport.function_call('AHKFileSelectFolder', args, blocking=blocking)
×
3715

3716
    async def block_forever(self) -> NoReturn:
4✔
3717
        """
3718
        Blocks (sleeps) forever. Utility method to prevent script from exiting.
3719
        """
3720
        while True:
3721
            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