Let's throw Python into the mix

Discuss other programming languages besides AutoHotkey
Posts: 176
Joined: 08 Sep 2014, 07:06

Let's throw Python into the mix

10 Nov 2016, 20:43

Okay, I know my timing couldn't be worse (with all the other posts right now about comparing other languages to AHK, and accessing AHK functionality from other languages), but I've been wondering about it for awhile: is there a way to use some of AHK's stuff in Python? I'm especially interested in:
- Sending keystrokes / mouse clicks (including settings like CoordMode, SendMode and KeyDelay)
- ImageSearch

It seems there are several options:
- Use the old AHK (AHK_H) and AutoHotkey.dll
- Write AHK scripts that do these things, accepting command-line parameters for what keys to send or where to search, and output the results to standard output, and call those from Python
- Dive into Win32 for hotkeys and some other API for images to cook up my own version (last resort, but I wouldn't be completely in over my head)
- Dive into the AHK source and rework it as a DLL ("last last resort"! lol)

But none of these sound that great, which is why I'm here. But I'm sure I'm not the first guy to ask this, so I'd sure appreciate your two cents on the subject. Thanks.
User avatar
Posts: 285
Joined: 07 Oct 2013, 04:05
GitHub: hoppfrosch
Location: Rhine-Maine-Area, Hesse, Germany

Re: Let's throw Python into the mix

11 Nov 2016, 00:47

You're wrong on "old AHK" and "AHK_H":
* "old" AHK is also called "Vanilla AHK" and is really the old 1.0.48(?) version (or below) of AHK
* AHK_H is a fork of AutoHotkey and adds functionality to original AutoHotkey and offers true multi-threading using NewThread() function or AutoHotkey.dll. It's based on the most recent version of AutoHotkey (Version ATM). It always merges the latest changes from AHK to keep up to date with most recent AHK.

So AHK_H is the option you're looking for.

There's already a project integrating Python and AHK_H: https://pyahk.readthedocs.io/en/latest/ (https://bitbucket.org/kitsu/pyahk/overview) - but I've never tested it ...
Posts: 176
Joined: 08 Sep 2014, 07:06

Re: Let's throw Python into the mix

11 Nov 2016, 01:29

Hey, this is awesome news! Guess it pays to be wrong sometimes :lol:

Yeah, I was totally confusing "AHK_H" with the 1.0.48ish version that you called "Vanilla" AHK - I had no idea they AHK_H was something else, especially since someone on another post kinda made them sound like the same thing. I've already seen PyAHK, and it looks like it's not compatible with my version of Python - but that's no big deal, cuz I can just downloadautohotkey.dll and call its functions using ctypes. So thanks for the info! :)

EDIT: I looked up AHK_H and found its main site, autohotkey.net, is supposedly a security risk. Both Firefox and Chrome blocked it - so is this really the correct site? I mean sure, it could be something simple (like there's probably a link to download a DLL), but it seems weird that both Google and Mozilla have flagged it. A bit more Googling led to this site:
which says autohotkey.net is okey...?
just me
Posts: 4685
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Let's throw Python into the mix

11 Nov 2016, 02:38

Remaining with AHK until v2 will become beta.
Posts: 176
Joined: 08 Sep 2014, 07:06

Re: Let's throw Python into the mix

11 Nov 2016, 03:20

Geeze... I tried downloading it from this site and my antivirus program flagged it! I don't know what this thing does that's got everyone on red alert, but this github page looks a lot more official and up-to-date than autohotkey.net so I think I'm ok. Thanks for the link.

Return to “Other Programming Languages”

Who is online

Users browsing this forum: No registered users and 1 guest