Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Would this awesome lib using AutoHotkey.dll? #52

Closed
ClericPy opened this issue Jul 20, 2019 · 1 comment
Closed

Would this awesome lib using AutoHotkey.dll? #52

ClericPy opened this issue Jul 20, 2019 · 1 comment

Comments

@ClericPy
Copy link

dll file can be upload to pypi, and I found an issue while call 64bit AutoHotkey.dll,
will this ahk lib support dll file path arg?

Download URL:
https://github.com/HotKeyIt/ahkdll-v1-release/

python 64-bit: x64w/AutoHotkey.dll or AutoHotkeyMini.dll
python 64-bit: Win32w/AutoHotkey.dll or AutoHotkeyMini.dll

btw, 64-bit dll seems occur an crash while using ahkgetvar

main.py

#! python3
import ctypes
import time
import sys
import pathlib
import typing

dll_file_path = str(
    pathlib.Path(__file__).parent / f'AutoHotkey{sys.hash_info.width}.dll')

ahk_instance = ctypes.cdll.LoadLibrary(dll_file_path)
ahk_instance = ctypes.CDLL(dll_file_path)

ahk_instance.ahktextdll("")

while not ahk_instance.ahkReady():
    time.sleep(0.1)


def goahk(code: str):
    """run source code with autohotkey."""
    return ahk_instance.ahkExec(code)


def getahk(var_name: str):
    """get var value from ahk script by var name"""
    result = ahk_instance.ahkgetvar(var_name, 0)
    result = ctypes.cast(result, ctypes.c_wchar_p)
    return result.value


__all__ = ['goahk', 'getahk']


def test():
    goahk(u'''msgbox Hello World;
var_name=sss
    ''')
    print(getahk('var_name'), flush=1)


if __name__ == "__main__":
    test()

I put the dll file in the dir of main.py
using 32-bit python.exe will run success => show msgbox and print sss
using 32-bit python.exe will run failed=> show msgbox and exited with code=3221225477

sorry for my stupid English grammar...

@ClericPy
Copy link
Author

ok, I will close this issue, autohotkey.exe is the better choice...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant