diff --git a/lib/virtualinput.js b/lib/virtualinput.js new file mode 100644 index 0000000..94c744a --- /dev/null +++ b/lib/virtualinput.js @@ -0,0 +1,31 @@ +////////////////////////////////////////////////////////////////////////////////// +// VirtualInput API +///////////////////////////////////////////////////////////////////////////////// + +var VirtualInputObject = function() { + this.oShell = null; + this.oAutoIt = null; + + this.create = function() { + try { + this.oShell = CreateObject("WScript.Shell"); + this.oAutoIt = CreateObject("AutoItX.Control"); + } catch (e) { + console.error("VirtualInputObject.create() -> " + e.message); + } + ); + + this.moveMouse = function(x, y) { + this.oAutoIt.MouseMove(x, y); + }; + + this.sendKeys = function(s) { + this.oShell.SendKeys(s); + }; + + this.create(); +}; + +exports.create = function() { + return (new VirtualInputObject()).create(); +};