node-key-sender
Advanced tools
Comparing version 1.0.3 to 1.0.4
@@ -49,11 +49,11 @@ var exec = require('child_process').exec; | ||
module.sendKey = function(keyCode) { | ||
module.execute([keyCode]); | ||
return module.execute([keyCode]); | ||
}; | ||
module.sendKeys = function(arrKeyCodes) { | ||
module.execute(arrKeyCodes); | ||
return module.execute(arrKeyCodes); | ||
}; | ||
module.sendLetter = function(letter) { | ||
module.sendKey(module.getKeyCode(letter)); | ||
return module.sendKey(module.getKeyCode(letter)); | ||
}; | ||
@@ -68,3 +68,3 @@ | ||
module.sendKey(arrKeyCodes); | ||
return module.sendKey(arrKeyCodes); | ||
}; | ||
@@ -82,3 +82,3 @@ | ||
module.execute(keyCodes); | ||
return module.execute(keyCodes); | ||
}; | ||
@@ -97,12 +97,20 @@ | ||
module.sendCombination = function(arrKeyCodes) { | ||
module.execute([arrKeyCodes.join('-')]); | ||
return module.execute([arrKeyCodes.join('-')]); | ||
}; | ||
module.execute = function(arrParams) { | ||
var jarPath = path.join(__dirname, 'jar', 'key-sender.jar'); | ||
return new Promise(function(resolve, reject) { | ||
var jarPath = path.join(__dirname, 'jar', 'key-sender.jar'); | ||
var command = 'java -jar ' + jarPath + ' ' + arrParams.join(' '); | ||
console.log('Sending: ' + command); | ||
var command = 'java -jar ' + jarPath + ' ' + arrParams.join(' '); | ||
console.log('Sending: ' + command); | ||
exec(command); | ||
return exec(command, {}, function(error, stdout, stderr) { | ||
if (error == null) { | ||
resolve(stdout, stderr); | ||
} else { | ||
reject(error, stdout, stderr); | ||
} | ||
}); | ||
}); | ||
}; | ||
@@ -109,0 +117,0 @@ |
{ | ||
"name": "node-key-sender", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "Lib to send keystrokes to the operation system.", | ||
@@ -5,0 +5,0 @@ "main": "key-sender.js", |
74462
103