is there a way to run a script with parameters from java? Not an executable file, but an AutoHotKey script.
I tried this, but since it is not a valid executable file it doesn't work.
Control class :
package org.bsep.acp;
import java.io.IOException;
/**
* This class allow you to send string to your
* computer as keystrokes.
*
* escape car is '
* special char are {space}, {Enter}, {F1}, {F2}, etc
*
* @author Eildosa
*/
public class StringSender {
Runtime runtime;
private final static String AHK_BRIDGE = "C:\\perso\\WorkspaceScripts\\skyrimTools\\src\\org\\bsep\\acp\\ahkBridge.ahk";
public StringSender() {
runtime = Runtime.getRuntime();
}
public void sendString(String data) throws IOException, InterruptedException {
runtime.exec(new String[] { AHK_BRIDGE, data} );
Thread.currentThread();
Thread.sleep(1000);
}
}
Test :
Runtime runtime = Runtime.getRuntime();
runtime.exec(NOTEPAD);
Thread.currentThread();
Thread.sleep(4000);
StringSender stringSender = new StringSender();
stringSender.sendString("Writing from java through AHK.");
Exception :
Exception in thread "main" java.io.IOException: Cannot run program "C:\perso\WorkspaceScripts\skyrimTools\src\org\bsep\acp\ahkBridge.ahk": CreateProcess error=193, %1 n?est pas une application Win32 valid
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1041)
at java.lang.Runtime.exec(Runtime.java:617)
at java.lang.Runtime.exec(Runtime.java:485)
at org.bsep.acp.StringSender.sendString(StringSender.java:25)
at org.bsep.acp.VariousTests.ahkBridgeTester(VariousTests.java:23)
at org.bsep.acp.VariousTests.main(VariousTests.java:13)
Caused by: java.io.IOException: CreateProcess error=193, %1 n?est pas une application Win32 valid
at java.lang.ProcessImpl.create(Native Method)
at java.lang.ProcessImpl.<init>(ProcessImpl.java:376)
at java.lang.ProcessImpl.start(ProcessImpl.java:136)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1022)
... 5 more
Translation : this is not a valid win32 application.
Thanks.
AHK_BRIDGE
anddata
contain? Please post a sufficient amount of code. – MCL