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]
How to combine autohotkey dll with Python?
Re: How to combine autohotkey dll with Python?
It is the same as in AutoHotkey.exe.
Can you show your examples and what errors do you get?
Can you show your examples and what errors do you get?
Re: How to combine autohotkey dll with Python?
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.
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.
Re: How to combine autohotkey dll with Python?
Where did you get that code from?
CAn you link to the py library you are using.
CAn you link to the py library you are using.
Re: How to combine autohotkey dll with Python?
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.
Re: How to combine autohotkey dll with Python?
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
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
-
- Posts: 38
- Joined: 25 Apr 2016, 18:00
Re: How to combine autohotkey dll with Python?
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.
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.
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.
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.
-
- Posts: 38
- Joined: 25 Apr 2016, 18:00
Re: How to combine autohotkey dll with Python?
I figured out how it work. Need pause before end of script and no need call "ahkExec()".
Who is online
Users browsing this forum: No registered users and 31 guests