ahk.ahkgetvar always returns a pointer?
kitsu opened this issue · 3 comments
From Python I try:
>>> import ctypes
>>> ahk = ctypes.cdll.AutoHotKey
>>> ahk.ahktextdll("","","")
816
>>> ahk.ahkassign("test","5")
0
>>> ahk.ahkgetvar("test",0) # As value
39321392
>>> ahk.ahkgetvar("test",1) # As pointer
39321392 # Same value either way
>>> ctypes.cast(int(ahk.ahkgetvar("test", 0)), ctypes.POINTER(ctypes.c_char))
<ctypes.LP_c_char object at 0x01EC7B20>
>>> ans = _ # Result of last operation is stored in a variable named "_"
>>> ans[0]
'5'
I expect ahkgetvar to return the value not a pointer, am I wrong?
Using Version 1.1.8.1 AutoHotkey_H ANSI 32-bit (on winXP64, Python2.7 32bit).
Thanks a ton for building this though, it's very helpful!
ahkgetvar returns always a pointer to a string similar to ahkFunction.
ahk.ahkgetvar("test", 1) is only required for LowLevel functions like Alias().
from ctypes import *
ahk = cdll.AutoHotKey
ahk.ahktextdll("","","")
ahk.ahkassign("test","5")
print str(cast(ahk.ahkgetvar("test", 0), c_char_p).value)
Hello HotKeyIt,
Seems like
print str(cast(ahk.ahkgetvar("test", 0), c_char_p).value)
throwing an error. Can you share me the working code for new version.
Python version 3.7
AutoHotkey.dll version 1.1.09.01
Are you using ANSI? Otherwise you will need c_wchar_p.
Also what error do you get?