更新时间:2023-11-11 20:19:58
使用 Apple 脚本编辑器打开终端并运行您的代码.
Use Apple Script Editor to open Terminal and run your code.
例如:
String action1 = jsonDriver.readApplicationDetails("OFF");
Runtime runtime = Runtime.getRuntime();
String applescriptCommand = "tell application \"Terminal\"\n" +
"activate\n" + "delay 1\n" + "tell application \"System Events\"\n" +
"keystroke \"" + action1 + "\"\n" + "end tell\n" + "end tell";
String[] args1 = { "osascript", "-e", applescriptCommand };
Process process = runtime.exec(args1);
Thread.sleep(5000);