Created
July 31, 2015 22:46
-
-
Save CodeBrauer/6e6624d8234a5642c2d3 to your computer and use it in GitHub Desktop.
just a simple demo for a ajax-usage of robotjs - allows to set the mouse position on a simple request like this: http://localhost:4000/movemouse/200/50
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var sys = require('sys'); | |
| var http = require('http'); | |
| var robot = require('robotjs'); | |
| console.log('Starting...'); | |
| http.createServer(function(request, response) { | |
| result = 0; | |
| if (request.method === 'GET') { | |
| requestEndpoint = request.url.split('/'); | |
| if ( | |
| requestEndpoint[1] === 'movemouse' | |
| && typeof requestEndpoint[2] !== 'undefined' | |
| && typeof requestEndpoint[3] !== 'undefined' | |
| ) { | |
| result = robot.moveMouse(parseInt(requestEndpoint[2]), parseInt(requestEndpoint[3])); | |
| console.log('moved mouse to: x: ' + requestEndpoint[2] + ', y:' + requestEndpoint[3]); | |
| } | |
| } | |
| response.writeHeader(200, {'Content-Type:' : 'application/javascript'}) | |
| response.write(JSON.stringify({'success' : (parseInt(result) != 0 ? true : false) })); | |
| response.end(); | |
| }).listen(4000); | |
| console.log('Server running on port 4000'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment