How to combine autohotkey dll with Python?

Post AHK_H specific scripts & libraries and discuss the usage and development of HotKeyIt's fork/branch
bsayles
Posts: 3
Joined: 31 May 2019, 22:01

How to combine autohotkey dll with Python?

31 May 2019, 22:08

I'm new to writing hotkeys through Autohotkey dll. I've been trying to combine autohotkey dll with Python's ahk module. But every time I write hotkeys, I get various errors. Do you have an example or tutorial on how the code for keyboard hotkeys is suppose to work through autohotkey dll? Thanks for your help.


[Mod edit: Topic name added]
HotKeyIt
Posts: 1870
Joined: 29 Sep 2013, 18:35
Contact:

Re: How to combine autohotkey dll with Python?

01 Jun 2019, 06:35

It is the same as in AutoHotkey.exe.
Can you show your examples and what errors do you get?
bsayles
Posts: 3
Joined: 31 May 2019, 22:01

Re: How to combine autohotkey dll with Python?

01 Jun 2019, 15:07

ahk = AHK(executable_path = r'C:\Users\bryan\AppData\Local\Programs\Python\Python37-32\ahkdll-v2-release-master\x64w_MT\AutoHotkey.dll')

def hotkeys ():
if ahk.key_press('Control', 'Shift', 'z'):
ahk.execute(ahk.key_press('m'))

elif ahk.key_press('Control', 'Shift', 'x'):
ahk.execute(ahk.key_press('f'))

elif ahk.key_press('Control', 'Shift', 'c'):
ahk.execute(ahk.key_press('u'))

It's always syntax errors. i know that that usually means I missed something on the lines before it, but I fixed those errors and I'm still getting the syntax error. Any idea what is wrong? I've tried to do it with the autohotkey.exe but neither seems to work. Thanks for your help.
HotKeyIt
Posts: 1870
Joined: 29 Sep 2013, 18:35
Contact:

Re: How to combine autohotkey dll with Python?

01 Jun 2019, 18:10

Where did you get that code from?
CAn you link to the py library you are using.
bsayles
Posts: 3
Joined: 31 May 2019, 22:01

Re: How to combine autohotkey dll with Python?

01 Jun 2019, 19:55

sure. the py module I'm using is from ahk import AHK. It's in Python 3. How should this be written? I'm new to AHK. Thanks for your help.
swagfag
Posts: 2922
Joined: 11 Jan 2017, 17:59

Re: How to combine autohotkey dll with Python?

01 Jun 2019, 20:25

https://github.com/spyoungtech/ahk
all this lib can do is write out a temp ahk file and run it. it doesnt interface with ahk.dll or anything

what u need is to find ur python equivalent of https://docs.microsoft.com/en-us/windows/desktop/api/libloaderapi/nf-libloaderapi-loadlibrarya and https://docs.microsoft.com/en-us/windows/desktop/api/libloaderapi/nf-libloaderapi-getprocaddress
get some function pointers to the thread functions https://hotkeyit.github.io/v2/docs/commands/AhkThread.htm
write ur ahk script with ahk functions in a string and launch the string as a new thread

Return to “AutoHotkey_H”

Who is online

Users browsing this forum: No registered users and 5 guests