2022-02-10 01:45:25 +00:00
|
|
|
////////////////////////////////////////////////////////////////////////
|
|
|
|
// AutoIt (AutoIt3, AutoItX) API
|
|
|
|
////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
function AutoItObject() {
|
|
|
|
this.interface = null;
|
|
|
|
|
|
|
|
this.create = function() {
|
2022-02-10 03:09:52 +00:00
|
|
|
try {
|
|
|
|
this.interface = CreateObject("AutoItX3.Control");
|
|
|
|
} catch (e) {
|
|
|
|
console.error("AutoIt_CreateObject() ->", e.message);
|
|
|
|
}
|
2022-02-10 01:45:25 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
this.execScript = function(scriptName) {
|
2022-02-10 03:09:52 +00:00
|
|
|
var result = null;
|
|
|
|
|
|
|
|
var cmd = [
|
|
|
|
"%PROGRAMFILES(X86)%\\AutoIt3\\AutoIt3.exe",
|
|
|
|
scriptName + ".au3"
|
|
|
|
];
|
|
|
|
|
|
|
|
if (typeof args !== "undefined") {
|
|
|
|
cmd = cmd.concat(args);
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
|
|
result = SHELL.exec(cmd);
|
|
|
|
} catch (e) {
|
|
|
|
console.error("AutoIt_execScript() ->", e.message);
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
2022-02-10 01:45:25 +00:00
|
|
|
};
|
2022-02-10 03:09:52 +00:00
|
|
|
|
|
|
|
this.callFunction = function(functionName, args) {
|
|
|
|
console.log("Calling AutoItX function...", functionName);
|
|
|
|
|
2022-02-10 01:45:25 +00:00
|
|
|
if (this.interface != null) {
|
2022-02-10 03:09:52 +00:00
|
|
|
try {
|
2022-02-10 03:42:11 +00:00
|
|
|
//this.interface[functionName].apply(null, args);
|
2022-02-10 03:09:52 +00:00
|
|
|
eval("this.interface." + functionName + "(\"" + args.map(addslashes).join("\", \"") + "\")");
|
2022-02-10 08:22:35 +00:00
|
|
|
sleep(300);
|
2022-02-10 03:09:52 +00:00
|
|
|
} catch (e) {
|
|
|
|
console.error("AutoItObject.callFunction() ->", e.message);
|
|
|
|
}
|
2022-02-10 01:45:25 +00:00
|
|
|
} else {
|
|
|
|
console.warn("AutoItX is disabled");
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2022-02-10 03:09:52 +00:00
|
|
|
this.create();
|
2022-02-10 01:45:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
exports.create = function() {
|
|
|
|
return new AutoItObject();
|
2022-02-10 03:09:52 +00:00
|
|
|
};
|