Python wrapper for AutoHotkey with full type support. Harness the automation power of AutoHotkey with the beauty of Python.
MIT License
Published by spyoungtech 11 months ago
This release introduces two major features: support for AHK v2 and an extension system to allow users to author and distribute extended functionality for the Python AHK wrapper. Check the documentation for more details. This release also includes some significant performance improvements -- up to 700% faster for some use cases.
Full Changelog: https://github.com/spyoungtech/ahk/compare/v1.3.0...v1.4.0
Published by spyoungtech about 1 year ago
Release candidate for 1.4.0 rc2 -- adds initial AHK v2 support (beta) and extension authoring (beta)
Published by spyoungtech about 1 year ago
Release candidate for 1.4.0
Published by spyoungtech about 1 year ago
Adds 4 new methods:
msg_box
as an analog for AHK's MsgBox
input_box
as an analog for AHK's InputBox
file_select_box
as an analog for AHK's FileSelectFile
folder_select_box
as an analog for AHK's FileSelectFolder
Full Changelog: https://github.com/spyoungtech/ahk/compare/v1.2.0...v1.3.0
Published by spyoungtech over 1 year ago
Full Changelog: https://github.com/spyoungtech/ahk/compare/v1.1.3...v1.2.0
Published by spyoungtech over 1 year ago
pre-release testing, from #216
Published by spyoungtech over 1 year ago
pre-release for testing fixes in #213
Published by spyoungtech over 1 year ago
This change fixes a bug that prevents fallback mechanisms from working when the package data cannot be found (which usually happens when freezing/compiling an app). ahk
should now work in more packaging scenarios than it did previously.
Full Changelog: https://github.com/spyoungtech/ahk/compare/v1.1.2...v1.1.3
Published by spyoungtech over 1 year ago
Another candidate release for fixing #201
Published by spyoungtech over 1 year ago
Release candidate testing fix for #201
Published by spyoungtech over 1 year ago
Other bugs squashed:
Full Changelog: https://github.com/spyoungtech/ahk/compare/v1.1.1...v1.1.2
Published by spyoungtech over 1 year ago
Reintroduces the from_pid
and from_mouse_position
methods for Window
/AsyncWindow
Published by spyoungtech over 1 year ago
Full Changelog: https://github.com/spyoungtech/ahk/compare/v1.0.1...v1.1.0
Published by spyoungtech over 1 year ago
Release candidate 2 for v1.1.0
Published by spyoungtech over 1 year ago
Draft release candidate for 1.1.0
Published by spyoungtech over 1 year ago
Resolves a minor bug where the blocking
parameter for key_wait
is ignored.
Also includes documentation changes.
Full Changelog: https://github.com/spyoungtech/ahk/compare/v1.0.0...v1.0.1
Published by spyoungtech over 1 year ago
Post-release to address some packaging issues. Updates readme and fixes the "binary" extra.
Published by spyoungtech over 1 year ago
Version 1.0 is a nearly-complete rewrite of the library, includes a major overhaul of the internals, bringing major improvements (as well as some breaking changes in the public API).
Here are some of the big improvements coming in 1.0
(code samples are preliminary and subject to change)
Previously, hotkeys could only be setup to run AutoHotkey scripts as callbacks. Now, Python callables are supported as callbacks.
from ahk import AHK
def my_callback():
print('Hello callback!')
ahk = AHK()
# when WIN + n is pressed, fire `my_callback`
ahk.add_hotkey('#n', callback=my_callback)
ahk.start_hotkeys() # start the hotkey process thread
ahk.block_forever() # not strictly needed in all scripts -- stops the script from exiting; sleep forever
Now whenever you press your hotkeys, the python callback will fire.
You can also add an exception handler for your callback:
from ahk import AHK
ahk = AHK()
def go_boom():
raise Exception('boom!')
def my_ex_handler(hotkey: str, exception: Exception):
print('exception with callback for hotkey', hotkey, 'Here was the error:', exception)
ahk.add_hotkey('#n', callback=go_boom, ex_handler=my_ex_handler)
Hotstrings can also be added to the hotkey process thread.
In addition to Hotstrings supporting normal AHK string replacements, you can also provide Python callbacks (with optional exception handlers) in response to hotstrings triggering.
from ahk import AHK
ahk = AHK()
def my_callback():
print('hello callback!')
ahk.add_hotstring('btw', 'by the way') # string replacements
ahk.add_hotstring('btw', my_callback) # call python function in response to hotstring
win_
methods are now available and can be called without a Window
objectTitleMatchMode
, CoordMode
, DetectHiddenWindows
now exposed, both as parameters to functions affected by these settings as well as default change via set_
methods e.g., set_title_match_mode
.block_input
is implementedblocking
keyword argument (previously, only select methods could do this)concurrent.futures.Future
object or a asyncio.Task
object (for the Async API), allowing you to more easily get results from nonblocking calls and/or await their completion.Enjoy all the benefits of a completely type-hinted API. Great for type-hinting and validating your own code, as well as just getting the various intellisense/IDE features that typically come with type-hinted code.
This is mostly an internal API change, but it has some impacts on users as well. Mainly, this brings a significant performance boost, stability, and the ability to implement a few more methods that were not possible in the previous execution model.
In v0.13.0, the daemon mode feature was released. Daemon mode uses a single AutoHotkey process to run all of the code (rather than creating a new AutoHotkey process for every method invocation). This is now the default execution model. Additionally, the underlying AutoHotkey code interacts with Python through an explicit messaging protocol, allowing for AutoHotkey to explicitly indicate return types.
run_script
can now alternatively accept a path to an autohotkey script instead of only accepting a literal script as a string.While most of the Public API is the same as in v0, there are some significant changes
HotKey
implementation has been removed and replaced by add_hotkey
. AHK script strings are no longer supported for hotkeys -- only python callbacks are allowed (but your callback can call run_script
if you wish).ActionChain
has been removedblocking
have become keyword-onlysend
/send_input
is slightly different - escaping sequences like `n
, `r
, `t
`,
, and similar are no longer required to be escaped. However, braces and similar sequences still need to be escaped -- e.g., in 0.x you would do ahk.send_input('hello`, world{!}')
-- in 1.x you would do ahk.send_input('hello, world{!}')
find_window[s][_by]
methods no longer use generators. Using list_windows
is recommended instead (which is what is now used by these methods).win.title = 'new title'
) are no longer supported. Use set_
methods (e.g., win.set_title('new title')
instead. Setters are still supported in sync API.await win.title
) are deprecated. Use get_
methods (e.g., await get_title()
) instead. Properties are not deprecated in the sync API.run_script
no longer accepts the deocde
parameter (all output is expected to be in UTF-8) use of Popen
keyword arguments have also been removed.encoding
keyword arguments have been removed. Encoding is now correctly handled for you and expected to be UTF-8 for inputs and outputs.Published by spyoungtech over 1 year ago
Pre-release of v1
Published by spyoungtech almost 2 years ago
Full Changelog: https://github.com/spyoungtech/ahk/compare/v0.14.1...v0.14.2