Skip to content

Instantly share code, notes, and snippets.

@lotusirous
Last active May 2, 2017 01:09
Show Gist options
  • Select an option

  • Save lotusirous/12e8b9d5ce1c4202b4905adcd78dc2cf to your computer and use it in GitHub Desktop.

Select an option

Save lotusirous/12e8b9d5ce1c4202b4905adcd78dc2cf to your computer and use it in GitHub Desktop.
JavaScript auto click
var robot = require("robotjs");
var mouse = robot.getMousePos();
function click(loc){
var mouse = robot.getMousePos();
robot.moveMouse(loc.x,loc.y);
//Left click!
robot.mouseClick();
}
function click_next(){
// x:1766 y:891
var next_loc = {"x" :"1766", "y":"891"};
console.log('click next');
click(next_loc);
}
function get_color(loc) {
var mouse = robot.getMousePos();
var hex_color = robot.getPixelColor(loc.x, loc.y);
return hex_color;
}
var work = function(){
var is_end = {"x":"1788", "y":"864"};
var end_color = get_color(is_end);
// console.log(end_color)
if (end_color == '0086d3'){
click_next();
}
else{
console.log('playing...');
}
// console.log("#" + hex_color + " at x:" + mouse.x + " y:" + mouse.y);
}
//
// setInterval(is_end_video, 3000);
setInterval(work, 3000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment