@@ -24,9 +24,9 @@ The most common use case, of course, simply invokes a script:
24
24
25
25
ahkpy myscript.py
26
26
27
- The REPL interface works best when you invoke it with the ``python ``
28
- executable, which allows you to explore your command history with the up and
29
- down arrow keys.
27
+ The REPL interface works best when you invoke it with the ``python `` executable,
28
+ which allows you to explore your command history with the up and down arrow
29
+ keys.
30
30
31
31
.. code-block :: text
32
32
@@ -60,7 +60,8 @@ following sequence:
60
60
is, AutoHotkey.py uses the environment variable as the AutoHotkey executable
61
61
path.
62
62
2. If not, checks the Windows Registry to find whether a program's set to run
63
- when a user opens an AHK file.
63
+ when a user opens an AHK file. If the program name starts with ``autohotkey ``
64
+ (case-insensitive), AutoHotkey.py uses it as the AutoHotkey executable path.
64
65
3. Otherwise, defaults to the path
65
66
``C:\Program Files\AutoHotkey\AutoHotkey.exe ``.
66
67
@@ -76,10 +77,9 @@ when a user opens an AHK file.
76
77
Hotkeys
77
78
-------
78
79
79
- The :func: `hotkey ` function registers HotKeys. In the
80
- following example, the hotkey :kbd: `Win ` + :kbd: `N ` is configured to launch
81
- Notepad. The pound sign ``# `` stands for the :kbd: `Win ` key, one of the hotkey
82
- modifiers::
80
+ The :func: `hotkey ` function registers Hotkeys. In the following example, the
81
+ hotkey :kbd: `Win ` + :kbd: `N ` is configured to launch Notepad. The pound sign
82
+ ``# `` stands for the :kbd: `Win ` key, one of the hotkey modifiers::
83
83
84
84
import subprocess
85
85
import ahkpy
@@ -93,9 +93,8 @@ If you want to bind an existing function to a hotkey, pass it as an argument to
93
93
94
94
ahkpy.hotkey("#n", subprocess.Popen, ["notepad"])
95
95
96
- In the preceding example, when a user presses :kbd: `Win ` + :kbd: `N `,
97
- they create a :class: `subprocess.Popen ` object with the argument
98
- ``["notepad"] ``.
96
+ In the preceding example, when a user presses :kbd: `Win ` + :kbd: `N `, they create
97
+ a :class: `subprocess.Popen ` object with the argument ``["notepad"] ``.
99
98
100
99
To disable a key or a combination of keys for the entire system, use the
101
100
``lambda: None `` function. For example, this disables the right-side :kbd: `Win `
@@ -105,8 +104,8 @@ key::
105
104
106
105
If you want to specify certain conditions when a hotkey performs a different
107
106
action (or no action at all), you can use the methods
108
- :meth: `Windows.active_window_context ` and :meth: `Windows.window_context `,
109
- or the class :class: `HotkeyContext `. For example::
107
+ :meth: `Windows.active_window_context ` and :meth: `Windows.window_context `, or the
108
+ class :class: `HotkeyContext `. For example::
110
109
111
110
notepad_ctx = ahkpy.windows.active_window_context(class_name="Notepad")
112
111
notepad_ctx.hotkey(
@@ -175,17 +174,17 @@ Window Management
175
174
-----------------
176
175
177
176
AutoHotkey.py provides the :class: `Windows ` class and its default instances:
178
- :data: `windows ` and :data: `all_windows `. With the :class: `Windows ` class
179
- interface, you can query windows through multiple search parameters, like
180
- `` title `` and `` window `` . To query the windows, set the criteria with the
181
- :meth: ` ~Windows.filter ` method. For example, this prepares a query of all
182
- windows of the class ``ConsoleWindowClass ``::
177
+ :data: `windows ` and :data: `all_windows `. With the :class: `Windows ` class, you
178
+ can query windows through multiple search parameters, like title and window
179
+ class . To query the windows, set the criteria with the :meth: ` ~Windows.filter `
180
+ method. For example, this prepares a query of all windows of the class
181
+ ``ConsoleWindowClass ``::
183
182
184
183
>>> console_windows = ahkpy.windows.filter(class_name="ConsoleWindowClass")
185
184
186
- The only role of the :meth: `~Windows.filter ` method is to pack the
187
- query parameters. Once you've filtered the object you want, you can perform
188
- a real operation, like get the count of matching windows::
185
+ The only role of the :meth: `~Windows.filter ` method is to pack the query
186
+ parameters. Once you've set the filters you want, you can perform a real
187
+ operation, like get the count of matching windows::
189
188
190
189
>>> console_windows
191
190
Windows(class_name='ConsoleWindowClass', hidden_windows=False, hidden_text=True, title_mode='startswith', text_mode='fast')
@@ -200,10 +199,10 @@ a real operation, like get the count of matching windows::
200
199
>>> [win.title for win in console_windows]
201
200
['Command Prompt', 'Windows PowerShell', 'C:\\Windows\\py.exe']
202
201
203
- Specifying multiple criteria for :meth: `~Windows.filter ` narrows the
204
- the search down to only the windows where *all * criteria match. In the
205
- following example, the script waits for a window whose title contains
206
- `` My File.txt `` and whose class is ``Notepad ``::
202
+ Specifying multiple criteria for :meth: `~Windows.filter ` narrows the search down
203
+ to only the windows where *all * criteria match. In the following example, the
204
+ script waits for a window whose title contains `` My File.txt `` and whose class
205
+ is ``Notepad ``::
207
206
208
207
ahkpy.windows.filter("My File.txt", class_name="Notepad").wait()
209
208
# Filter chaining gives the same result.
0 commit comments