Skip to content

Instantly share code, notes, and snippets.

@brigand
Created December 28, 2011 06:26
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save brigand/1526712 to your computer and use it in GitHub Desktop.
Save brigand/1526712 to your computer and use it in GitHub Desktop.
Using AutoHotkey in a Java program
// All depends can be found here: http://apps.aboutscript.com/jhk/JHK.zip
// Video: http://youtu.be/EX0iT0NTTjw
import com.eaio.nativecall.*;
public class AutoHotkeyTest {
private static IntCall exec;
public static void main(String[] args) {
System.out.println("Hello World");
try {
NativeCall.init();
init();
} catch (Throwable t) {
System.out.println("\n" + "Something went wrong...");
System.out.println(t);
}
ahk("Run Calc");
System.out.println("This is the good part!");
ahk("\n Sleep 1000\n SendInput 1{+}1{Enter}");
System.out.println("Woo!");
ahk("Sleep 3000\n WinClose Calc");
}
public static void init() {
IntCall textdll = new IntCall("AutoHotkey.dll", "ahktextdll");
textdll.executeCall(new Object[]{"","",""});
exec = new IntCall("AutoHotkey.dll", "ahkExec");
}
public static void ahk(String code) {
exec.executeCall(code);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment