2024-07-10 10:46:30 +00:00
|
|
|
// autoit.js
|
|
|
|
// AutoIt (AutoIt3, AutoItX) API interface for WelsonJS framework
|
|
|
|
// Namhyeon Go (Catswords Research) <abuse@catswords.net>
|
|
|
|
// https://github.com/gnh1201/welsonjs
|
2022-02-10 01:45:25 +00:00
|
|
|
function AutoItObject() {
|
2024-07-10 10:46:30 +00:00
|
|
|
this._interface = null;
|
2022-02-10 01:45:25 +00:00
|
|
|
|
|
|
|
this.create = function() {
|
2022-02-10 03:09:52 +00:00
|
|
|
try {
|
2024-07-10 10:46:30 +00:00
|
|
|
this._interface = CreateObject("AutoItX3.Control");
|
2022-02-10 03:09:52 +00:00
|
|
|
} 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);
|
|
|
|
|
2024-07-10 10:46:30 +00:00
|
|
|
if (this._interface != null) {
|
2022-02-10 03:09:52 +00:00
|
|
|
try {
|
2024-07-10 10:46:30 +00:00
|
|
|
//this._interface[functionName].apply(null, args);
|
|
|
|
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");
|
|
|
|
}
|
|
|
|
};
|
2024-09-20 07:53:50 +00:00
|
|
|
|
|
|
|
this.mouseMove = function(x ,y) {
|
|
|
|
this.callFunction("MouseMove", [x, y]);
|
|
|
|
};
|
|
|
|
|
|
|
|
this.mouseClick = function(_button) {
|
|
|
|
this.callFunction("MouseClick", [_button]);
|
|
|
|
};
|
|
|
|
|
|
|
|
this.send = function(keys) {
|
|
|
|
this.callFunction("Send", [keys]);
|
|
|
|
};
|
2022-02-10 01:45:25 +00:00
|
|
|
|
2022-02-10 03:09:52 +00:00
|
|
|
this.create();
|
2022-02-10 01:45:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
exports.create = function() {
|
|
|
|
return new AutoItObject();
|
2024-07-10 10:47:24 +00:00
|
|
|
};
|
|
|
|
|
2024-09-20 07:53:50 +00:00
|
|
|
exports.VERSIONINFO = "AutoItX API interface version 0.1.4";
|
2024-07-10 10:47:24 +00:00
|
|
|
exports.global = global;
|
|
|
|
exports.require = global.require;
|