welsonjs/lib/autoit.js
Namhyeon, Go e7f65d50b0
Some checks failed
CodeQL / Analyze (csharp) (push) Has been cancelled
CodeQL / Analyze (javascript) (push) Has been cancelled
CodeQL / Analyze (python) (push) Has been cancelled
Update ScreenMatch.cs and related files
2024-09-20 16:53:50 +09:00

75 lines
2.0 KiB
JavaScript

// autoit.js
// AutoIt (AutoIt3, AutoItX) API interface for WelsonJS framework
// Namhyeon Go (Catswords Research) <abuse@catswords.net>
// https://github.com/gnh1201/welsonjs
function AutoItObject() {
this._interface = null;
this.create = function() {
try {
this._interface = CreateObject("AutoItX3.Control");
} catch (e) {
console.error("AutoIt_CreateObject() ->", e.message);
}
};
this.execScript = function(scriptName) {
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;
};
this.callFunction = function(functionName, args) {
console.log("Calling AutoItX function...", functionName);
if (this._interface != null) {
try {
//this._interface[functionName].apply(null, args);
eval("this._interface." + functionName + "(\"" + args.map(addslashes).join("\", \"") + "\")");
sleep(300);
} catch (e) {
console.error("AutoItObject.callFunction() ->", e.message);
}
} else {
console.warn("AutoItX is disabled");
}
};
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]);
};
this.create();
}
exports.create = function() {
return new AutoItObject();
};
exports.VERSIONINFO = "AutoItX API interface version 0.1.4";
exports.global = global;
exports.require = global.require;