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: 2364
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: 2364
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: 6222
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
KusochekDobra
Posts: 38
Joined: 25 Apr 2016, 18:00

Re: How to combine autohotkey dll with Python?

05 Nov 2019, 10:53

Hello everyone!
I learn equal question and after reading some examples from HotkeyIt and other, i has come to this result:

After start, script show MsgBox with "400" then i click to "Ok" and script terminate the process with exit code "-1073740940 (0xC0000374)" and do not a print a "Done" to console.
Image
Sorry for image, forum block me when i try write this code.
Use env:
Win 10 x64
AHK.DLL x64w from this
Python 3.7.5 x64

Please help me get a new experience. 8-)
KusochekDobra
Posts: 38
Joined: 25 Apr 2016, 18:00

Re: How to combine autohotkey dll with Python?

06 Nov 2019, 07:00

I figured out how it work. Need pause before end of script and no need call "ahkExec()".

Return to “AutoHotkey_H”

Who is online

Users browsing this forum: No registered users and 21 guests