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

spyoungtech / ahk / 4857440128

pending completion
4857440128

push

github

GitHub
Merge pull request #185 from spyoungtech/rewrite

5666 of 5666 new or added lines in 16 files covered. (100.0%)

4345 of 5787 relevant lines covered (75.08%)

3.0 hits per line

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

67.03
/ahk/_sync/engine.py
1
from __future__ import annotations
4✔
2

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

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

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

32
from ..keys import Key
4✔
33
from .transport import DaemonProcessTransport
4✔
34
from .transport import FutureResult
4✔
35
from .transport import Transport
4✔
36
from .window import Control
4✔
37
from .window import Window
4✔
38
from ahk.message import Position
4✔
39

40
sleep = time.sleep
4✔
41

42
SyncFilterFunc: TypeAlias = Callable[[Window], bool]
4✔
43

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

49
CoordMode: TypeAlias = Union[CoordModeTargets, Tuple[CoordModeTargets, CoordModeRelativeTo]]
4✔
50

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

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

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

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

91
SyncPropertyReturnTupleIntInt: TypeAlias = Tuple[int, int]
4✔
92

93
SyncPropertyReturnOptionalAsyncWindow: TypeAlias = Optional[Window]
4✔
94

95
_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✔
96

97

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

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

118

119
class AHK:
4✔
120
    def __init__(
4✔
121
        self,
122
        *,
123
        TransportClass: Optional[Type[Transport]] = None,
124
        directives: Optional[list[Directive | Type[Directive]]] = None,
125
        executable_path: str = '',
126
    ):
127
        if TransportClass is None:
4✔
128
            TransportClass = DaemonProcessTransport
4✔
129
        assert TransportClass is not None
4✔
130
        transport = TransportClass(executable_path=executable_path, directives=directives)
4✔
131
        self._transport: Transport = transport
4✔
132

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

139
        Key notes:
140

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

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

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

169
        Key notes:
170

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

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

188
    def set_title_match_mode(self, title_match_mode: TitleMatchMode, /) -> None:
4✔
189
        """
190
        Sets the default title match mode
191

192
        Has no effect for `Window`/`Control` instance methods (these always use hwnd)
193

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

196
        Reference: https://www.autohotkey.com/docs/commands/SetTitleMatchMode.htm
197

198
        :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.
199
        :return: None
200
        """
201

202
        args = []
4✔
203
        if isinstance(title_match_mode, tuple):
4✔
204
            (match_mode, match_speed) = title_match_mode
4✔
205
        elif title_match_mode in (1, 2, 3, 'RegEx'):
4✔
206
            match_mode = title_match_mode
4✔
207
            match_speed = ''
4✔
208
        elif title_match_mode in ('Fast', 'Slow'):
4✔
209
            match_mode = ''
4✔
210
            match_speed = title_match_mode
4✔
211
        else:
212
            raise ValueError(
×
213
                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}"
214
            )
215
        args.append(str(match_mode))
4✔
216
        args.append(str(match_speed))
4✔
217
        self._transport.function_call('AHKSetTitleMatchMode', args)
4✔
218
        return None
4✔
219

220
    def get_title_match_mode(self) -> str:
4✔
221
        """
222
        Get the title match mode.
223

224
        I.E. the current value of `A_TitleMatchMode`
225

226
        """
227
        resp = self._transport.function_call('AHKGetTitleMatchMode')
4✔
228
        return resp
4✔
229

230
    def get_title_match_speed(self) -> str:
4✔
231
        """
232
        Get the title match mode speed.
233

234
        I.E. the current value of `A_TitleMatchModeSpeed`
235

236
        """
237
        resp = self._transport.function_call('AHKGetTitleMatchSpeed')
4✔
238
        return resp
4✔
239

240
    def set_coord_mode(self, target: CoordModeTargets, relative_to: CoordModeRelativeTo = 'Screen') -> None:
4✔
241
        args = [str(target), str(relative_to)]
×
242
        self._transport.function_call('AHKSetCoordMode', args)
×
243
        return None
×
244

245
    def get_coord_mode(self, target: CoordModeTargets) -> str:
4✔
246
        args = [str(target)]
×
247
        resp = self._transport.function_call('AHKGetCoordMode', args)
×
248
        return resp
×
249

250
    # fmt: off
251
    @overload
4✔
252
    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✔
253
    @overload
4✔
254
    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]) -> FutureResult[None]: ...
4✔
255
    @overload
4✔
256
    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✔
257
    @overload
4✔
258
    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, FutureResult[None]]: ...
4✔
259
    # fmt: on
260
    def control_click(
4✔
261
        self,
262
        button: Literal['L', 'R', 'M', 'LEFT', 'RIGHT', 'MIDDLE'] = 'L',
263
        click_count: int = 1,
264
        options: str = '',
265
        control: str = '',
266
        title: str = '',
267
        text: str = '',
268
        exclude_title: str = '',
269
        exclude_text: str = '',
270
        *,
271
        title_match_mode: Optional[TitleMatchMode] = None,
272
        detect_hidden_windows: Optional[bool] = None,
273
        blocking: bool = True,
274
    ) -> Union[None, FutureResult[None]]:
275
        """
276

277
        :param button: the mouse button to use
278
        :param click_count: how many times to click
279
        :param options: options -- same meaning as in AutoHotkey
280
        :param control: the control to click
281
        :param title:
282
        :param text:
283
        :param exclude_title:
284
        :param exclude_text:
285
        :param title_match_mode:
286
        :param detect_hidden_windows:
287
        :param blocking:
288
        :return:
289
        """
290
        args = [control, title, text, str(button), str(click_count), options, exclude_title, exclude_text]
×
291
        if detect_hidden_windows is not None:
×
292
            if detect_hidden_windows is True:
×
293
                args.append('On')
×
294
            elif detect_hidden_windows is False:
×
295
                args.append('Off')
×
296
            else:
297
                raise TypeError(
×
298
                    f'Invalid value for parameter detect_hidden_windows. Expected boolean or None, got {detect_hidden_windows!r}'
299
                )
300
        else:
301
            args.append('')
×
302
        if title_match_mode is not None:
×
303
            if isinstance(title_match_mode, tuple):
×
304
                match_mode, match_speed = title_match_mode
×
305
            elif title_match_mode in (1, 2, 3, 'RegEx'):
×
306
                match_mode = title_match_mode
×
307
                match_speed = ''
×
308
            elif title_match_mode in ('Fast', 'Slow'):
×
309
                match_mode = ''
×
310
                match_speed = title_match_mode
×
311
            else:
312
                raise ValueError(
×
313
                    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}"
314
                )
315
            args.append(str(match_mode))
×
316
            args.append(str(match_speed))
×
317
        else:
318
            args.append('')
×
319
            args.append('')
×
320
        resp = self._transport.function_call('AHKControlClick', args=args, blocking=blocking)
×
321

322
        return resp
×
323

324
    # fmt: off
325
    @overload
4✔
326
    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✔
327
    @overload
4✔
328
    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]) -> FutureResult[str]: ...
4✔
329
    @overload
4✔
330
    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✔
331
    @overload
4✔
332
    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, FutureResult[str]]: ...
4✔
333
    # fmt: on
334
    def control_get_text(
4✔
335
        self,
336
        *,
337
        control: str = '',
338
        title: str = '',
339
        text: str = '',
340
        exclude_title: str = '',
341
        exclude_text: str = '',
342
        title_match_mode: Optional[TitleMatchMode] = None,
343
        detect_hidden_windows: Optional[bool] = None,
344
        blocking: bool = True,
345
    ) -> Union[str, FutureResult[str]]:
346
        """
347
        Analog to ``ControlGetText``
348

349
        :param control:
350
        :param title:
351
        :param text:
352
        :param exclude_title:
353
        :param exclude_text:
354
        :param title_match_mode:
355
        :param detect_hidden_windows:
356
        :param blocking:
357
        :return:
358
        """
359
        args = [control, title, text, exclude_title, exclude_text]
×
360
        if detect_hidden_windows is not None:
×
361
            if detect_hidden_windows is True:
×
362
                args.append('On')
×
363
            elif detect_hidden_windows is False:
×
364
                args.append('Off')
×
365
            else:
366
                raise TypeError(
×
367
                    f'Invalid value for parameter detect_hidden_windows. Expected boolean or None, got {detect_hidden_windows!r}'
368
                )
369
        else:
370
            args.append('')
×
371
        if title_match_mode is not None:
×
372
            if isinstance(title_match_mode, tuple):
×
373
                match_mode, match_speed = title_match_mode
×
374
            elif title_match_mode in (1, 2, 3, 'RegEx'):
×
375
                match_mode = title_match_mode
×
376
                match_speed = ''
×
377
            elif title_match_mode in ('Fast', 'Slow'):
×
378
                match_mode = ''
×
379
                match_speed = title_match_mode
×
380
            else:
381
                raise ValueError(
×
382
                    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}"
383
                )
384
            args.append(str(match_mode))
×
385
            args.append(str(match_speed))
×
386
        else:
387
            args.append('')
×
388
            args.append('')
×
389
        resp = self._transport.function_call('AHKControlGetText', args, blocking=blocking)
×
390
        return resp
×
391

392
    # fmt: off
393
    @overload
4✔
394
    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✔
395
    @overload
4✔
396
    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]) -> FutureResult[Position]: ...
4✔
397
    @overload
4✔
398
    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✔
399
    @overload
4✔
400
    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, FutureResult[Position]]: ...
4✔
401
    # fmt: on
402
    def control_get_position(
4✔
403
        self,
404
        control: str = '',
405
        title: str = '',
406
        text: str = '',
407
        exclude_title: str = '',
408
        exclude_text: str = '',
409
        *,
410
        title_match_mode: Optional[TitleMatchMode] = None,
411
        detect_hidden_windows: Optional[bool] = None,
412
        blocking: bool = True,
413
    ) -> Union[Position, FutureResult[Position]]:
414
        """
415
        Analog to ``ControlGetPos``
416

417
        :param control:
418
        :param title:
419
        :param text:
420
        :param exclude_title:
421
        :param exclude_text:
422
        :param title_match_mode:
423
        :param detect_hidden_windows:
424
        :param blocking:
425
        :return:
426
        """
427
        args = [control, title, text, exclude_title, exclude_text]
4✔
428
        if detect_hidden_windows is not None:
4✔
429
            if detect_hidden_windows is True:
4✔
430
                args.append('On')
4✔
431
            elif detect_hidden_windows is False:
×
432
                args.append('Off')
×
433
            else:
434
                raise TypeError(
×
435
                    f'Invalid value for parameter detect_hidden_windows. Expected boolean or None, got {detect_hidden_windows!r}'
436
                )
437
        else:
438
            args.append('')
×
439
        if title_match_mode is not None:
4✔
440
            if isinstance(title_match_mode, tuple):
4✔
441
                match_mode, match_speed = title_match_mode
4✔
442
            elif title_match_mode in (1, 2, 3, 'RegEx'):
×
443
                match_mode = title_match_mode
×
444
                match_speed = ''
×
445
            elif title_match_mode in ('Fast', 'Slow'):
×
446
                match_mode = ''
×
447
                match_speed = title_match_mode
×
448
            else:
449
                raise ValueError(
×
450
                    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}"
451
                )
452
            args.append(str(match_mode))
4✔
453
            args.append(str(match_speed))
4✔
454
        else:
455
            args.append('')
×
456
            args.append('')
×
457

458
        resp = self._transport.function_call('AHKControlGetPos', args, blocking=blocking)
4✔
459
        return resp
4✔
460

461
    # fmt: off
462
    @overload
4✔
463
    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✔
464
    @overload
4✔
465
    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]) -> FutureResult[None]: ...
4✔
466
    @overload
4✔
467
    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✔
468
    @overload
4✔
469
    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, FutureResult[None]]: ...
4✔
470
    # fmt: on
471
    def control_send(
4✔
472
        self,
473
        keys: str,
474
        control: str = '',
475
        title: str = '',
476
        text: str = '',
477
        exclude_title: str = '',
478
        exclude_text: str = '',
479
        *,
480
        title_match_mode: Optional[TitleMatchMode] = None,
481
        detect_hidden_windows: Optional[bool] = None,
482
        blocking: bool = True,
483
    ) -> Union[None, FutureResult[None]]:
484
        """
485
        Analog for ``ControlSend``
486

487
        Reference: https://www.autohotkey.com/docs/commands/ControlSend.htm
488

489
        :param keys:
490
        :param control:
491
        :param title:
492
        :param text:
493
        :param exclude_title:
494
        :param exclude_text:
495
        :param title_match_mode:
496
        :param detect_hidden_windows:
497
        :param blocking:
498
        :return:
499
        """
500
        args = [control, keys, title, text, exclude_title, exclude_text]
4✔
501
        if detect_hidden_windows is not None:
4✔
502
            if detect_hidden_windows is True:
4✔
503
                args.append('On')
4✔
504
            elif detect_hidden_windows is False:
×
505
                args.append('Off')
×
506
            else:
507
                raise TypeError(
×
508
                    f'Invalid value for parameter detect_hidden_windows. Expected boolean or None, got {detect_hidden_windows!r}'
509
                )
510
        else:
511
            args.append('')
×
512
        if title_match_mode is not None:
4✔
513
            if isinstance(title_match_mode, tuple):
4✔
514
                match_mode, match_speed = title_match_mode
4✔
515
            elif title_match_mode in (1, 2, 3, 'RegEx'):
×
516
                match_mode = title_match_mode
×
517
                match_speed = ''
×
518
            elif title_match_mode in ('Fast', 'Slow'):
×
519
                match_mode = ''
×
520
                match_speed = title_match_mode
×
521
            else:
522
                raise ValueError(
×
523
                    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}"
524
                )
525
            args.append(str(match_mode))
4✔
526
            args.append(str(match_speed))
4✔
527
        else:
528
            args.append('')
×
529
            args.append('')
×
530
        resp = self._transport.function_call('AHKControlSend', args, blocking=blocking)
4✔
531
        return resp
4✔
532

533
    # TODO: raw option for control_send
534

535
    def start_hotkeys(self) -> None:
4✔
536
        """
537
        Start the Autohotkey process for triggering hotkeys
538

539
        """
540
        return self._transport.start_hotkeys()
4✔
541

542
    def stop_hotkeys(self) -> None:
4✔
543
        """
544
        Stop the Autohotkey process for triggering hotkeys
545

546
        """
547
        return self._transport.stop_hotkeys()
4✔
548

549
    def set_detect_hidden_windows(self, value: bool) -> None:
4✔
550
        """
551
        Analog for AutoHotkey's `DetectHiddenWindows`
552

553
        :param value: The setting value. `True` to turn on hidden window detection, `False` to turn it off.
554

555
        """
556

557
        if value not in (True, False):
4✔
558
            raise TypeError(f'detect hidden windows must be a boolean, got object of type {type(value)}')
×
559
        args = []
4✔
560
        if value is True:
4✔
561
            args.append('On')
4✔
562
        else:
563
            args.append('Off')
×
564
        self._transport.function_call('AHKSetDetectHiddenWindows', args=args)
4✔
565
        return None
4✔
566

567
    @staticmethod
4✔
568
    def _format_win_args(
4✔
569
        title: str,
570
        text: str,
571
        exclude_title: str,
572
        exclude_text: str,
573
        title_match_mode: Optional[TitleMatchMode] = None,
574
        detect_hidden_windows: Optional[bool] = None,
575
    ) -> List[str]:
576
        args = [title, text, exclude_title, exclude_text]
4✔
577
        if detect_hidden_windows is not None:
4✔
578
            if detect_hidden_windows is True:
4✔
579
                args.append('On')
4✔
580
            elif detect_hidden_windows is False:
4✔
581
                args.append('Off')
4✔
582
            else:
583
                raise TypeError(
×
584
                    f'Invalid value for parameter detect_hidden_windows. Expected boolean or None, got {detect_hidden_windows!r}'
585
                )
586
        else:
587
            args.append('')
4✔
588
        if title_match_mode is not None:
4✔
589
            if isinstance(title_match_mode, tuple):
4✔
590
                match_mode, match_speed = title_match_mode
4✔
591
            elif title_match_mode in (1, 2, 3, 'RegEx'):
×
592
                match_mode = title_match_mode
×
593
                match_speed = ''
×
594
            elif title_match_mode in ('Fast', 'Slow'):
×
595
                match_mode = ''
×
596
                match_speed = title_match_mode
×
597
            else:
598
                raise ValueError(
×
599
                    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}"
600
                )
601
            args.append(str(match_mode))
4✔
602
            args.append(str(match_speed))
4✔
603
        else:
604
            args.append('')
4✔
605
            args.append('')
4✔
606
        return args
4✔
607

608
    # fmt: off
609
    @overload
4✔
610
    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[Window]: ...
4✔
611
    @overload
4✔
612
    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[Window], FutureResult[List[Window]]]: ...
4✔
613
    @overload
4✔
614
    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[Window]: ...
4✔
615
    @overload
4✔
616
    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[Window], FutureResult[List[Window]]]: ...
4✔
617
    # fmt: on
618
    def list_windows(
4✔
619
        self,
620
        title: str = '',
621
        text: str = '',
622
        exclude_title: str = '',
623
        exclude_text: str = '',
624
        *,
625
        title_match_mode: Optional[TitleMatchMode] = None,
626
        detect_hidden_windows: Optional[bool] = None,
627
        blocking: bool = True,
628
    ) -> Union[List[Window], FutureResult[List[Window]]]:
629
        """
630
        Enumerate all windows matching the criteria.
631

632

633
        :param title:
634
        :param text:
635
        :param exclude_title:
636
        :param exclude_text:
637
        :param title_match_mode:
638
        :param detect_hidden_windows:
639
        :param blocking:
640
        :return:
641
        """
642
        args = self._format_win_args(
4✔
643
            title=title,
644
            text=text,
645
            exclude_title=exclude_title,
646
            exclude_text=exclude_text,
647
            title_match_mode=title_match_mode,
648
            detect_hidden_windows=detect_hidden_windows,
649
        )
650
        resp = self._transport.function_call('AHKWindowList', args, engine=self, blocking=blocking)
4✔
651
        return resp
4✔
652

653
    # fmt: off
654
    @overload
4✔
655
    def get_mouse_position(self, coord_mode: Optional[CoordModeRelativeTo] = None, *, blocking: Literal[True]) -> Tuple[int, int]: ...
4✔
656
    @overload
4✔
657
    def get_mouse_position(self, coord_mode: Optional[CoordModeRelativeTo] = None, *, blocking: Literal[False]) -> FutureResult[Tuple[int, int]]: ...
4✔
658
    @overload
4✔
659
    def get_mouse_position(self, coord_mode: Optional[CoordModeRelativeTo] = None) -> Tuple[int, int]: ...
4✔
660
    @overload
4✔
661
    def get_mouse_position(self, coord_mode: Optional[CoordModeRelativeTo] = None, *, blocking: bool = True) -> Union[Tuple[int, int], FutureResult[Tuple[int, int]]]: ...
4✔
662
    # fmt: on
663
    def get_mouse_position(
4✔
664
        self, coord_mode: Optional[CoordModeRelativeTo] = None, *, blocking: bool = True
665
    ) -> Union[Tuple[int, int], FutureResult[Tuple[int, int]]]:
666
        """
667
        Analog for ``MouseGetPos``
668

669
        :param coord_mode:
670
        :param blocking:
671
        :return:
672
        """
673
        if coord_mode:
4✔
674
            args = [str(coord_mode)]
×
675
        else:
676
            args = []
4✔
677
        resp = self._transport.function_call('AHKMouseGetPos', args, blocking=blocking)
4✔
678
        return resp
4✔
679

680
    @property
4✔
681
    def mouse_position(self) -> SyncPropertyReturnTupleIntInt:
4✔
682
        """
683
        Convenience property for ``get_mouse_position``
684

685
        :return:
686
        """
687
        return self.get_mouse_position()
×
688

689
    @mouse_position.setter
4✔
690
    def mouse_position(self, new_position: Tuple[int, int]) -> None:
4✔
691
        """
692
        Convenience setter for ``mouse_move``
693

694
        :param new_position: a tuple of x,y coordinates to move to
695
        :return:
696
        """
697
        x, y = new_position
×
698
        return self.mouse_move(x=x, y=y, speed=0, relative=False)
×
699

700
    # fmt: off
701
    @overload
4✔
702
    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✔
703
    @overload
4✔
704
    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✔
705
    @overload
4✔
706
    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, ) -> FutureResult[None]: ...
4✔
707
    @overload
4✔
708
    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, FutureResult[None]]: ...
4✔
709
    # fmt: on
710
    def mouse_move(
4✔
711
        self,
712
        x: Optional[Union[str, int]] = None,
713
        y: Optional[Union[str, int]] = None,
714
        *,
715
        speed: Optional[int] = None,
716
        relative: bool = False,
717
        blocking: bool = True,
718
    ) -> Union[None, FutureResult[None]]:
719
        """
720
        Analog for ``MouseMove``
721

722
        :param x:
723
        :param y:
724
        :param speed:
725
        :param relative:
726
        :param blocking:
727
        :return:
728
        """
729
        if relative and (x is None or y is None):
4✔
730
            x = x or 0
×
731
            y = y or 0
×
732
        elif not relative and (x is None or y is None):
4✔
733
            posx, posy = self.get_mouse_position()
×
734
            x = x or posx
×
735
            y = y or posy
×
736

737
        if speed is None:
4✔
738
            speed = 2
4✔
739
        args = [str(x), str(y), str(speed)]
4✔
740
        if relative:
4✔
741
            args.append('R')
4✔
742
        resp = self._transport.function_call('AHKMouseMove', args, blocking=blocking)
4✔
743
        return resp
4✔
744

745
    def a_run_script(self, *args: Any, **kwargs: Any) -> Union[str, FutureResult[str]]:
4✔
746
        """
747
        Deprecated. Use ``run_script`` instead.
748
        """
749
        warnings.warn('a_run_script is deprecated. Use run_script instead.', DeprecationWarning, stacklevel=2)
×
750
        return self.run_script(*args, **kwargs)
×
751

752
    # fmt: off
753
    @overload
4✔
754
    def get_active_window(self) -> Optional[Window]: ...
4✔
755
    @overload
4✔
756
    def get_active_window(self, blocking: Literal[True]) -> Optional[Window]: ...
4✔
757
    @overload
4✔
758
    def get_active_window(self, blocking: Literal[False]) -> FutureResult[Optional[Window]]: ...
4✔
759
    @overload
4✔
760
    def get_active_window(self, blocking: bool = True) -> Union[Optional[Window], FutureResult[Optional[Window]]]: ...
4✔
761
    # fmt: on
762
    def get_active_window(
4✔
763
        self, blocking: bool = True
764
    ) -> Union[Optional[Window], FutureResult[Optional[Window]]]:
765
        """
766
        Gets the currently active window.
767

768
        :param blocking:
769
        :return:
770
        """
771
        return self.win_get(
4✔
772
            title='A', detect_hidden_windows=False, title_match_mode=(1, 'Fast'), blocking=blocking
773
        )
774

775
    @property
4✔
776
    def active_window(self) -> SyncPropertyReturnOptionalAsyncWindow:
4✔
777
        """
778
        Gets the currently active window
779

780
        :return:
781
        """
782
        return self.get_active_window()
×
783

784
    def find_windows(
4✔
785
        self,
786
        func: Optional[SyncFilterFunc] = None,
787
        *,
788
        title_match_mode: Optional[TitleMatchMode] = None,
789
        title: str = '',
790
        text: str = '',
791
        exclude_title: str = '',
792
        exclude_text: str = '',
793
        exact: Optional[bool] = None,
794
    ) -> List[Window]:
795
        if exact is not None and title_match_mode is not None:
×
796
            raise TypeError('exact and match_mode parameters are mutually exclusive')
×
797
        if exact is not None:
×
798
            warnings.warn('exact parameter is deprecated. Use match_mode=3 instead', stacklevel=2)
×
799
            if exact:
×
800
                title_match_mode = (3, 'Fast')
×
801
            else:
802
                title_match_mode = (1, 'Fast')
×
803
        elif title_match_mode is None:
×
804
            title_match_mode = (1, 'Fast')
×
805

806
        windows = self.list_windows(
×
807
            title=title,
808
            text=text,
809
            exclude_title=exclude_title,
810
            exclude_text=exclude_text,
811
            title_match_mode=title_match_mode,
812
        )
813
        if func is None:
×
814
            return windows
×
815
        else:
816
            ret: List[Window] = []
×
817
            for win in windows:
×
818
                match = func(win)
×
819
                if match:
×
820
                    ret.append(win)
×
821
            return ret
×
822

823
    def find_windows_by_class(
4✔
824
        self, class_name: str, *, exact: Optional[bool] = None, title_match_mode: Optional[TitleMatchMode] = None
825
    ) -> List[Window]:
826
        with warnings.catch_warnings(record=True) as caught_warnings:
×
827
            ret = self.find_windows(
×
828
                title=f'ahk_class {class_name}', title_match_mode=title_match_mode, exact=exact
829
            )
830
        if caught_warnings:
×
831
            for warning in caught_warnings:
×
832
                warnings.warn(warning.message, warning.category, stacklevel=2)
×
833
        return ret
×
834

835
    def find_windows_by_text(
4✔
836
        self, text: str, exact: Optional[bool] = None, title_match_mode: Optional[TitleMatchMode] = None
837
    ) -> List[Window]:
838
        with warnings.catch_warnings(record=True) as caught_warnings:
×
839
            ret = self.find_windows(text=text, exact=exact, title_match_mode=title_match_mode)
×
840
        if caught_warnings:
×
841
            for warning in caught_warnings:
×
842
                warnings.warn(warning.message, warning.category, stacklevel=2)
×
843
        return ret
×
844

845
    def find_windows_by_title(
4✔
846
        self, title: str, exact: Optional[bool] = None, title_match_mode: Optional[TitleMatchMode] = None
847
    ) -> List[Window]:
848
        with warnings.catch_warnings(record=True) as caught_warnings:
×
849
            ret = self.find_windows(title=title, exact=exact, title_match_mode=title_match_mode)
×
850
        if caught_warnings:
×
851
            for warning in caught_warnings:
×
852
                warnings.warn(warning.message, warning.category, stacklevel=2)
×
853
        return ret
×
854

855
    def find_window(
4✔
856
        self,
857
        func: Optional[SyncFilterFunc] = None,
858
        *,
859
        title_match_mode: Optional[TitleMatchMode] = None,
860
        title: str = '',
861
        text: str = '',
862
        exclude_title: str = '',
863
        exclude_text: str = '',
864
        exact: Optional[bool] = None,
865
    ) -> Optional[Window]:
866
        with warnings.catch_warnings(record=True) as caught_warnings:
×
867
            windows = self.find_windows(
×
868
                func,
869
                title=title,
870
                text=text,
871
                exclude_title=exclude_title,
872
                exclude_text=exclude_text,
873
                exact=exact,
874
                title_match_mode=title_match_mode,
875
            )
876
        if caught_warnings:
×
877
            for warning in caught_warnings:
×
878
                warnings.warn(warning.message, warning.category, stacklevel=2)
×
879
        return windows[0] if windows else None
×
880

881
    def find_window_by_class(
4✔
882
        self, class_name: str, exact: Optional[bool] = None, title_match_mode: Optional[TitleMatchMode] = None
883
    ) -> Optional[Window]:
884
        with warnings.catch_warnings(record=True) as caught_warnings:
×
885
            windows = self.find_windows_by_class(
×
886
                class_name=class_name, exact=exact, title_match_mode=title_match_mode
887
            )
888
        if caught_warnings:
×
889
            for warning in caught_warnings:
×
890
                warnings.warn(warning.message, warning.category, stacklevel=2)
×
891
        return windows[0] if windows else None
×
892

893
    def find_window_by_text(
4✔
894
        self, text: str, exact: Optional[bool] = None, title_match_mode: Optional[TitleMatchMode] = None
895
    ) -> Optional[Window]:
896
        with warnings.catch_warnings(record=True) as caught_warnings:
×
897
            windows = self.find_windows_by_text(text=text, exact=exact, title_match_mode=title_match_mode)
×
898
        if caught_warnings:
×
899
            for warning in caught_warnings:
×
900
                warnings.warn(warning.message, warning.category, stacklevel=2)
×
901
        return windows[0] if windows else None
×
902

903
    def find_window_by_title(
4✔
904
        self, title: str, exact: Optional[bool] = None, title_match_mode: Optional[TitleMatchMode] = None
905
    ) -> Optional[Window]:
906
        with warnings.catch_warnings(record=True) as caught_warnings:
×
907
            windows = self.find_windows_by_title(title=title, exact=exact, title_match_mode=title_match_mode)
×
908
        if caught_warnings:
×
909
            for warning in caught_warnings:
×
910
                warnings.warn(warning.message, warning.category, stacklevel=2)
×
911
        return windows[0] if windows else None
×
912

913
    def get_volume(self, device_number: int = 1) -> float:
4✔
914
        args = [str(device_number)]
×
915
        response = self._transport.function_call('AHKGetVolume', args)
×
916
        return response
×
917

918
    # fmt: off
919
    @overload
4✔
920
    def key_down(self, key: Union[str, Key]) -> None: ...
4✔
921
    @overload
4✔
922
    def key_down(self, key: Union[str, Key], *, blocking: Literal[True]) -> None: ...
4✔
923
    @overload
4✔
924
    def key_down(self, key: Union[str, Key], *, blocking: Literal[False]) -> FutureResult[None]: ...
4✔
925
    @overload
4✔
926
    def key_down(self, key: Union[str, Key], *, blocking: bool = True) -> Union[None, FutureResult[None]]: ...
4✔
927
    # fmt: on
928
    def key_down(self, key: Union[str, Key], *, blocking: bool = True) -> Union[None, FutureResult[None]]:
4✔
929
        if isinstance(key, str):
4✔
930
            key = Key(key_name=key)
4✔
931
        if blocking:
4✔
932
            self.send_input(key.DOWN, blocking=True)
4✔
933
            return None
4✔
934
        else:
935
            return self.send_input(key.DOWN, blocking=False)
×
936

937
    # fmt: off
938
    @overload
4✔
939
    def key_press(self, key: Union[str, Key], *, release: bool = True) -> None: ...
4✔
940
    @overload
4✔
941
    def key_press(self, key: Union[str, Key], *, blocking: Literal[True], release: bool = True) -> None: ...
4✔
942
    @overload
4✔
943
    def key_press(self, key: Union[str, Key], *, blocking: Literal[False], release: bool = True) -> FutureResult[None]: ...
4✔
944
    @overload
4✔
945
    def key_press(self, key: Union[str, Key], *, release: bool = True, blocking: bool = True) -> Union[None, FutureResult[None]]: ...
4✔
946
    # fmt: on
947
    def key_press(
4✔
948
        self, key: Union[str, Key], *, release: bool = True, blocking: bool = True
949
    ) -> Union[None, FutureResult[None]]:
950
        if blocking:
4✔
951
            self.key_down(key, blocking=True)
4✔
952
            if release:
4✔
953
                self.key_up(key, blocking=True)
4✔
954
            return None
4✔
955
        else:
956
            d = self.key_down(key, blocking=False)
×
957
            if release:
×
958
                return self.key_up(key, blocking=False)
×
959
            return d
×
960

961
    # fmt: off
962
    @overload
4✔
963
    def key_release(self, key: Union[str, Key]) -> None: ...
4✔
964
    @overload
4✔
965
    def key_release(self, key: Union[str, Key], *, blocking: Literal[True]) -> None: ...
4✔
966
    @overload
4✔
967
    def key_release(self, key: Union[str, Key], *, blocking: Literal[False]) -> FutureResult[None]: ...
4✔
968
    @overload
4✔
969
    def key_release(self, key: Union[str, Key], *, blocking: bool = True) -> Union[None, FutureResult[None]]: ...
4✔
970
    # fmt: on
971
    def key_release(self, key: Union[str, Key], *, blocking: bool = True) -> Union[None, FutureResult[None]]:
4✔
972
        if blocking:
×
973
            self.key_up(key=key, blocking=True)
×
974
            return None
×
975
        else:
976
            return self.key_up(key=key, blocking=False)
×
977

978
    # fmt: off
979
    @overload
4✔
980
    def key_state(self, key_name: str, *, mode: Optional[Literal['T', 'P']] = None) -> Union[float, int, str, None]: ...
4✔
981
    @overload
4✔
982
    def key_state(self, key_name: str, *, mode: Optional[Literal['T', 'P']] = None, blocking: Literal[True]) -> Union[float, int, str, None]: ...
4✔
983
    @overload
4✔
984
    def key_state(self, key_name: str, *, mode: Optional[Literal['T', 'P']] = None, blocking: Literal[False]) -> Union[FutureResult[str], FutureResult[int], FutureResult[float], FutureResult[None]]: ...
4✔
985
    @overload
4✔
986
    def key_state(self, key_name: str, *, mode: Optional[Literal['T', 'P']] = None, blocking: bool = True) -> Union[None, FutureResult[None], Union[str, FutureResult[str]], Union[int, FutureResult[int]], Union[float, FutureResult[float]]]: ...
4✔
987
    # fmt: on
988
    def key_state(
4✔
989
        self, key_name: str, *, mode: Optional[Literal['T', 'P']] = None, blocking: bool = True
990
    ) -> Union[
991
        int,
992
        float,
993
        str,
994
        None,
995
        FutureResult[str],
996
        FutureResult[int],
997
        FutureResult[float],
998
        FutureResult[None],
999
    ]:
1000
        args: List[str] = [key_name]
4✔
1001
        if mode is not None:
4✔
1002
            if mode not in ('T', 'P'):
4✔
1003
                raise ValueError(f'Invalid value for mode parameter. Mode must be `T` or `P`. Got {mode!r}')
×
1004
            args.append(mode)
4✔
1005
        resp = self._transport.function_call('AHKKeyState', args, blocking=blocking)
4✔
1006
        return resp
4✔
1007

1008
    # fmt: off
1009
    @overload
4✔
1010
    def key_up(self, key: Union[str, Key]) -> None: ...
4✔
1011
    @overload
4✔
1012
    def key_up(self, key: Union[str, Key], *, blocking: Literal[True]) -> None: ...
4✔
1013
    @overload
4✔
1014
    def key_up(self, key: Union[str, Key], *, blocking: Literal[False]) -> FutureResult[None]: ...
4✔
1015
    @overload
4✔
1016
    def key_up(self, key: Union[str, Key], blocking: bool = True) -> Union[None, FutureResult[None]]: ...
4✔
1017
    # fmt: on
1018
    def key_up(self, key: Union[str, Key], blocking: bool = True) -> Union[None, FutureResult[None]]:
4✔
1019
        if isinstance(key, str):
4✔
1020
            key = Key(key_name=key)
4✔
1021
        if blocking:
4✔
1022
            self.send_input(key.UP, blocking=True)
4✔
1023
            return None
4✔
1024
        else:
1025
            return self.send_input(key.UP, blocking=False)
×
1026

1027
    # fmt: off
1028
    @overload
4✔
1029
    def key_wait(self, key_name: str, *, timeout: Optional[int] = None, logical_state: bool = False, released: bool = False) -> int: ...
4✔
1030
    @overload
4✔
1031
    def key_wait(self, key_name: str, *, blocking: Literal[True], timeout: Optional[int] = None, logical_state: bool = False, released: bool = False) -> int: ...
4✔
1032
    @overload
4✔
1033
    def key_wait(self, key_name: str, *, blocking: Literal[False], timeout: Optional[int] = None, logical_state: bool = False, released: bool = False) -> FutureResult[int]: ...
4✔
1034
    @overload
4✔
1035
    def key_wait(self, key_name: str, *, timeout: Optional[int] = None, logical_state: bool = False, released: bool = False, blocking: bool = True) -> Union[int, FutureResult[int]]: ...
4✔
1036
    # fmt: on
1037
    def key_wait(
4✔
1038
        self,
1039
        key_name: str,
1040
        *,
1041
        timeout: Optional[int] = None,
1042
        logical_state: bool = False,
1043
        released: bool = False,
1044
        blocking: bool = True,
1045
    ) -> Union[int, FutureResult[int]]:
1046
        options = ''
×
1047
        if not released:
×
1048
            options += 'D'
×
1049
        if logical_state:
×
1050
            options += 'L'
×
1051
        if timeout:
×
1052
            options += f'T{timeout}'
×
1053
        args = [key_name]
×
1054
        if options:
×
1055
            args.append(options)
×
1056

1057
        resp = self._transport.function_call('AHKKeyWait', args)
×
1058
        return resp
×
1059

1060
    def run_script(
4✔
1061
        self, script_text_or_path: str, /, *, blocking: bool = True, timeout: Optional[int] = None
1062
    ) -> Union[str, FutureResult[str]]:
1063
        return self._transport.run_script(script_text_or_path, blocking=blocking, timeout=timeout)
4✔
1064

1065
    def set_send_level(self, level: int) -> None:
4✔
1066
        if not isinstance(level, int):
4✔
1067
            raise TypeError('level must be an integer between 0 and 100')
×
1068
        if not 0 <= level <= 100:
4✔
1069
            raise ValueError('level value must be between 0 and 100')
×
1070
        args = [str(level)]
4✔
1071
        self._transport.function_call('AHKSetSendLevel', args)
4✔
1072

1073
    def get_send_level(self) -> int:
4✔
1074
        resp = self._transport.function_call('AHKGetSendLevel')
×
1075
        return resp
×
1076

1077
    # fmt: off
1078
    @overload
4✔
1079
    def send(self, s: str, *, raw: bool = False, key_delay: Optional[int] = None, key_press_duration: Optional[int] = None) -> None: ...
4✔
1080
    @overload
4✔
1081
    def send(self, s: str, *, raw: bool = False, key_delay: Optional[int] = None, key_press_duration: Optional[int] = None, blocking: Literal[True]) -> None: ...
4✔
1082
    @overload
4✔
1083
    def send(self, s: str, *, raw: bool = False, key_delay: Optional[int] = None, key_press_duration: Optional[int] = None, blocking: Literal[False]) -> FutureResult[None]: ...
4✔
1084
    @overload
4✔
1085
    def send(self, s: str, *, raw: bool = False, key_delay: Optional[int] = None, key_press_duration: Optional[int] = None, blocking: bool = True) -> Union[None, FutureResult[None]]: ...
4✔
1086
    # fmt: on
1087
    def send(
4✔
1088
        self,
1089
        s: str,
1090
        *,
1091
        raw: bool = False,
1092
        key_delay: Optional[int] = None,
1093
        key_press_duration: Optional[int] = None,
1094
        blocking: bool = True,
1095
    ) -> Union[None, FutureResult[None]]:
1096
        args = [s]
4✔
1097
        if key_delay:
4✔
1098
            args.append(str(key_delay))
×
1099
        else:
1100
            args.append('')
4✔
1101
        if key_press_duration:
4✔
1102
            args.append(str(key_press_duration))
×
1103
        else:
1104
            args.append('')
4✔
1105

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

1113
    # fmt: off
1114
    @overload
4✔
1115
    def send_raw(self, s: str, *, key_delay: Optional[int] = None, key_press_duration: Optional[int] = None) -> None: ...
4✔
1116
    @overload
4✔
1117
    def send_raw(self, s: str, *, key_delay: Optional[int] = None, key_press_duration: Optional[int] = None, blocking: Literal[True]) -> None: ...
4✔
1118
    @overload
4✔
1119
    def send_raw(self, s: str, *, key_delay: Optional[int] = None, key_press_duration: Optional[int] = None, blocking: Literal[False]) -> FutureResult[None]: ...
4✔
1120
    @overload
4✔
1121
    def send_raw(self, s: str, *, key_delay: Optional[int] = None, key_press_duration: Optional[int] = None, blocking: bool = True) -> Union[None, FutureResult[None]]: ...
4✔
1122
    # fmt: on
1123
    def send_raw(
4✔
1124
        self,
1125
        s: str,
1126
        *,
1127
        key_delay: Optional[int] = None,
1128
        key_press_duration: Optional[int] = None,
1129
        blocking: bool = True,
1130
    ) -> Union[None, FutureResult[None]]:
1131
        resp = self.send(
×
1132
            s, raw=True, key_delay=key_delay, key_press_duration=key_press_duration, blocking=blocking
1133
        )
1134
        return resp
×
1135

1136
    # fmt: off
1137
    @overload
4✔
1138
    def send_input(self, s: str) -> None: ...
4✔
1139
    @overload
4✔
1140
    def send_input(self, s: str, *, blocking: Literal[True]) -> None: ...
4✔
1141
    @overload
4✔
1142
    def send_input(self, s: str, *, blocking: Literal[False]) -> FutureResult[None]: ...
4✔
1143
    @overload
4✔
1144
    def send_input(self, s: str, *, blocking: bool = True) -> Union[None, FutureResult[None]]: ...
4✔
1145
    # fmt: on
1146
    def send_input(self, s: str, *, blocking: bool = True) -> Union[None, FutureResult[None]]:
4✔
1147
        args = [s]
4✔
1148
        resp = self._transport.function_call('AHKSendInput', args, blocking=blocking)
4✔
1149
        return resp
4✔
1150

1151
    # fmt: off
1152
    @overload
4✔
1153
    def type(self, s: str) -> None: ...
4✔
1154
    @overload
4✔
1155
    def type(self, s: str, *, blocking: Literal[True]) -> None: ...
4✔
1156
    @overload
4✔
1157
    def type(self, s: str, *, blocking: Literal[False]) -> FutureResult[None]: ...
4✔
1158
    @overload
4✔
1159
    def type(self, s: str, *, blocking: bool = True) -> Union[None, FutureResult[None]]: ...
4✔
1160
    # fmt: on
1161
    def type(self, s: str, *, blocking: bool = True) -> Union[None, FutureResult[None]]:
4✔
1162
        resp = self.send_input(type_escape(s), blocking=blocking)
4✔
1163
        return resp
4✔
1164

1165
    # fmt: off
1166
    @overload
4✔
1167
    def send_play(self, s: str, *, key_delay: Optional[int] = None, key_press_duration: Optional[int] = None) -> None: ...
4✔
1168
    @overload
4✔
1169
    def send_play(self, s: str, *, key_delay: Optional[int] = None, key_press_duration: Optional[int] = None, blocking: Literal[True]) -> None: ...
4✔
1170
    @overload
4✔
1171
    def send_play(self, s: str, *, key_delay: Optional[int] = None, key_press_duration: Optional[int] = None, blocking: Literal[False]) -> FutureResult[None]: ...
4✔
1172
    @overload
4✔
1173
    def send_play(self, s: str, *, key_delay: Optional[int] = None, key_press_duration: Optional[int] = None, blocking: bool = True) -> Union[None, FutureResult[None]]: ...
4✔
1174
    # fmt: on
1175
    def send_play(
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, FutureResult[None]]:
1183
        args = [s]
×
1184
        if key_delay:
×
1185
            args.append(str(key_delay))
×
1186
        else:
1187
            args.append('')
×
1188
        if key_press_duration:
×
1189
            args.append(str(key_press_duration))
×
1190
        else:
1191
            args.append('')
×
1192

1193
        resp = self._transport.function_call('AHKSendPlay', args=args, blocking=blocking)
×
1194
        return resp
×
1195

1196
    # fmt: off
1197
    @overload
4✔
1198
    def set_capslock_state(self, state: Optional[Literal[0, 1, 'On', 'Off', 'AlwaysOn', 'AlwaysOff']] = None) -> None: ...
4✔
1199
    @overload
4✔
1200
    def set_capslock_state(self, state: Optional[Literal[0, 1, 'On', 'Off', 'AlwaysOn', 'AlwaysOff']] = None, *, blocking: Literal[True]) -> None: ...
4✔
1201
    @overload
4✔
1202
    def set_capslock_state(self, state: Optional[Literal[0, 1, 'On', 'Off', 'AlwaysOn', 'AlwaysOff']] = None, *, blocking: Literal[False]) -> FutureResult[None]: ...
4✔
1203
    @overload
4✔
1204
    def set_capslock_state(self, state: Optional[Literal[0, 1, 'On', 'Off', 'AlwaysOn', 'AlwaysOff']] = None, *, blocking: bool = True) -> Union[None, FutureResult[None]]: ...
4✔
1205
    # fmt: on
1206
    def set_capslock_state(
4✔
1207
        self, state: Optional[Literal[0, 1, 'On', 'Off', 'AlwaysOn', 'AlwaysOff']] = None, *, blocking: bool = True
1208
    ) -> Union[None, FutureResult[None]]:
1209
        args: List[str] = []
4✔
1210
        if state is not None:
4✔
1211
            if str(state).lower() not in ('1', '0', 'on', 'off', 'alwayson', 'alwaysoff'):
4✔
1212
                raise ValueError(
×
1213
                    f'Invalid value for state. Must be one of On, Off, AlwaysOn, AlwaysOff or None. Got {state!r}'
1214
                )
1215
            args.append(str(state))
4✔
1216

1217
        resp = self._transport.function_call('AHKSetCapsLockState', args, blocking=blocking)
4✔
1218
        return resp
4✔
1219

1220
    # fmt: off
1221
    @overload
4✔
1222
    def set_volume(self, value: int, device_number: int = 1) -> None: ...
4✔
1223
    @overload
4✔
1224
    def set_volume(self, value: int, device_number: int = 1, *, blocking: Literal[False]) -> FutureResult[None]: ...
4✔
1225
    @overload
4✔
1226
    def set_volume(self, value: int, device_number: int = 1, *, blocking: Literal[True]) -> None: ...
4✔
1227
    @overload
4✔
1228
    def set_volume(self, value: int, device_number: int = 1, *, blocking: bool = True) -> Union[None, FutureResult[None]]: ...
4✔
1229
    # fmt: on
1230
    def set_volume(
4✔
1231
        self, value: int, device_number: int = 1, *, blocking: bool = True
1232
    ) -> Union[None, FutureResult[None]]:
1233
        args = [str(device_number), str(value)]
×
1234
        return self._transport.function_call('AHKSetVolume', args, blocking=blocking)
×
1235

1236
    # fmt: off
1237
    @overload
4✔
1238
    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✔
1239
    @overload
4✔
1240
    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]) -> FutureResult[None]: ...
4✔
1241
    @overload
4✔
1242
    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✔
1243
    @overload
4✔
1244
    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, FutureResult[None]]: ...
4✔
1245
    # fmt: on
1246
    def show_traytip(
4✔
1247
        self,
1248
        title: str,
1249
        text: str,
1250
        second: float = 1.0,
1251
        type_id: int = 1,
1252
        *,
1253
        silent: bool = False,
1254
        large_icon: bool = False,
1255
        blocking: bool = True,
1256
    ) -> Union[None, FutureResult[None]]:
1257
        option = type_id + (16 if silent else 0) + (32 if large_icon else 0)
×
1258
        args = [title, text, str(second), str(option)]
×
1259
        return self._transport.function_call('AHKTrayTip', args, blocking=blocking)
×
1260

1261
    # fmt: off
1262
    @overload
4✔
1263
    def show_error_traytip(self, title: str, text: str, second: float = 1.0, *, silent: bool = False, large_icon: bool = False) -> None: ...
4✔
1264
    @overload
4✔
1265
    def show_error_traytip(self, title: str, text: str, second: float = 1.0, *, silent: bool = False, large_icon: bool = False, blocking: Literal[False]) -> FutureResult[None]: ...
4✔
1266
    @overload
4✔
1267
    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✔
1268
    @overload
4✔
1269
    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, FutureResult[None]]: ...
4✔
1270
    # fmt: on
1271
    def show_error_traytip(
4✔
1272
        self,
1273
        title: str,
1274
        text: str,
1275
        second: float = 1.0,
1276
        *,
1277
        silent: bool = False,
1278
        large_icon: bool = False,
1279
        blocking: bool = True,
1280
    ) -> Union[None, FutureResult[None]]:
1281
        return self.show_traytip(
×
1282
            title=title, text=text, second=second, type_id=3, silent=silent, large_icon=large_icon, blocking=blocking
1283
        )
1284

1285
    # fmt: off
1286
    @overload
4✔
1287
    def show_info_traytip(self, title: str, text: str, second: float = 1.0, *, silent: bool = False, large_icon: bool = False) -> None: ...
4✔
1288
    @overload
4✔
1289
    def show_info_traytip(self, title: str, text: str, second: float = 1.0, *, silent: bool = False, large_icon: bool = False, blocking: Literal[False]) -> FutureResult[None]: ...
4✔
1290
    @overload
4✔
1291
    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✔
1292
    @overload
4✔
1293
    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, FutureResult[None]]: ...
4✔
1294
    # fmt: on
1295
    def show_info_traytip(
4✔
1296
        self,
1297
        title: str,
1298
        text: str,
1299
        second: float = 1.0,
1300
        *,
1301
        silent: bool = False,
1302
        large_icon: bool = False,
1303
        blocking: bool = True,
1304
    ) -> Union[None, FutureResult[None]]:
1305
        return self.show_traytip(
×
1306
            title=title, text=text, second=second, type_id=1, silent=silent, large_icon=large_icon, blocking=blocking
1307
        )
1308

1309
    # fmt: off
1310
    @overload
4✔
1311
    def show_warning_traytip(self, title: str, text: str, second: float = 1.0, *, silent: bool = False, large_icon: bool = False) -> None: ...
4✔
1312
    @overload
4✔
1313
    def show_warning_traytip(self, title: str, text: str, second: float = 1.0, *, silent: bool = False, large_icon: bool = False, blocking: Literal[False]) -> FutureResult[None]: ...
4✔
1314
    @overload
4✔
1315
    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✔
1316
    @overload
4✔
1317
    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, FutureResult[None]]: ...
4✔
1318
    # fmt: on
1319
    def show_warning_traytip(
4✔
1320
        self,
1321
        title: str,
1322
        text: str,
1323
        second: float = 1.0,
1324
        *,
1325
        silent: bool = False,
1326
        large_icon: bool = False,
1327
        blocking: bool = True,
1328
    ) -> Union[None, FutureResult[None]]:
1329
        return self.show_traytip(
×
1330
            title=title, text=text, second=second, type_id=2, silent=silent, large_icon=large_icon, blocking=blocking
1331
        )
1332

1333
    def show_tooltip(
4✔
1334
        self,
1335
        text: str = '',
1336
        x: Optional[int] = None,
1337
        y: Optional[int] = None,
1338
        which: int = 1,
1339
    ) -> None:
1340
        if which not in range(1, 21):
×
1341
            raise ValueError('which must be an integer between 1 and 20')
×
1342
        args = [text]
×
1343
        if x is not None:
×
1344
            args.append(str(x))
×
1345
        else:
1346
            args.append('')
×
1347
        if y is not None:
×
1348
            args.append(str(y))
×
1349
        else:
1350
            args.append('')
×
1351
        self._transport.function_call('AHKShowToolTip', args)
×
1352

1353
    def hide_tooltip(self, which: int = 1) -> None:
4✔
1354
        self.show_tooltip(which=which)
×
1355

1356
    # fmt: off
1357
    @overload
4✔
1358
    def sound_beep(self, frequency: int = 523, duration: int = 150) -> None: ...
4✔
1359
    @overload
4✔
1360
    def sound_beep(self, frequency: int = 523, duration: int = 150, *, blocking: Literal[False]) -> FutureResult[None]: ...
4✔
1361
    @overload
4✔
1362
    def sound_beep(self, frequency: int = 523, duration: int = 150, *, blocking: Literal[True]) -> None: ...
4✔
1363
    @overload
4✔
1364
    def sound_beep(self, frequency: int = 523, duration: int = 150, *, blocking: bool = True) -> Optional[FutureResult[None]]: ...
4✔
1365
    # fmt: on
1366
    def sound_beep(
4✔
1367
        self, frequency: int = 523, duration: int = 150, *, blocking: bool = True
1368
    ) -> Optional[FutureResult[None]]:
1369
        args = [str(frequency), str(duration)]
×
1370
        self._transport.function_call('AHKSoundBeep', args, blocking=blocking)
×
1371
        return None
×
1372

1373
    # fmt: off
1374
    @overload
4✔
1375
    def sound_get(self, device_number: int = 1, component_type: str = 'MASTER', control_type: str = 'VOLUME') -> str: ...
4✔
1376
    @overload
4✔
1377
    def sound_get(self, device_number: int = 1, component_type: str = 'MASTER', control_type: str = 'VOLUME', *, blocking: Literal[False]) -> FutureResult[str]: ...
4✔
1378
    @overload
4✔
1379
    def sound_get(self, device_number: int = 1, component_type: str = 'MASTER', control_type: str = 'VOLUME', *, blocking: Literal[True]) -> str: ...
4✔
1380
    @overload
4✔
1381
    def sound_get(self, device_number: int = 1, component_type: str = 'MASTER', control_type: str = 'VOLUME', *, blocking: bool = True) -> Union[str, FutureResult[str]]: ...
4✔
1382
    # fmt: on
1383
    def sound_get(
4✔
1384
        self,
1385
        device_number: int = 1,
1386
        component_type: str = 'MASTER',
1387
        control_type: str = 'VOLUME',
1388
        *,
1389
        blocking: bool = True,
1390
    ) -> Union[str, FutureResult[str]]:
1391
        args = [str(device_number), component_type, control_type]
×
1392
        return self._transport.function_call('AHKSoundGet', args, blocking=blocking)
×
1393

1394
    # fmt: off
1395
    @overload
4✔
1396
    def sound_play(self, filename: str) -> None: ...
4✔
1397
    @overload
4✔
1398
    def sound_play(self, filename: str, *, blocking: Literal[False]) -> FutureResult[None]: ...
4✔
1399
    @overload
4✔
1400
    def sound_play(self, filename: str, *, blocking: Literal[True]) -> None: ...
4✔
1401
    @overload
4✔
1402
    def sound_play(self, filename: str, *, blocking: bool = True) -> Union[None, FutureResult[None]]: ...
4✔
1403
    # fmt: on
1404
    def sound_play(self, filename: str, *, blocking: bool = True) -> Union[None, FutureResult[None]]:
4✔
1405
        return self._transport.function_call('AHKSoundPlay', [filename], blocking=blocking)
×
1406

1407
    def sound_set(
4✔
1408
        self,
1409
        value: Union[str, int, float],
1410
        device_number: int = 1,
1411
        component_type: str = 'MASTER',
1412
        control_type: str = 'VOLUME',
1413
        *,
1414
        blocking: bool = True,
1415
    ) -> Union[None, FutureResult[None]]:
1416
        args = [str(device_number), component_type, control_type, str(value)]
×
1417
        return self._transport.function_call('AHKSoundSet', args, blocking=blocking)
×
1418

1419
    # fmt: off
1420
    @overload
4✔
1421
    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[Window, None]: ...
4✔
1422
    @overload
4✔
1423
    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]) -> FutureResult[Union[Window, None]]: ...
4✔
1424
    @overload
4✔
1425
    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[Window, None]: ...
4✔
1426
    @overload
4✔
1427
    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[Window, None, FutureResult[Union[None, Window]]]: ...
4✔
1428
    # fmt: on
1429
    def win_get(
4✔
1430
        self,
1431
        title: str = '',
1432
        text: str = '',
1433
        exclude_title: str = '',
1434
        exclude_text: str = '',
1435
        *,
1436
        title_match_mode: Optional[TitleMatchMode] = None,
1437
        detect_hidden_windows: Optional[bool] = None,
1438
        blocking: bool = True,
1439
    ) -> Union[Window, None, FutureResult[Union[None, Window]]]:
1440
        args = self._format_win_args(
4✔
1441
            title=title,
1442
            text=text,
1443
            exclude_title=exclude_title,
1444
            exclude_text=exclude_text,
1445
            title_match_mode=title_match_mode,
1446
            detect_hidden_windows=detect_hidden_windows,
1447
        )
1448
        resp = self._transport.function_call('AHKWinGetID', args, blocking=blocking, engine=self)
4✔
1449
        return resp
4✔
1450

1451
    # fmt: off
1452
    @overload
4✔
1453
    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✔
1454
    @overload
4✔
1455
    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]) -> FutureResult[str]: ...
4✔
1456
    @overload
4✔
1457
    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✔
1458
    @overload
4✔
1459
    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, FutureResult[str]]: ...
4✔
1460
    # fmt: on
1461
    def win_get_text(
4✔
1462
        self,
1463
        title: str = '',
1464
        text: str = '',
1465
        exclude_title: str = '',
1466
        exclude_text: str = '',
1467
        *,
1468
        title_match_mode: Optional[TitleMatchMode] = None,
1469
        detect_hidden_windows: Optional[bool] = None,
1470
        blocking: bool = True,
1471
    ) -> Union[str, FutureResult[str]]:
1472
        args = self._format_win_args(
4✔
1473
            title=title,
1474
            text=text,
1475
            exclude_title=exclude_title,
1476
            exclude_text=exclude_text,
1477
            title_match_mode=title_match_mode,
1478
            detect_hidden_windows=detect_hidden_windows,
1479
        )
1480
        resp = self._transport.function_call('AHKWinGetText', args, blocking=blocking)
4✔
1481
        return resp
4✔
1482

1483
    # fmt: off
1484
    @overload
4✔
1485
    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✔
1486
    @overload
4✔
1487
    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]) -> FutureResult[str]: ...
4✔
1488
    @overload
4✔
1489
    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✔
1490
    @overload
4✔
1491
    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, FutureResult[str]]: ...
4✔
1492
    # fmt: on
1493
    def win_get_title(
4✔
1494
        self,
1495
        title: str = '',
1496
        text: str = '',
1497
        exclude_title: str = '',
1498
        exclude_text: str = '',
1499
        *,
1500
        title_match_mode: Optional[TitleMatchMode] = None,
1501
        detect_hidden_windows: Optional[bool] = None,
1502
        blocking: bool = True,
1503
    ) -> Union[str, FutureResult[str]]:
1504
        args = self._format_win_args(
4✔
1505
            title=title,
1506
            text=text,
1507
            exclude_title=exclude_title,
1508
            exclude_text=exclude_text,
1509
            title_match_mode=title_match_mode,
1510
            detect_hidden_windows=detect_hidden_windows,
1511
        )
1512
        resp = self._transport.function_call('AHKWinGetTitle', args, blocking=blocking)
4✔
1513
        return resp
4✔
1514

1515
    # fmt: off
1516
    @overload
4✔
1517
    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✔
1518
    @overload
4✔
1519
    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]) -> FutureResult[str]: ...
4✔
1520
    @overload
4✔
1521
    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✔
1522
    @overload
4✔
1523
    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, FutureResult[str]]: ...
4✔
1524
    # fmt: on
1525
    def win_get_class(
4✔
1526
        self,
1527
        title: str = '',
1528
        text: str = '',
1529
        exclude_title: str = '',
1530
        exclude_text: str = '',
1531
        *,
1532
        title_match_mode: Optional[TitleMatchMode] = None,
1533
        detect_hidden_windows: Optional[bool] = None,
1534
        blocking: bool = True,
1535
    ) -> Union[str, FutureResult[str]]:
1536
        args = self._format_win_args(
4✔
1537
            title=title,
1538
            text=text,
1539
            exclude_title=exclude_title,
1540
            exclude_text=exclude_text,
1541
            title_match_mode=title_match_mode,
1542
            detect_hidden_windows=detect_hidden_windows,
1543
        )
1544
        resp = self._transport.function_call('AHKWinGetClass', args, blocking=blocking)
4✔
1545
        return resp
4✔
1546

1547
    # fmt: off
1548
    @overload
4✔
1549
    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✔
1550
    @overload
4✔
1551
    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]) -> FutureResult[Union[Position, None]]: ...
4✔
1552
    @overload
4✔
1553
    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✔
1554
    @overload
4✔
1555
    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, FutureResult[Union[Position, None]]]: ...
4✔
1556
    # fmt: on
1557
    def win_get_position(
4✔
1558
        self,
1559
        title: str = '',
1560
        text: str = '',
1561
        exclude_title: str = '',
1562
        exclude_text: str = '',
1563
        *,
1564
        title_match_mode: Optional[TitleMatchMode] = None,
1565
        detect_hidden_windows: Optional[bool] = None,
1566
        blocking: bool = True,
1567
    ) -> Union[Position, None, FutureResult[Union[Position, None]]]:
1568
        args = self._format_win_args(
4✔
1569
            title=title,
1570
            text=text,
1571
            exclude_title=exclude_title,
1572
            exclude_text=exclude_text,
1573
            title_match_mode=title_match_mode,
1574
            detect_hidden_windows=detect_hidden_windows,
1575
        )
1576
        resp = self._transport.function_call('AHKWinGetPos', args, blocking=blocking, engine=self)
4✔
1577
        return resp
4✔
1578

1579
    # fmt: off
1580
    @overload
4✔
1581
    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[Window, None]: ...
4✔
1582
    @overload
4✔
1583
    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]) -> FutureResult[Union[Window, None]]: ...
4✔
1584
    @overload
4✔
1585
    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[Window, None]: ...
4✔
1586
    @overload
4✔
1587
    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[Window, None, FutureResult[Union[Window, None]]]: ...
4✔
1588
    # fmt: on
1589
    def win_get_idlast(
4✔
1590
        self,
1591
        title: str = '',
1592
        text: str = '',
1593
        exclude_title: str = '',
1594
        exclude_text: str = '',
1595
        *,
1596
        title_match_mode: Optional[TitleMatchMode] = None,
1597
        detect_hidden_windows: Optional[bool] = None,
1598
        blocking: bool = True,
1599
    ) -> Union[Window, None, FutureResult[Union[Window, None]]]:
1600
        args = self._format_win_args(
4✔
1601
            title=title,
1602
            text=text,
1603
            exclude_title=exclude_title,
1604
            exclude_text=exclude_text,
1605
            title_match_mode=title_match_mode,
1606
            detect_hidden_windows=detect_hidden_windows,
1607
        )
1608
        resp = self._transport.function_call('AHKWinGetIDLast', args, blocking=blocking, engine=self)
4✔
1609
        return resp
4✔
1610

1611
    # fmt: off
1612
    @overload
4✔
1613
    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✔
1614
    @overload
4✔
1615
    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]) -> FutureResult[Union[int, None]]: ...
4✔
1616
    @overload
4✔
1617
    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✔
1618
    @overload
4✔
1619
    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, FutureResult[Union[int, None]]]: ...
4✔
1620
    # fmt: on
1621
    def win_get_pid(
4✔
1622
        self,
1623
        title: str = '',
1624
        text: str = '',
1625
        exclude_title: str = '',
1626
        exclude_text: str = '',
1627
        *,
1628
        title_match_mode: Optional[TitleMatchMode] = None,
1629
        detect_hidden_windows: Optional[bool] = None,
1630
        blocking: bool = True,
1631
    ) -> Union[int, None, FutureResult[Union[int, None]]]:
1632
        args = self._format_win_args(
4✔
1633
            title=title,
1634
            text=text,
1635
            exclude_title=exclude_title,
1636
            exclude_text=exclude_text,
1637
            title_match_mode=title_match_mode,
1638
            detect_hidden_windows=detect_hidden_windows,
1639
        )
1640
        resp = self._transport.function_call('AHKWinGetPID', args, blocking=blocking)
4✔
1641
        return resp
4✔
1642

1643
    # fmt: off
1644
    @overload
4✔
1645
    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✔
1646
    @overload
4✔
1647
    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]) -> FutureResult[Union[str, None]]: ...
4✔
1648
    @overload
4✔
1649
    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✔
1650
    @overload
4✔
1651
    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, FutureResult[Optional[str]]]: ...
4✔
1652
    # fmt: on
1653
    def win_get_process_name(
4✔
1654
        self,
1655
        title: str = '',
1656
        text: str = '',
1657
        exclude_title: str = '',
1658
        exclude_text: str = '',
1659
        *,
1660
        title_match_mode: Optional[TitleMatchMode] = None,
1661
        detect_hidden_windows: Optional[bool] = None,
1662
        blocking: bool = True,
1663
    ) -> Union[None, str, FutureResult[Optional[str]]]:
1664
        args = self._format_win_args(
4✔
1665
            title=title,
1666
            text=text,
1667
            exclude_title=exclude_title,
1668
            exclude_text=exclude_text,
1669
            title_match_mode=title_match_mode,
1670
            detect_hidden_windows=detect_hidden_windows,
1671
        )
1672
        resp = self._transport.function_call('AHKWinGetProcessName', args, blocking=blocking)
4✔
1673
        return resp
4✔
1674

1675
    # fmt: off
1676
    @overload
4✔
1677
    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✔
1678
    @overload
4✔
1679
    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]) -> FutureResult[Union[str, None]]: ...
4✔
1680
    @overload
4✔
1681
    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✔
1682
    @overload
4✔
1683
    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, FutureResult[Optional[str]]]]: ...
4✔
1684
    # fmt: on
1685
    def win_get_process_path(
4✔
1686
        self,
1687
        title: str = '',
1688
        text: str = '',
1689
        exclude_title: str = '',
1690
        exclude_text: str = '',
1691
        *,
1692
        title_match_mode: Optional[TitleMatchMode] = None,
1693
        detect_hidden_windows: Optional[bool] = None,
1694
        blocking: bool = True,
1695
    ) -> Union[str, None, Union[None, str, FutureResult[Optional[str]]]]:
1696
        args = self._format_win_args(
4✔
1697
            title=title,
1698
            text=text,
1699
            exclude_title=exclude_title,
1700
            exclude_text=exclude_text,
1701
            title_match_mode=title_match_mode,
1702
            detect_hidden_windows=detect_hidden_windows,
1703
        )
1704
        resp = self._transport.function_call('AHKWinGetProcessPath', args, blocking=blocking)
4✔
1705
        return resp
4✔
1706

1707
    # fmt: off
1708
    @overload
4✔
1709
    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✔
1710
    @overload
4✔
1711
    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]) -> FutureResult[int]: ...
4✔
1712
    @overload
4✔
1713
    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✔
1714
    @overload
4✔
1715
    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, FutureResult[int]]: ...
4✔
1716
    # fmt: on
1717
    def win_get_count(
4✔
1718
        self,
1719
        title: str = '',
1720
        text: str = '',
1721
        exclude_title: str = '',
1722
        exclude_text: str = '',
1723
        *,
1724
        title_match_mode: Optional[TitleMatchMode] = None,
1725
        detect_hidden_windows: Optional[bool] = None,
1726
        blocking: bool = True,
1727
    ) -> Union[int, FutureResult[int]]:
1728
        args = self._format_win_args(
4✔
1729
            title=title,
1730
            text=text,
1731
            exclude_title=exclude_title,
1732
            exclude_text=exclude_text,
1733
            title_match_mode=title_match_mode,
1734
            detect_hidden_windows=detect_hidden_windows,
1735
        )
1736
        resp = self._transport.function_call('AHKWinGetCount', args, blocking=blocking)
4✔
1737
        return resp
4✔
1738

1739
    # fmt: off
1740
    @overload
4✔
1741
    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✔
1742
    @overload
4✔
1743
    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]) -> FutureResult[Union[int, None]]: ...
4✔
1744
    @overload
4✔
1745
    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✔
1746
    @overload
4✔
1747
    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, FutureResult[Optional[int]]]: ...
4✔
1748
    # fmt: on
1749
    def win_get_minmax(
4✔
1750
        self,
1751
        title: str = '',
1752
        text: str = '',
1753
        exclude_title: str = '',
1754
        exclude_text: str = '',
1755
        *,
1756
        title_match_mode: Optional[TitleMatchMode] = None,
1757
        detect_hidden_windows: Optional[bool] = None,
1758
        blocking: bool = True,
1759
    ) -> Union[None, int, FutureResult[Optional[int]]]:
1760
        args = self._format_win_args(
4✔
1761
            title=title,
1762
            text=text,
1763
            exclude_title=exclude_title,
1764
            exclude_text=exclude_text,
1765
            title_match_mode=title_match_mode,
1766
            detect_hidden_windows=detect_hidden_windows,
1767
        )
1768
        resp = self._transport.function_call('AHKWinGetMinMax', args, blocking=blocking)
4✔
1769
        return resp
4✔
1770

1771
    # fmt: off
1772
    @overload
4✔
1773
    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[Control], None]: ...
4✔
1774
    @overload
4✔
1775
    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]) -> FutureResult[Union[List[Control], None]]: ...
4✔
1776
    @overload
4✔
1777
    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[Control], None]: ...
4✔
1778
    @overload
4✔
1779
    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[Control], None, FutureResult[Optional[List[Control]]]]: ...
4✔
1780
    # fmt: on
1781
    def win_get_control_list(
4✔
1782
        self,
1783
        title: str = '',
1784
        text: str = '',
1785
        exclude_title: str = '',
1786
        exclude_text: str = '',
1787
        *,
1788
        title_match_mode: Optional[TitleMatchMode] = None,
1789
        detect_hidden_windows: Optional[bool] = None,
1790
        blocking: bool = True,
1791
    ) -> Union[List[Control], None, FutureResult[Optional[List[Control]]]]:
1792
        args = self._format_win_args(
4✔
1793
            title=title,
1794
            text=text,
1795
            exclude_title=exclude_title,
1796
            exclude_text=exclude_text,
1797
            title_match_mode=title_match_mode,
1798
            detect_hidden_windows=detect_hidden_windows,
1799
        )
1800
        resp = self._transport.function_call('AHKWinGetControlList', args, blocking=blocking, engine=self)
4✔
1801
        return resp
4✔
1802

1803
    # fmt: off
1804
    @overload
4✔
1805
    def win_get_from_mouse_position(self) -> Union[Window, None]: ...
4✔
1806
    @overload
4✔
1807
    def win_get_from_mouse_position(self, *, blocking: Literal[False]) -> FutureResult[Union[Window, None]]: ...
4✔
1808
    @overload
4✔
1809
    def win_get_from_mouse_position(self, *, blocking: Literal[True]) -> Union[Window, None]: ...
4✔
1810
    @overload
4✔
1811
    def win_get_from_mouse_position(self, *, blocking: bool = True) -> Union[Optional[Window], FutureResult[Optional[Window]]]: ...
4✔
1812
    # fmt: on
1813
    def win_get_from_mouse_position(
4✔
1814
        self, *, blocking: bool = True
1815
    ) -> Union[Optional[Window], FutureResult[Optional[Window]]]:
1816
        resp = self._transport.function_call('AHKWinFromMouse', blocking=blocking, engine=self)
×
1817
        return resp
×
1818

1819
    # fmt: off
1820
    @overload
4✔
1821
    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✔
1822
    @overload
4✔
1823
    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]) -> FutureResult[bool]: ...
4✔
1824
    @overload
4✔
1825
    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✔
1826
    @overload
4✔
1827
    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, FutureResult[bool]]: ...
4✔
1828
    # fmt: on
1829
    def win_exists(
4✔
1830
        self,
1831
        title: str = '',
1832
        text: str = '',
1833
        exclude_title: str = '',
1834
        exclude_text: str = '',
1835
        *,
1836
        title_match_mode: Optional[TitleMatchMode] = None,
1837
        detect_hidden_windows: Optional[bool] = None,
1838
        blocking: bool = True,
1839
    ) -> Union[bool, FutureResult[bool]]:
1840
        args = self._format_win_args(
4✔
1841
            title=title,
1842
            text=text,
1843
            exclude_title=exclude_title,
1844
            exclude_text=exclude_text,
1845
            title_match_mode=title_match_mode,
1846
            detect_hidden_windows=detect_hidden_windows,
1847
        )
1848
        resp = self._transport.function_call('AHKWinExist', args, blocking=blocking)
4✔
1849
        return resp
4✔
1850

1851
    # fmt: off
1852
    @overload
4✔
1853
    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✔
1854
    @overload
4✔
1855
    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]) -> FutureResult[None]: ...
4✔
1856
    @overload
4✔
1857
    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✔
1858
    @overload
4✔
1859
    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, FutureResult[None]]: ...
4✔
1860
    # fmt: on
1861
    def win_activate(
4✔
1862
        self,
1863
        title: str = '',
1864
        text: str = '',
1865
        exclude_title: str = '',
1866
        exclude_text: str = '',
1867
        *,
1868
        title_match_mode: Optional[TitleMatchMode] = None,
1869
        detect_hidden_windows: Optional[bool] = None,
1870
        blocking: bool = True,
1871
    ) -> Union[None, FutureResult[None]]:
1872
        args = self._format_win_args(
4✔
1873
            title=title,
1874
            text=text,
1875
            exclude_title=exclude_title,
1876
            exclude_text=exclude_text,
1877
            title_match_mode=title_match_mode,
1878
            detect_hidden_windows=detect_hidden_windows,
1879
        )
1880
        resp = self._transport.function_call('AHKWinActivate', args, blocking=blocking)
4✔
1881
        return resp
4✔
1882

1883
    # fmt: off
1884
    @overload
4✔
1885
    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✔
1886
    @overload
4✔
1887
    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✔
1888
    @overload
4✔
1889
    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]) -> FutureResult[None]: ...
4✔
1890
    @overload
4✔
1891
    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, FutureResult[None]]: ...
4✔
1892
    # fmt: on
1893
    def win_set_title(
4✔
1894
        self,
1895
        new_title: str,
1896
        title: str = '',
1897
        text: str = '',
1898
        exclude_title: str = '',
1899
        exclude_text: str = '',
1900
        *,
1901
        title_match_mode: Optional[TitleMatchMode] = None,
1902
        detect_hidden_windows: Optional[bool] = None,
1903
        blocking: bool = True,
1904
    ) -> Union[None, FutureResult[None]]:
1905
        args = [new_title, title, text, exclude_title, exclude_text]
4✔
1906
        if detect_hidden_windows is not None:
4✔
1907
            if detect_hidden_windows is True:
4✔
1908
                args.append('On')
4✔
1909
            elif detect_hidden_windows is False:
×
1910
                args.append('Off')
×
1911
            else:
1912
                raise TypeError(
×
1913
                    f'Invalid value for parameter detect_hidden_windows. Expected boolean or None, got {detect_hidden_windows!r}'
1914
                )
1915
        else:
1916
            args.append('')
×
1917
        if title_match_mode is not None:
4✔
1918
            if isinstance(title_match_mode, tuple):
4✔
1919
                match_mode, match_speed = title_match_mode
4✔
1920
            elif title_match_mode in (1, 2, 3, 'RegEx'):
×
1921
                match_mode = title_match_mode
×
1922
                match_speed = ''
×
1923
            elif title_match_mode in ('Fast', 'Slow'):
×
1924
                match_mode = ''
×
1925
                match_speed = title_match_mode
×
1926
            else:
1927
                raise ValueError(
×
1928
                    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}"
1929
                )
1930
            args.append(str(match_mode))
4✔
1931
            args.append(str(match_speed))
4✔
1932
        else:
1933
            args.append('')
×
1934
            args.append('')
×
1935
        resp = self._transport.function_call('AHKWinSetTitle', args, blocking=blocking)
4✔
1936
        return resp
4✔
1937

1938
    # fmt: off
1939
    @overload
4✔
1940
    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✔
1941
    @overload
4✔
1942
    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]) -> FutureResult[None]: ...
4✔
1943
    @overload
4✔
1944
    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✔
1945
    @overload
4✔
1946
    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, FutureResult[None]]: ...
4✔
1947
    # fmt: on
1948
    def win_set_always_on_top(
4✔
1949
        self,
1950
        toggle: Literal['On', 'Off', 'Toggle', 1, -1, 0],
1951
        title: str = '',
1952
        text: str = '',
1953
        exclude_title: str = '',
1954
        exclude_text: str = '',
1955
        *,
1956
        title_match_mode: Optional[TitleMatchMode] = None,
1957
        detect_hidden_windows: Optional[bool] = None,
1958
        blocking: bool = True,
1959
    ) -> Union[None, FutureResult[None]]:
1960
        args = [str(toggle), title, text, exclude_title, exclude_text]
4✔
1961
        if detect_hidden_windows is not None:
4✔
1962
            if detect_hidden_windows is True:
4✔
1963
                args.append('On')
4✔
1964
            elif detect_hidden_windows is False:
×
1965
                args.append('Off')
×
1966
            else:
1967
                raise TypeError(
×
1968
                    f'Invalid value for parameter detect_hidden_windows. Expected boolean or None, got {detect_hidden_windows!r}'
1969
                )
1970
        else:
1971
            args.append('')
×
1972
        if title_match_mode is not None:
4✔
1973
            if isinstance(title_match_mode, tuple):
4✔
1974
                match_mode, match_speed = title_match_mode
4✔
1975
            elif title_match_mode in (1, 2, 3, 'RegEx'):
×
1976
                match_mode = title_match_mode
×
1977
                match_speed = ''
×
1978
            elif title_match_mode in ('Fast', 'Slow'):
×
1979
                match_mode = ''
×
1980
                match_speed = title_match_mode
×
1981
            else:
1982
                raise ValueError(
×
1983
                    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}"
1984
                )
1985
            args.append(str(match_mode))
4✔
1986
            args.append(str(match_speed))
4✔
1987
        else:
1988
            args.append('')
×
1989
            args.append('')
×
1990
        resp = self._transport.function_call('AHKWinSetAlwaysOnTop', args, blocking=blocking)
4✔
1991
        return resp
4✔
1992

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

2025
    # fmt: off
2026
    @overload
4✔
2027
    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✔
2028
    @overload
4✔
2029
    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]) -> FutureResult[None]: ...
4✔
2030
    @overload
4✔
2031
    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✔
2032
    @overload
4✔
2033
    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, FutureResult[None]]: ...
4✔
2034
    # fmt: on
2035
    def win_set_top(
4✔
2036
        self,
2037
        title: str = '',
2038
        text: str = '',
2039
        exclude_title: str = '',
2040
        exclude_text: str = '',
2041
        *,
2042
        title_match_mode: Optional[TitleMatchMode] = None,
2043
        detect_hidden_windows: Optional[bool] = None,
2044
        blocking: bool = True,
2045
    ) -> Union[None, FutureResult[None]]:
2046
        args = self._format_win_args(
×
2047
            title=title,
2048
            text=text,
2049
            exclude_title=exclude_title,
2050
            exclude_text=exclude_text,
2051
            title_match_mode=title_match_mode,
2052
            detect_hidden_windows=detect_hidden_windows,
2053
        )
2054
        resp = self._transport.function_call('AHKWinSetTop', args, blocking=blocking)
×
2055
        return resp
×
2056

2057
    # fmt: off
2058
    @overload
4✔
2059
    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✔
2060
    @overload
4✔
2061
    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]) -> FutureResult[None]: ...
4✔
2062
    @overload
4✔
2063
    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✔
2064
    @overload
4✔
2065
    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, FutureResult[None]]: ...
4✔
2066
    # fmt: on
2067
    def win_set_disable(
4✔
2068
        self,
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, FutureResult[None]]:
2078
        args = self._format_win_args(
×
2079
            title=title,
2080
            text=text,
2081
            exclude_title=exclude_title,
2082
            exclude_text=exclude_text,
2083
            title_match_mode=title_match_mode,
2084
            detect_hidden_windows=detect_hidden_windows,
2085
        )
2086
        resp = self._transport.function_call('AHKWinSetDisable', args, blocking=blocking)
×
2087
        return resp
×
2088

2089
    # fmt: off
2090
    @overload
4✔
2091
    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✔
2092
    @overload
4✔
2093
    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]) -> FutureResult[None]: ...
4✔
2094
    @overload
4✔
2095
    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✔
2096
    @overload
4✔
2097
    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, FutureResult[None]]: ...
4✔
2098
    # fmt: on
2099
    def win_set_enable(
4✔
2100
        self,
2101
        title: str = '',
2102
        text: str = '',
2103
        exclude_title: str = '',
2104
        exclude_text: str = '',
2105
        *,
2106
        title_match_mode: Optional[TitleMatchMode] = None,
2107
        detect_hidden_windows: Optional[bool] = None,
2108
        blocking: bool = True,
2109
    ) -> Union[None, FutureResult[None]]:
2110
        args = self._format_win_args(
×
2111
            title=title,
2112
            text=text,
2113
            exclude_title=exclude_title,
2114
            exclude_text=exclude_text,
2115
            title_match_mode=title_match_mode,
2116
            detect_hidden_windows=detect_hidden_windows,
2117
        )
2118
        resp = self._transport.function_call('AHKWinSetEnable', args, blocking=blocking)
×
2119
        return resp
×
2120

2121
    # fmt: off
2122
    @overload
4✔
2123
    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✔
2124
    @overload
4✔
2125
    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]) -> FutureResult[None]: ...
4✔
2126
    @overload
4✔
2127
    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✔
2128
    @overload
4✔
2129
    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, FutureResult[None]]: ...
4✔
2130
    # fmt: on
2131
    def win_set_redraw(
4✔
2132
        self,
2133
        title: str = '',
2134
        text: str = '',
2135
        exclude_title: str = '',
2136
        exclude_text: str = '',
2137
        *,
2138
        title_match_mode: Optional[TitleMatchMode] = None,
2139
        detect_hidden_windows: Optional[bool] = None,
2140
        blocking: bool = True,
2141
    ) -> Union[None, FutureResult[None]]:
2142
        args = self._format_win_args(
×
2143
            title=title,
2144
            text=text,
2145
            exclude_title=exclude_title,
2146
            exclude_text=exclude_text,
2147
            title_match_mode=title_match_mode,
2148
            detect_hidden_windows=detect_hidden_windows,
2149
        )
2150
        resp = self._transport.function_call('AHKWinSetRedraw', args, blocking=blocking)
×
2151
        return resp
×
2152

2153
    # fmt: off
2154
    @overload
4✔
2155
    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✔
2156
    @overload
4✔
2157
    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]) -> FutureResult[bool]: ...
4✔
2158
    @overload
4✔
2159
    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✔
2160
    @overload
4✔
2161
    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, FutureResult[bool]]: ...
4✔
2162
    # fmt: on
2163
    def win_set_style(
4✔
2164
        self,
2165
        style: str,
2166
        title: str = '',
2167
        text: str = '',
2168
        exclude_title: str = '',
2169
        exclude_text: str = '',
2170
        *,
2171
        title_match_mode: Optional[TitleMatchMode] = None,
2172
        detect_hidden_windows: Optional[bool] = None,
2173
        blocking: bool = True,
2174
    ) -> Union[bool, FutureResult[bool]]:
2175
        args = [style, title, text, exclude_title, exclude_text]
×
2176
        if detect_hidden_windows is not None:
×
2177
            if detect_hidden_windows is True:
×
2178
                args.append('On')
×
2179
            elif detect_hidden_windows is False:
×
2180
                args.append('Off')
×
2181
            else:
2182
                raise TypeError(
×
2183
                    f'Invalid value for parameter detect_hidden_windows. Expected boolean or None, got {detect_hidden_windows!r}'
2184
                )
2185
        else:
2186
            args.append('')
×
2187
        if title_match_mode is not None:
×
2188
            if isinstance(title_match_mode, tuple):
×
2189
                match_mode, match_speed = title_match_mode
×
2190
            elif title_match_mode in (1, 2, 3, 'RegEx'):
×
2191
                match_mode = title_match_mode
×
2192
                match_speed = ''
×
2193
            elif title_match_mode in ('Fast', 'Slow'):
×
2194
                match_mode = ''
×
2195
                match_speed = title_match_mode
×
2196
            else:
2197
                raise ValueError(
×
2198
                    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}"
2199
                )
2200
            args.append(str(match_mode))
×
2201
            args.append(str(match_speed))
×
2202
        else:
2203
            args.append('')
×
2204
            args.append('')
×
2205
        resp = self._transport.function_call('AHKWinSetStyle', args, blocking=blocking)
×
2206
        return resp
×
2207

2208
    # fmt: off
2209
    @overload
4✔
2210
    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✔
2211
    @overload
4✔
2212
    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]) -> FutureResult[bool]: ...
4✔
2213
    @overload
4✔
2214
    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✔
2215
    @overload
4✔
2216
    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, FutureResult[bool]]: ...
4✔
2217
    # fmt: on
2218
    def win_set_ex_style(
4✔
2219
        self,
2220
        style: str,
2221
        title: str = '',
2222
        text: str = '',
2223
        exclude_title: str = '',
2224
        exclude_text: str = '',
2225
        *,
2226
        title_match_mode: Optional[TitleMatchMode] = None,
2227
        detect_hidden_windows: Optional[bool] = None,
2228
        blocking: bool = True,
2229
    ) -> Union[bool, FutureResult[bool]]:
2230
        args = [style, title, text, exclude_title, exclude_text]
×
2231
        if detect_hidden_windows is not None:
×
2232
            if detect_hidden_windows is True:
×
2233
                args.append('On')
×
2234
            elif detect_hidden_windows is False:
×
2235
                args.append('Off')
×
2236
            else:
2237
                raise TypeError(
×
2238
                    f'Invalid value for parameter detect_hidden_windows. Expected boolean or None, got {detect_hidden_windows!r}'
2239
                )
2240
        else:
2241
            args.append('')
×
2242
        if title_match_mode is not None:
×
2243
            if isinstance(title_match_mode, tuple):
×
2244
                match_mode, match_speed = title_match_mode
×
2245
            elif title_match_mode in (1, 2, 3, 'RegEx'):
×
2246
                match_mode = title_match_mode
×
2247
                match_speed = ''
×
2248
            elif title_match_mode in ('Fast', 'Slow'):
×
2249
                match_mode = ''
×
2250
                match_speed = title_match_mode
×
2251
            else:
2252
                raise ValueError(
×
2253
                    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}"
2254
                )
2255
            args.append(str(match_mode))
×
2256
            args.append(str(match_speed))
×
2257
        else:
2258
            args.append('')
×
2259
            args.append('')
×
2260
        resp = self._transport.function_call('AHKWinSetExStyle', args, blocking=blocking)
×
2261
        return resp
×
2262

2263
    # fmt: off
2264
    @overload
4✔
2265
    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✔
2266
    @overload
4✔
2267
    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]) -> FutureResult[bool]: ...
4✔
2268
    @overload
4✔
2269
    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✔
2270
    @overload
4✔
2271
    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, FutureResult[bool]]: ...
4✔
2272
    # fmt: on
2273
    def win_set_region(
4✔
2274
        self,
2275
        options: str,
2276
        title: str = '',
2277
        text: str = '',
2278
        exclude_title: str = '',
2279
        exclude_text: str = '',
2280
        *,
2281
        title_match_mode: Optional[TitleMatchMode] = None,
2282
        detect_hidden_windows: Optional[bool] = None,
2283
        blocking: bool = True,
2284
    ) -> Union[bool, FutureResult[bool]]:
2285
        args = [options, title, text, exclude_title, exclude_text]
×
2286
        if detect_hidden_windows is not None:
×
2287
            if detect_hidden_windows is True:
×
2288
                args.append('On')
×
2289
            elif detect_hidden_windows is False:
×
2290
                args.append('Off')
×
2291
            else:
2292
                raise TypeError(
×
2293
                    f'Invalid value for parameter detect_hidden_windows. Expected boolean or None, got {detect_hidden_windows!r}'
2294
                )
2295
        else:
2296
            args.append('')
×
2297
        if title_match_mode is not None:
×
2298
            if isinstance(title_match_mode, tuple):
×
2299
                match_mode, match_speed = title_match_mode
×
2300
            elif title_match_mode in (1, 2, 3, 'RegEx'):
×
2301
                match_mode = title_match_mode
×
2302
                match_speed = ''
×
2303
            elif title_match_mode in ('Fast', 'Slow'):
×
2304
                match_mode = ''
×
2305
                match_speed = title_match_mode
×
2306
            else:
2307
                raise ValueError(
×
2308
                    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}"
2309
                )
2310
            args.append(str(match_mode))
×
2311
            args.append(str(match_speed))
×
2312
        else:
2313
            args.append('')
×
2314
            args.append('')
×
2315
        resp = self._transport.function_call('AHKWinSetRegion', args, blocking=blocking)
×
2316
        return resp
×
2317

2318
    # fmt: off
2319
    @overload
4✔
2320
    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✔
2321
    @overload
4✔
2322
    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]) -> FutureResult[None]: ...
4✔
2323
    @overload
4✔
2324
    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✔
2325
    @overload
4✔
2326
    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, FutureResult[None]]: ...
4✔
2327
    # fmt: on
2328
    def win_set_transparent(
4✔
2329
        self,
2330
        transparency: Union[int, Literal['Off']],
2331
        title: str = '',
2332
        text: str = '',
2333
        exclude_title: str = '',
2334
        exclude_text: str = '',
2335
        *,
2336
        title_match_mode: Optional[TitleMatchMode] = None,
2337
        detect_hidden_windows: Optional[bool] = None,
2338
        blocking: bool = True,
2339
    ) -> Union[None, FutureResult[None]]:
2340
        args = [str(transparency), title, text, exclude_title, exclude_text]
×
2341
        if detect_hidden_windows is not None:
×
2342
            if detect_hidden_windows is True:
×
2343
                args.append('On')
×
2344
            elif detect_hidden_windows is False:
×
2345
                args.append('Off')
×
2346
            else:
2347
                raise TypeError(
×
2348
                    f'Invalid value for parameter detect_hidden_windows. Expected boolean or None, got {detect_hidden_windows!r}'
2349
                )
2350
        else:
2351
            args.append('')
×
2352
        if title_match_mode is not None:
×
2353
            if isinstance(title_match_mode, tuple):
×
2354
                match_mode, match_speed = title_match_mode
×
2355
            elif title_match_mode in (1, 2, 3, 'RegEx'):
×
2356
                match_mode = title_match_mode
×
2357
                match_speed = ''
×
2358
            elif title_match_mode in ('Fast', 'Slow'):
×
2359
                match_mode = ''
×
2360
                match_speed = title_match_mode
×
2361
            else:
2362
                raise ValueError(
×
2363
                    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}"
2364
                )
2365
            args.append(str(match_mode))
×
2366
            args.append(str(match_speed))
×
2367
        else:
2368
            args.append('')
×
2369
            args.append('')
×
2370
        resp = self._transport.function_call('AHKWinSetTransparent', args, blocking=blocking)
×
2371
        return resp
×
2372

2373
    # fmt: off
2374
    @overload
4✔
2375
    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✔
2376
    @overload
4✔
2377
    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]) -> FutureResult[None]: ...
4✔
2378
    @overload
4✔
2379
    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✔
2380
    @overload
4✔
2381
    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, FutureResult[None]]: ...
4✔
2382
    # fmt: on
2383
    def win_set_trans_color(
4✔
2384
        self,
2385
        color: Union[int, str],
2386
        title: str = '',
2387
        text: str = '',
2388
        exclude_title: str = '',
2389
        exclude_text: str = '',
2390
        *,
2391
        title_match_mode: Optional[TitleMatchMode] = None,
2392
        detect_hidden_windows: Optional[bool] = None,
2393
        blocking: bool = True,
2394
    ) -> Union[None, FutureResult[None]]:
2395
        args = [str(color), title, text, exclude_title, exclude_text]
×
2396
        if detect_hidden_windows is not None:
×
2397
            if detect_hidden_windows is True:
×
2398
                args.append('On')
×
2399
            elif detect_hidden_windows is False:
×
2400
                args.append('Off')
×
2401
            else:
2402
                raise TypeError(
×
2403
                    f'Invalid value for parameter detect_hidden_windows. Expected boolean or None, got {detect_hidden_windows!r}'
2404
                )
2405
        else:
2406
            args.append('')
×
2407
        if title_match_mode is not None:
×
2408
            if isinstance(title_match_mode, tuple):
×
2409
                match_mode, match_speed = title_match_mode
×
2410
            elif title_match_mode in (1, 2, 3, 'RegEx'):
×
2411
                match_mode = title_match_mode
×
2412
                match_speed = ''
×
2413
            elif title_match_mode in ('Fast', 'Slow'):
×
2414
                match_mode = ''
×
2415
                match_speed = title_match_mode
×
2416
            else:
2417
                raise ValueError(
×
2418
                    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}"
2419
                )
2420
            args.append(str(match_mode))
×
2421
            args.append(str(match_speed))
×
2422
        else:
2423
            args.append('')
×
2424
            args.append('')
×
2425
        resp = self._transport.function_call('AHKWinSetTransColor', args, blocking=blocking)
×
2426
        return resp
×
2427

2428
    # alias for backwards compatibility
2429
    windows = list_windows
4✔
2430

2431
    # fmt: off
2432
    @overload
4✔
2433
    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✔
2434
    @overload
4✔
2435
    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✔
2436
    @overload
4✔
2437
    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) -> FutureResult[None]: ...
4✔
2438
    @overload
4✔
2439
    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, FutureResult[None]]: ...
4✔
2440
    # fmt: on
2441
    def right_click(
4✔
2442
        self,
2443
        x: Optional[Union[int, Tuple[int, int]]] = None,
2444
        y: Optional[int] = None,
2445
        click_count: Optional[int] = None,
2446
        direction: Optional[Literal['U', 'D', 'Up', 'Down']] = None,
2447
        *,
2448
        relative: Optional[bool] = None,
2449
        blocking: bool = True,
2450
        coord_mode: Optional[CoordModeRelativeTo] = None,
2451
    ) -> Union[None, FutureResult[None]]:
2452
        button = 'R'
×
2453
        return self.click(
×
2454
            x,
2455
            y,
2456
            button=button,
2457
            click_count=click_count,
2458
            direction=direction,
2459
            relative=relative,
2460
            blocking=blocking,
2461
            coord_mode=coord_mode,
2462
        )
2463

2464
    # fmt: off
2465
    @overload
4✔
2466
    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✔
2467
    @overload
4✔
2468
    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✔
2469
    @overload
4✔
2470
    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) -> FutureResult[None]: ...
4✔
2471
    @overload
4✔
2472
    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, FutureResult[None]]: ...
4✔
2473
    # fmt: on
2474
    def click(
4✔
2475
        self,
2476
        x: Optional[Union[int, Tuple[int, int]]] = None,
2477
        y: Optional[int] = None,
2478
        button: Optional[Union[MouseButton, str]] = None,
2479
        click_count: Optional[int] = None,
2480
        direction: Optional[Literal['U', 'D', 'Up', 'Down']] = None,
2481
        *,
2482
        relative: Optional[bool] = None,
2483
        blocking: bool = True,
2484
        coord_mode: Optional[CoordModeRelativeTo] = None,
2485
    ) -> Union[None, FutureResult[None]]:
2486
        if x or y:
×
2487
            if y is None and isinstance(x, tuple) and len(x) == 2:
×
2488
                #  allow position to be specified by a two-sequence tuple
2489
                x, y = x
×
2490
            assert x is not None and y is not None, 'If provided, position must be specified by x AND y'
×
2491
        if button is None:
×
2492
            button = 'L'
×
2493
        button = _resolve_button(button)
×
2494

2495
        if relative:
×
2496
            r = 'Rel'
×
2497
        else:
2498
            r = ''
×
2499
        if coord_mode is None:
×
2500
            coord_mode = ''
×
2501
        args = [str(x), str(y), button, str(click_count), direction or '', r, coord_mode]
×
2502
        resp = self._transport.function_call('AHKClick', args, blocking=blocking)
×
2503
        return resp
×
2504

2505
    # fmt: off
2506
    @overload
4✔
2507
    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✔
2508
    @overload
4✔
2509
    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]) -> FutureResult[Optional[Tuple[int, int]]]: ...
4✔
2510
    @overload
4✔
2511
    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✔
2512
    @overload
4✔
2513
    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, FutureResult[Optional[Tuple[int, int]]]]: ...
4✔
2514
    # fmt: on
2515
    def image_search(
4✔
2516
        self,
2517
        image_path: str,
2518
        upper_bound: Tuple[Union[int, str], Union[int, str]] = (0, 0),
2519
        lower_bound: Optional[Tuple[Union[int, str], Union[int, str]]] = None,
2520
        *,
2521
        color_variation: Optional[int] = None,
2522
        coord_mode: Optional[CoordModeRelativeTo] = None,
2523
        scale_height: Optional[int] = None,
2524
        scale_width: Optional[int] = None,
2525
        transparent: Optional[str] = None,
2526
        icon: Optional[int] = None,
2527
        blocking: bool = True,
2528
    ) -> Union[Tuple[int, int], None, FutureResult[Optional[Tuple[int, int]]]]:
2529
        """
2530
        https://www.autohotkey.com/docs/commands/ImageSearch.htm
2531
        """
2532

2533
        if scale_height and not scale_width:
×
2534
            scale_width = -1
×
2535
        elif scale_width and not scale_height:
×
2536
            scale_height = -1
×
2537

2538
        options: List[Union[str, int]] = []
×
2539
        if icon:
×
2540
            options.append(f'Icon{icon}')
×
2541
        if color_variation is not None:
×
2542
            options.append(color_variation)
×
2543
        if transparent is not None:
×
2544
            options.append(f'Trans{transparent}')
×
2545
        if scale_width:
×
2546
            options.append(f'w{scale_width}')
×
2547
            options.append(f'h{scale_height}')
×
2548

2549
        x1, y1 = upper_bound
×
2550
        if lower_bound:
×
2551
            x2, y2 = lower_bound
×
2552
        else:
2553
            x2, y2 = ('A_ScreenWidth', 'A_ScreenHeight')
×
2554

2555
        args = [str(x1), str(y1), str(x2), str(y2)]
×
2556
        if options:
×
2557
            opts = ' '.join(f'*{opt}' for opt in options)
×
2558
            args.append(opts)
×
2559
        else:
2560
            args.append(image_path)
×
2561
        resp = self._transport.function_call('AHKImageSearch', args, blocking=blocking)
×
2562
        return resp
×
2563

2564
    def mouse_drag(
4✔
2565
        self,
2566
        x: int,
2567
        y: int,
2568
        *,
2569
        from_position: Optional[Tuple[int, int]] = None,
2570
        speed: Optional[int] = None,
2571
        button: MouseButton = 1,
2572
        relative: Optional[bool] = None,
2573
        blocking: bool = True,
2574
        coord_mode: Optional[CoordModeRelativeTo] = None,
2575
    ) -> None:
2576
        if from_position:
×
2577
            x1, y1 = from_position
×
2578
            args = [str(button), str(x1), str(y1), str(x), str(y)]
×
2579
        else:
2580
            args = [str(button), '', '', str(x), str(y)]
×
2581

2582
        if speed:
×
2583
            args.append(str(speed))
×
2584
        else:
2585
            args.append('')
×
2586

2587
        if relative:
×
2588
            args.append('R')
×
2589
        else:
2590
            args.append('')
×
2591

2592
        if coord_mode:
×
2593
            args.append(coord_mode)
×
2594

2595
        self._transport.function_call('AHKMouseClickDrag', args, blocking=blocking)
×
2596

2597
    # fmt: off
2598
    @overload
4✔
2599
    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✔
2600
    @overload
4✔
2601
    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✔
2602
    @overload
4✔
2603
    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]) -> FutureResult[str]: ...
4✔
2604
    @overload
4✔
2605
    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, FutureResult[str]]: ...
4✔
2606
    # fmt: on
2607
    def pixel_get_color(
4✔
2608
        self,
2609
        x: int,
2610
        y: int,
2611
        *,
2612
        coord_mode: Optional[CoordModeRelativeTo] = None,
2613
        alt: bool = False,
2614
        slow: bool = False,
2615
        rgb: bool = True,
2616
        blocking: bool = True,
2617
    ) -> Union[str, FutureResult[str]]:
2618
        args = [str(x), str(y), coord_mode or '']
×
2619

2620
        options = ' '.join(word for word, val in zip(('Alt', 'Slow', 'RGB'), (alt, slow, rgb)) if val)
×
2621
        args.append(options)
×
2622

2623
        resp = self._transport.function_call('AHKPixelGetColor', args, blocking=blocking)
×
2624
        return resp
×
2625

2626
    # fmt: off
2627
    @overload
4✔
2628
    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✔
2629
    @overload
4✔
2630
    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✔
2631
    @overload
4✔
2632
    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]) -> FutureResult[Optional[Tuple[int, int]]]: ...
4✔
2633
    @overload
4✔
2634
    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]], FutureResult[Optional[Tuple[int, int]]]]: ...
4✔
2635
    # fmt: on
2636
    def pixel_search(
4✔
2637
        self,
2638
        search_region_start: Tuple[int, int],
2639
        search_region_end: Tuple[int, int],
2640
        color: Union[str, int],
2641
        variation: int = 0,
2642
        *,
2643
        coord_mode: Optional[CoordModeRelativeTo] = None,
2644
        fast: bool = True,
2645
        rgb: bool = True,
2646
        blocking: bool = True,
2647
    ) -> Union[Optional[Tuple[int, int]], FutureResult[Optional[Tuple[int, int]]]]:
2648
        x1, y1 = search_region_start
×
2649
        x2, y2 = search_region_end
×
2650
        args = [str(x1), str(y1), str(x2), str(y2), str(color), str(variation)]
×
2651
        mode = ' '.join(word for word, val in zip(('Fast', 'RGB'), (fast, rgb)) if val)
×
2652
        args.append(mode)
×
2653
        args.append(coord_mode or '')
×
2654
        resp = self._transport.function_call('AHKPixelSearch', args, blocking=blocking)
×
2655
        return resp
×
2656

2657
    # fmt: off
2658
    @overload
4✔
2659
    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✔
2660
    @overload
4✔
2661
    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✔
2662
    @overload
4✔
2663
    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]) -> FutureResult[None]: ...
4✔
2664
    @overload
4✔
2665
    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, FutureResult[None]]: ...
4✔
2666
    # fmt: on
2667
    def win_close(
4✔
2668
        self,
2669
        title: str = '',
2670
        text: str = '',
2671
        seconds_to_wait: Optional[int] = None,
2672
        exclude_title: str = '',
2673
        exclude_text: str = '',
2674
        *,
2675
        blocking: bool = True,
2676
        title_match_mode: Optional[TitleMatchMode] = None,
2677
        detect_hidden_windows: Optional[bool] = None,
2678
    ) -> Union[None, FutureResult[None]]:
2679
        args = self._format_win_args(
4✔
2680
            title=title,
2681
            text=text,
2682
            exclude_title=exclude_title,
2683
            exclude_text=exclude_text,
2684
            title_match_mode=title_match_mode,
2685
            detect_hidden_windows=detect_hidden_windows,
2686
        )
2687
        args.append(str(seconds_to_wait) if seconds_to_wait else '')
4✔
2688

2689
        resp = self._transport.function_call('AHKWinClose', args, engine=self, blocking=blocking)
4✔
2690
        return resp
4✔
2691

2692
    # fmt: off
2693
    @overload
4✔
2694
    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✔
2695
    @overload
4✔
2696
    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, FutureResult[None]]: ...
4✔
2697
    @overload
4✔
2698
    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✔
2699
    @overload
4✔
2700
    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, FutureResult[None]]: ...
4✔
2701
    # fmt: on
2702
    def win_kill(
4✔
2703
        self,
2704
        title: str = '',
2705
        text: str = '',
2706
        seconds_to_wait: Optional[int] = None,
2707
        exclude_title: str = '',
2708
        exclude_text: str = '',
2709
        *,
2710
        title_match_mode: Optional[TitleMatchMode] = None,
2711
        detect_hidden_windows: Optional[bool] = None,
2712
        blocking: bool = True,
2713
    ) -> Union[None, FutureResult[None]]:
2714
        args = self._format_win_args(
×
2715
            title=title,
2716
            text=text,
2717
            exclude_title=exclude_title,
2718
            exclude_text=exclude_text,
2719
            title_match_mode=title_match_mode,
2720
            detect_hidden_windows=detect_hidden_windows,
2721
        )
2722
        args.append(str(seconds_to_wait) if seconds_to_wait else '')
×
2723

2724
        resp = self._transport.function_call('AHKWinKill', args, engine=self, blocking=blocking)
×
2725
        return resp
×
2726

2727
    # fmt: off
2728
    @overload
4✔
2729
    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✔
2730
    @overload
4✔
2731
    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, FutureResult[None]]: ...
4✔
2732
    @overload
4✔
2733
    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✔
2734
    @overload
4✔
2735
    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, FutureResult[None]]: ...
4✔
2736
    # fmt: on
2737
    def win_minimize(
4✔
2738
        self,
2739
        title: str = '',
2740
        text: str = '',
2741
        exclude_title: str = '',
2742
        exclude_text: str = '',
2743
        *,
2744
        title_match_mode: Optional[TitleMatchMode] = None,
2745
        detect_hidden_windows: Optional[bool] = None,
2746
        blocking: bool = True,
2747
    ) -> Union[None, FutureResult[None]]:
2748
        args = self._format_win_args(
×
2749
            title=title,
2750
            text=text,
2751
            exclude_title=exclude_title,
2752
            exclude_text=exclude_text,
2753
            title_match_mode=title_match_mode,
2754
            detect_hidden_windows=detect_hidden_windows,
2755
        )
2756
        resp = self._transport.function_call('AHKWinMinimize', args, engine=self, blocking=blocking)
×
2757
        return resp
×
2758

2759
    # fmt: off
2760
    @overload
4✔
2761
    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✔
2762
    @overload
4✔
2763
    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, FutureResult[None]]: ...
4✔
2764
    @overload
4✔
2765
    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✔
2766
    @overload
4✔
2767
    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, FutureResult[None]]: ...
4✔
2768
    # fmt: on
2769
    def win_maximize(
4✔
2770
        self,
2771
        title: str = '',
2772
        text: str = '',
2773
        exclude_title: str = '',
2774
        exclude_text: str = '',
2775
        *,
2776
        title_match_mode: Optional[TitleMatchMode] = None,
2777
        detect_hidden_windows: Optional[bool] = None,
2778
        blocking: bool = True,
2779
    ) -> Union[None, FutureResult[None]]:
2780
        args = self._format_win_args(
×
2781
            title=title,
2782
            text=text,
2783
            exclude_title=exclude_title,
2784
            exclude_text=exclude_text,
2785
            title_match_mode=title_match_mode,
2786
            detect_hidden_windows=detect_hidden_windows,
2787
        )
2788
        resp = self._transport.function_call('AHKWinMaximize', args, engine=self, blocking=blocking)
×
2789
        return resp
×
2790

2791
    # fmt: off
2792
    @overload
4✔
2793
    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✔
2794
    @overload
4✔
2795
    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, FutureResult[None]]: ...
4✔
2796
    @overload
4✔
2797
    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✔
2798
    @overload
4✔
2799
    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, FutureResult[None]]: ...
4✔
2800
    # fmt: on
2801
    def win_restore(
4✔
2802
        self,
2803
        title: str = '',
2804
        text: str = '',
2805
        exclude_title: str = '',
2806
        exclude_text: str = '',
2807
        *,
2808
        title_match_mode: Optional[TitleMatchMode] = None,
2809
        detect_hidden_windows: Optional[bool] = None,
2810
        blocking: bool = True,
2811
    ) -> Union[None, FutureResult[None]]:
2812
        args = self._format_win_args(
×
2813
            title=title,
2814
            text=text,
2815
            exclude_title=exclude_title,
2816
            exclude_text=exclude_text,
2817
            title_match_mode=title_match_mode,
2818
            detect_hidden_windows=detect_hidden_windows,
2819
        )
2820
        resp = self._transport.function_call('AHKWinRestore', args, engine=self, blocking=blocking)
×
2821
        return resp
×
2822

2823
    # fmt: off
2824
    @overload
4✔
2825
    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) -> Window: ...
4✔
2826
    @overload
4✔
2827
    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]) -> FutureResult[Window]: ...
4✔
2828
    @overload
4✔
2829
    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]) -> Window: ...
4✔
2830
    @overload
4✔
2831
    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[Window, FutureResult[Window]]: ...
4✔
2832
    # fmt: on
2833
    def win_wait(
4✔
2834
        self,
2835
        title: str = '',
2836
        text: str = '',
2837
        exclude_title: str = '',
2838
        exclude_text: str = '',
2839
        *,
2840
        title_match_mode: Optional[TitleMatchMode] = None,
2841
        detect_hidden_windows: Optional[bool] = None,
2842
        timeout: Optional[int] = None,
2843
        blocking: bool = True,
2844
    ) -> Union[Window, FutureResult[Window]]:
2845
        args = self._format_win_args(
4✔
2846
            title=title,
2847
            text=text,
2848
            exclude_title=exclude_title,
2849
            exclude_text=exclude_text,
2850
            title_match_mode=title_match_mode,
2851
            detect_hidden_windows=detect_hidden_windows,
2852
        )
2853
        args.append(str(timeout) if timeout else '')
4✔
2854
        resp = self._transport.function_call('AHKWinWait', args, blocking=blocking, engine=self)
4✔
2855
        return resp
4✔
2856

2857
    # fmt: off
2858
    @overload
4✔
2859
    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) -> Window: ...
4✔
2860
    @overload
4✔
2861
    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]) -> FutureResult[Window]: ...
4✔
2862
    @overload
4✔
2863
    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]) -> Window: ...
4✔
2864
    @overload
4✔
2865
    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[Window, FutureResult[Window]]: ...
4✔
2866
    # fmt: on
2867
    def win_wait_active(
4✔
2868
        self,
2869
        title: str = '',
2870
        text: str = '',
2871
        exclude_title: str = '',
2872
        exclude_text: str = '',
2873
        *,
2874
        title_match_mode: Optional[TitleMatchMode] = None,
2875
        detect_hidden_windows: Optional[bool] = None,
2876
        timeout: Optional[int] = None,
2877
        blocking: bool = True,
2878
    ) -> Union[Window, FutureResult[Window]]:
2879
        args = self._format_win_args(
×
2880
            title=title,
2881
            text=text,
2882
            exclude_title=exclude_title,
2883
            exclude_text=exclude_text,
2884
            title_match_mode=title_match_mode,
2885
            detect_hidden_windows=detect_hidden_windows,
2886
        )
2887
        args.append(str(timeout) if timeout else '')
×
2888
        resp = self._transport.function_call('AHKWinWaitActive', args, blocking=blocking, engine=self)
×
2889
        return resp
×
2890

2891
    # fmt: off
2892
    @overload
4✔
2893
    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) -> Window: ...
4✔
2894
    @overload
4✔
2895
    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]) -> FutureResult[Window]: ...
4✔
2896
    @overload
4✔
2897
    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]) -> Window: ...
4✔
2898
    @overload
4✔
2899
    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[Window, FutureResult[Window]]: ...
4✔
2900
    # fmt: on
2901
    def win_wait_not_active(
4✔
2902
        self,
2903
        title: str = '',
2904
        text: str = '',
2905
        exclude_title: str = '',
2906
        exclude_text: str = '',
2907
        *,
2908
        title_match_mode: Optional[TitleMatchMode] = None,
2909
        detect_hidden_windows: Optional[bool] = None,
2910
        timeout: Optional[int] = None,
2911
        blocking: bool = True,
2912
    ) -> Union[Window, FutureResult[Window]]:
2913
        args = self._format_win_args(
×
2914
            title=title,
2915
            text=text,
2916
            exclude_title=exclude_title,
2917
            exclude_text=exclude_text,
2918
            title_match_mode=title_match_mode,
2919
            detect_hidden_windows=detect_hidden_windows,
2920
        )
2921
        args.append(str(timeout) if timeout else '')
×
2922
        resp = self._transport.function_call('AHKWinWaitNotActive', args, blocking=blocking, engine=self)
×
2923
        return resp
×
2924

2925
    # fmt: off
2926
    @overload
4✔
2927
    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✔
2928
    @overload
4✔
2929
    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]) -> FutureResult[None]: ...
4✔
2930
    @overload
4✔
2931
    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✔
2932
    @overload
4✔
2933
    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, FutureResult[None]]: ...
4✔
2934
    # fmt: on
2935
    def win_wait_close(
4✔
2936
        self,
2937
        title: str = '',
2938
        text: str = '',
2939
        exclude_title: str = '',
2940
        exclude_text: str = '',
2941
        *,
2942
        title_match_mode: Optional[TitleMatchMode] = None,
2943
        detect_hidden_windows: Optional[bool] = None,
2944
        timeout: Optional[int] = None,
2945
        blocking: bool = True,
2946
    ) -> Union[None, FutureResult[None]]:
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(timeout) if timeout else '')
×
2956
        resp = self._transport.function_call('AHKWinWaitClose', args, blocking=blocking, engine=self)
×
2957
        return resp
×
2958

2959
    # fmt: off
2960
    @overload
4✔
2961
    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✔
2962
    @overload
4✔
2963
    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]) -> FutureResult[None]: ...
4✔
2964
    @overload
4✔
2965
    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✔
2966
    @overload
4✔
2967
    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, FutureResult[None]]: ...
4✔
2968
    # fmt: on
2969
    def win_show(
4✔
2970
        self,
2971
        title: str = '',
2972
        text: str = '',
2973
        exclude_title: str = '',
2974
        exclude_text: str = '',
2975
        *,
2976
        title_match_mode: Optional[TitleMatchMode] = None,
2977
        detect_hidden_windows: Optional[bool] = None,
2978
        blocking: bool = True,
2979
    ) -> Union[None, FutureResult[None]]:
2980
        args = self._format_win_args(
×
2981
            title=title,
2982
            text=text,
2983
            exclude_title=exclude_title,
2984
            exclude_text=exclude_text,
2985
            title_match_mode=title_match_mode,
2986
            detect_hidden_windows=detect_hidden_windows,
2987
        )
2988
        resp = self._transport.function_call('AHKWinShow', args, blocking=blocking)
×
2989
        return resp
×
2990

2991
    # fmt: off
2992
    @overload
4✔
2993
    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✔
2994
    @overload
4✔
2995
    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]) -> FutureResult[None]: ...
4✔
2996
    @overload
4✔
2997
    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✔
2998
    @overload
4✔
2999
    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, FutureResult[None]]: ...
4✔
3000
    # fmt: on
3001
    def win_hide(
4✔
3002
        self,
3003
        title: str = '',
3004
        text: str = '',
3005
        exclude_title: str = '',
3006
        exclude_text: str = '',
3007
        *,
3008
        title_match_mode: Optional[TitleMatchMode] = None,
3009
        detect_hidden_windows: Optional[bool] = None,
3010
        blocking: bool = True,
3011
    ) -> Union[None, FutureResult[None]]:
3012
        args = self._format_win_args(
×
3013
            title=title,
3014
            text=text,
3015
            exclude_title=exclude_title,
3016
            exclude_text=exclude_text,
3017
            title_match_mode=title_match_mode,
3018
            detect_hidden_windows=detect_hidden_windows,
3019
        )
3020
        resp = self._transport.function_call('AHKWinHide', args, blocking=blocking)
×
3021
        return resp
×
3022

3023
    # fmt: off
3024
    @overload
4✔
3025
    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✔
3026
    @overload
4✔
3027
    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✔
3028
    @overload
4✔
3029
    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]) -> FutureResult[bool]: ...
4✔
3030
    @overload
4✔
3031
    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, FutureResult[bool]]: ...
4✔
3032
    # fmt: on
3033
    def win_is_active(
4✔
3034
        self,
3035
        title: str = '',
3036
        text: str = '',
3037
        exclude_title: str = '',
3038
        exclude_text: str = '',
3039
        *,
3040
        title_match_mode: Optional[TitleMatchMode] = None,
3041
        detect_hidden_windows: Optional[bool] = None,
3042
        blocking: bool = True,
3043
    ) -> Union[bool, FutureResult[bool]]:
3044
        args = self._format_win_args(
4✔
3045
            title=title,
3046
            text=text,
3047
            exclude_title=exclude_title,
3048
            exclude_text=exclude_text,
3049
            title_match_mode=title_match_mode,
3050
            detect_hidden_windows=detect_hidden_windows,
3051
        )
3052
        resp = self._transport.function_call('AHKWinIsActive', args, blocking=blocking)
4✔
3053
        return resp
4✔
3054

3055
    # fmt: off
3056
    @overload
4✔
3057
    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✔
3058
    @overload
4✔
3059
    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✔
3060
    @overload
4✔
3061
    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]) -> FutureResult[None]: ...
4✔
3062
    @overload
4✔
3063
    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, FutureResult[None]]: ...
4✔
3064
    # fmt: on
3065
    def win_move(
4✔
3066
        self,
3067
        x: int,
3068
        y: int,
3069
        *,
3070
        width: Optional[int] = None,
3071
        height: Optional[int] = None,
3072
        title: str = '',
3073
        text: str = '',
3074
        exclude_title: str = '',
3075
        exclude_text: str = '',
3076
        title_match_mode: Optional[TitleMatchMode] = None,
3077
        detect_hidden_windows: Optional[bool] = None,
3078
        blocking: bool = True,
3079
    ) -> Union[None, FutureResult[None]]:
3080
        args = self._format_win_args(
4✔
3081
            title=title,
3082
            text=text,
3083
            exclude_title=exclude_title,
3084
            exclude_text=exclude_text,
3085
            title_match_mode=title_match_mode,
3086
            detect_hidden_windows=detect_hidden_windows,
3087
        )
3088
        args.append(str(x))
4✔
3089
        args.append(str(y))
4✔
3090
        args.append(str(width) if width is not None else '')
4✔
3091
        args.append(str(height) if height is not None else '')
4✔
3092
        resp = self._transport.function_call('AHKWinMove', args, blocking=blocking)
4✔
3093
        return resp
4✔
3094

3095
    # fmt: off
3096
    @overload
4✔
3097
    def get_clipboard(self) -> str: ...
4✔
3098
    @overload
4✔
3099
    def get_clipboard(self, *, blocking: Literal[False]) -> FutureResult[str]: ...
4✔
3100
    @overload
4✔
3101
    def get_clipboard(self, *, blocking: Literal[True]) -> str: ...
4✔
3102
    @overload
4✔
3103
    def get_clipboard(self, *, blocking: bool = True) -> Union[str, FutureResult[str]]: ...
4✔
3104
    # fmt: on
3105
    def get_clipboard(self, *, blocking: bool = True) -> Union[str, FutureResult[str]]:
4✔
3106
        return self._transport.function_call('AHKGetClipboard', blocking=blocking)
4✔
3107

3108
    def set_clipboard(self, s: str, *, blocking: bool = True) -> Union[None, FutureResult[None]]:
4✔
3109
        args = [s]
4✔
3110
        return self._transport.function_call('AHKSetClipboard', args, blocking=blocking)
4✔
3111

3112
    def get_clipboard_all(self, *, blocking: bool = True) -> Union[bytes, FutureResult[bytes]]:
4✔
3113
        return self._transport.function_call('AHKGetClipboardAll', blocking=blocking)
4✔
3114

3115
    # fmt: off
3116
    @overload
4✔
3117
    def set_clipboard_all(self, contents: bytes) -> None: ...
4✔
3118
    @overload
4✔
3119
    def set_clipboard_all(self, contents: bytes, *, blocking: Literal[False]) -> FutureResult[None]: ...
4✔
3120
    @overload
4✔
3121
    def set_clipboard_all(self, contents: bytes, *, blocking: Literal[True]) -> None: ...
4✔
3122
    @overload
4✔
3123
    def set_clipboard_all(self, contents: bytes, *, blocking: bool = True) -> Union[None, FutureResult[None]]: ...
4✔
3124
    # fmt: on
3125
    def set_clipboard_all(
4✔
3126
        self, contents: bytes, *, blocking: bool = True
3127
    ) -> Union[None, FutureResult[None]]:
3128
        # TODO: figure out how to do this without a tempfile
3129
        if not isinstance(contents, bytes):
4✔
3130
            raise ValueError('Malformed data. Can only set bytes as returned by get_clipboard_all')
×
3131
        if not contents:
4✔
3132
            raise ValueError('bytes must be nonempty. If you want to clear the clipboard, use `set_clipboard`')
×
3133
        with tempfile.NamedTemporaryFile(prefix='ahk-python', suffix='.clip', mode='wb', delete=False) as f:
4✔
3134
            f.write(contents)
4✔
3135

3136
        args = [f'*c {f.name}']
4✔
3137
        try:
4✔
3138
            resp = self._transport.function_call('AHKSetClipboardAll', args, blocking=blocking)
4✔
3139
            return resp
4✔
3140
        finally:
3141
            try:
4✔
3142
                os.remove(f.name)
4✔
3143
            except Exception:
×
3144
                pass
×
3145

3146
    def on_clipboard_change(
4✔
3147
        self, callback: Callable[[int], Any], ex_handler: Optional[Callable[[int, Exception], Any]] = None
3148
    ) -> None:
3149
        self._transport.on_clipboard_change(callback, ex_handler)
4✔
3150

3151
    # fmt: off
3152
    @overload
4✔
3153
    def clip_wait(self, timeout: Optional[float] = None, wait_for_any_data: bool = False) -> None: ...
4✔
3154
    @overload
4✔
3155
    def clip_wait(self, timeout: Optional[float] = None, wait_for_any_data: bool = False, *, blocking: Literal[False]) -> FutureResult[None]: ...
4✔
3156
    @overload
4✔
3157
    def clip_wait(self, timeout: Optional[float] = None, wait_for_any_data: bool = False, *, blocking: Literal[True]) -> None: ...
4✔
3158
    @overload
4✔
3159
    def clip_wait(self, timeout: Optional[float] = None, wait_for_any_data: bool = False, *, blocking: bool = True) -> Union[None, FutureResult[None]]: ...
4✔
3160
    # fmt: on
3161
    def clip_wait(
4✔
3162
        self, timeout: Optional[float] = None, wait_for_any_data: bool = False, *, blocking: bool = True
3163
    ) -> Union[None, FutureResult[None]]:
3164
        args = [str(timeout) if timeout else '']
×
3165
        if wait_for_any_data:
×
3166
            args.append('1')
×
3167
        return self._transport.function_call('AHKClipWait', args, blocking=blocking)
×
3168

3169
    def block_input(
4✔
3170
        self,
3171
        value: Literal['On', 'Off', 'Default', 'Send', 'Mouse', 'MouseMove', 'MouseMoveOff', 'SendAndMouse'],
3172
        /,  # flake8: noqa
3173
    ) -> None:
3174
        self._transport.function_call('AHKBlockInput', args=[value])
×
3175

3176
    # fmt: off
3177
    @overload
4✔
3178
    def reg_delete(self, key_name: str, value_name: Optional[str] = None) -> None: ...
4✔
3179
    @overload
4✔
3180
    def reg_delete(self, key_name: str, value_name: Optional[str] = None, *, blocking: Literal[False]) -> Union[None, FutureResult[None]]: ...
4✔
3181
    @overload
4✔
3182
    def reg_delete(self, key_name: str, value_name: Optional[str] = None, *, blocking: Literal[True]) -> None: ...
4✔
3183
    @overload
4✔
3184
    def reg_delete(self, key_name: str, value_name: Optional[str] = None, *, blocking: bool = True) -> Union[None, FutureResult[None]]: ...
4✔
3185
    # fmt: on
3186
    def reg_delete(
4✔
3187
        self, key_name: str, value_name: Optional[str] = None, *, blocking: bool = True
3188
    ) -> Union[None, FutureResult[None]]:
3189
        args = [key_name, value_name if value_name is not None else '']
4✔
3190
        return self._transport.function_call('AHKRegDelete', args, blocking=blocking)
4✔
3191

3192
    # fmt: off
3193
    @overload
4✔
3194
    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✔
3195
    @overload
4✔
3196
    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]) -> FutureResult[None]: ...
4✔
3197
    @overload
4✔
3198
    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✔
3199
    @overload
4✔
3200
    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, FutureResult[None]]: ...
4✔
3201
    # fmt: on
3202
    def reg_write(
4✔
3203
        self,
3204
        value_type: Literal['REG_SZ', 'REG_EXPAND_SZ', 'REG_MULTI_SZ', 'REG_DWORD', 'REG_BINARY'],
3205
        key_name: str,
3206
        value_name: Optional[str] = None,
3207
        value: Optional[str] = None,
3208
        *,
3209
        blocking: bool = True,
3210
    ) -> Union[None, FutureResult[None]]:
3211
        args = [value_type, key_name]
4✔
3212
        if value_name is not None:
4✔
3213
            args.append(value_name)
4✔
3214
        else:
3215
            args.append('')
4✔
3216
        if value is not None:
4✔
3217
            args.append(value)
4✔
3218
        return self._transport.function_call('AHKRegWrite', args, blocking=blocking)
4✔
3219

3220
    # fmt: off
3221
    @overload
4✔
3222
    def reg_read(self, key_name: str, value_name: Optional[str] = None) -> str: ...
4✔
3223
    @overload
4✔
3224
    def reg_read(self, key_name: str, value_name: Optional[str] = None, *, blocking: Literal[False]) -> FutureResult[str]: ...
4✔
3225
    @overload
4✔
3226
    def reg_read(self, key_name: str, value_name: Optional[str] = None, *, blocking: Literal[True]) -> str: ...
4✔
3227
    @overload
4✔
3228
    def reg_read(self, key_name: str, value_name: Optional[str] = None, *, blocking: bool = True) -> Union[str, FutureResult[str]]: ...
4✔
3229
    # fmt: on
3230
    def reg_read(
4✔
3231
        self, key_name: str, value_name: Optional[str] = None, *, blocking: bool = True
3232
    ) -> Union[str, FutureResult[str]]:
3233
        args = [key_name]
4✔
3234
        if value_name is not None:
4✔
3235
            args.append(value_name)
4✔
3236
        return self._transport.function_call('AHKRegRead', args, blocking=blocking)
4✔
3237

3238
    def block_forever(self) -> NoReturn:
4✔
3239
        while True:
3240
            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

© 2026 Coveralls, Inc