Skip to content

Releases: spyoungtech/ahk

v1.0.0

02 May 04:43
23139b7
Compare
Choose a tag to compare

V1

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).

Major features/improvements

Here are some of the big improvements coming in 1.0
(code samples are preliminary and subject to change)

Python callbacks for hotkeys

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 are now supported

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

More of the AutoHotkey API is available

  • Support for controls is added
  • win_ methods are now available and can be called without a Window object
  • TitleMatchMode, 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.
  • clipboard support is added
  • block_input is implemented

Improvements for 'Nonblocking' API

  • Virtually all methods that call into AutoHotkey now support the blocking keyword argument (previously, only select methods could do this)
  • Nonblocking functionality is now supported in the Async API
  • Instead of returning a process object, nonblocking calls now return a 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.

Fully type-hinted API (PEP 561 compliant)

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.

AutoHotkey process is now run as a daemon for performance

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.

Other minor improvements

  • run_script can now alternatively accept a path to an autohotkey script instead of only accepting a literal script as a string.

Deprecations and Breaking Changes

While most of the Public API is the same as in v0, there are some significant changes

  • Support for Python 3.6 - 3.7 is dropped. The new minimum Python version is 3.8
  • Original 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 removed
  • For clarity, many parameters like blocking have become keyword-only
  • The behavior of send/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).
  • In the async API, property setters (e.g., 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.
  • In the async API, property getters (e.g., 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.
  • All encoding keyword arguments have been removed. Encoding is now correctly handled for you and expected to be UTF-8 for inputs and outputs.

v1.0.0b

02 May 04:34
28fb128
Compare
Choose a tag to compare
v1.0.0b Pre-release
Pre-release

Pre-release of v1

v0.14.2

12 Nov 21:32
7988c13
Compare
Choose a tag to compare

What's Changed

Full Changelog: v0.14.1...v0.14.2

v0.14.1

13 Jul 06:44
d84f9c9
Compare
Choose a tag to compare

What's Changed

Getting non-ascii output should now be more reliable

Full Changelog: v0.14.0...v0.14.1

v0.14.0

15 Jun 18:40
60e01d7
Compare
Choose a tag to compare

What's Changed

This release has some potential breaking changes, as the API for win_get and (async) find_window have changed slightly.

New Contributors

Full Changelog: v0.13.0...v0.14.0

v0.13.0

13 Oct 04:31
197bb9e
Compare
Choose a tag to compare

v0.13.0

Major new feature is Daemon Mode #111 which is now available as a preview/experimental feature.

Several fixes for Async API and other bug fixes are also included in this release

v0.12.0

07 Jan 16:17
c25725e
Compare
Choose a tag to compare

Adds base asyncio support.

While the existing user-facing APIs remains mostly untouched, there are some significant and potentially breaking changes in this version:

  • Default parameter of blocking for a couple functions is changed from False to True
  • Internal API has shifted around quite a bit. Template generation and script running have been split in all (or most) methods
  • Typos in classes and modules were corrected (registry.py and RegistryMixin)

v0.11.1

17 Sep 21:09
0bc74f5
Compare
Choose a tag to compare

Adds support for adding directives to all scripts

v0.11.0

17 Sep 20:05
e1183c8
Compare
Choose a tag to compare

Adds fixes for key state

Adds set_capslock_state

Other improvements

v0.10.0

07 Sep 13:17
126c2e8
Compare
Choose a tag to compare
  • Adds tooltip/traytip GUI functionality (Thanks @yedhrab for this contribution)

  • Renames registry methods (read/write/delete/set_view, etc now raise a deprecation warning, suggesting to use new names: reg_read/reg_write/reg_delete etc)

  • Fixes a bug (#96) where using an equal sign breaks type/sendraw