|
const robot = require("robotjs"); |
|
|
|
|
|
function getPixelColor(x, y) { |
|
return robot.getPixelColor(x, y); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function isColorInRange(color, minColor, maxColor) { |
|
const intColor = parseInt(color, 16); |
|
const intMinColor = parseInt(minColor, 16); |
|
const intMaxColor = parseInt(maxColor, 16); |
|
return intColor >= intMinColor && intColor <= intMaxColor; |
|
} |
|
|
|
|
|
const minColor = "ffc500"; |
|
const maxColor = "ffdf0f"; |
|
|
|
|
|
function pressKeyJ() { |
|
robot.keyTap("j"); |
|
} |
|
|
|
|
|
function pressKeyD() { |
|
robot.keyToggle("d", "down"); |
|
setTimeout(() => robot.keyToggle("d", "up"), 10); |
|
} |
|
|
|
|
|
function pressKeyF() { |
|
robot.keyToggle("f", "down"); |
|
setTimeout(() => robot.keyToggle("f", "up"), 10); |
|
} |
|
|
|
|
|
function pressKeyK() { |
|
robot.keyTap("k"); |
|
} |
|
|
|
|
|
async function checkPixelColor() { |
|
try { |
|
const inicio = performance.now(); |
|
|
|
const color = getPixelColor(635, 365); |
|
|
|
|
|
if (color === "f84828") { |
|
|
|
pressKeyJ(); |
|
} else if (color === "68c0c0") { |
|
|
|
pressKeyK(); |
|
} else if (color === "f8b800") { |
|
|
|
robot.keyTap("b"); |
|
while (getPixelColor(635, 365) === "f8b800") { |
|
|
|
} robot.keyTap("b"); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
else if (color === "ff7800") { |
|
|
|
robot.keyTap("b"); |
|
|
|
|
|
await sleep(700); |
|
|
|
robot.keyTap("b"); |
|
} |
|
|
|
|
|
|
|
} catch (error) { |
|
console.error("Erro:", error); |
|
} |
|
|
|
setTimeout(checkPixelColor, 10); |
|
} |
|
|
|
|
|
function sleep(ms) { |
|
return new Promise((resolve) => setTimeout(resolve, ms)); |
|
} |
|
|
|
|
|
checkPixelColor(); |
|
|