Using autohotkey.dll with java. (ahkgetvar always returns 1)
Posted: 01 Feb 2020, 06:28
Hello
I'm not sure if this is right place to ask but anyway....
I'm studying how to use autohotkey.dll with java and I encountered a problem when trying to use ahkgetvar command. The command always seems to return value between 1-9.
Does anyone know what I'm doing wrong here?
Here is the java code
and this is what my .ahk looks like
I'm not sure if this is right place to ask but anyway....
I'm studying how to use autohotkey.dll with java and I encountered a problem when trying to use ahkgetvar command. The command always seems to return value between 1-9.
Does anyone know what I'm doing wrong here?
Here is the java code
Code: Select all
public class DllController {
autoHotKeyDll lib;
public interface autoHotKeyDll extends Library {
public void ahkExec(char[] s);
public void ahktextdll(char[] s);
public void AhkThread(String ScriptOrFile);
public void addFile(char[] filepath,char[] runtype);
public String ahkgetvar(char[] varname,char[] getpointer);
public Integer ahkassign (char[] varname,char[] value); //returns integer -1=fail 0=success
public void ahkdll (char[] filename);
public void ahkFunction(char[] functionname);
}
public DllController() {
autoHotKeyDll dll = (autoHotKeyDll) Native.loadLibrary("AutoHotkey", autoHotKeyDll.class);
String fileLoc = System.getProperty("user.dir")+"\\test.ahk";
dll.ahkdll(convert(fileLoc));
Integer a = dll.ahkassign(convert("MyVar"), convert("111"));
String data = dll.ahkgetvar(convert("MyVar"),convert("0"));
System.out.println("value= "+data); //This always returns 1-9
}
and this is what my .ahk looks like
Code: Select all
#Persistent
global MyVar
MyVar:="1234"
message()
{
MsgBox %MyVar%
}