Using Ahk File/Lib
xfeyz opened this issue · 4 comments
Hello there, is it possible to import a custom library/ahk file into the python code and use the ahk functions in the python code? I'm asking for an Ahk v2 file.
Thanks
Yes, and no. It is possible to add custom AHK code to the library and use them through Python functions. An official interface for this is being added in #232 -- some workarounds for current versions of the library have been discussed in #228
However, this is currently limited to AHK v1 code. Support for AHK v2 will come in the future, but it's going to be quite a large effort and there's currently no estimate of when v2 support will be available.
Beyond this, it is also possible to run arbitrary AHK code via the .run_script
method. You could write your own Python methods that call run_script
. It may be possible in the short-term to add the ability to run v2 code via this style of interface.
Alright thanks.. but doesn't the run_script function runs the whole AHK script added in the python code? What if the library is very long?
https://www.autohotkey.com/boards/viewtopic.php?t=116471
This is the AHK Library I'm planing to use.
Based on the forum post, it sounds like this is just a V2 version of a script that already exists for V1:
This is the V2 version of FindText, which is synchronized with the V1 version
So you should be able to use the V1 version in the way described in other discussions or with the upcoming extension system.
What if the library is very long?
The length of the library shouldn't matter much. You can also pass filenames to run_script
to run scripts from a file.
Extension authoring is now the supported way to add additional functionality. You can also distribute extensions on PyPI, if you wanted.