Compare commits

..

No commits in common. "57f3767d57fbac0fe90c069df32c82a9ecb6b307" and "8798d7b2a7862c3688cfa1f97d345324fce5b71a" have entirely different histories.

6 changed files with 17 additions and 34 deletions

View File

@ -3,10 +3,7 @@
A bot for eat drywall probably idk.
Setup with `start setup.bat`.
Run with `python start.py`.
Press "q" anywhere to quit.
Run with `node main`.
Configure in "config.jsonc".

View File

@ -6,6 +6,6 @@ x = int(sys.argv[1])
y = int(sys.argv[2])
print("\n" + str(x) + str(y) + "\n")
pyautogui.moveTo(x,y, .1)
pydirectinput.moveTo(x,y)
pyautogui.click(clicks=4, interval=.1)
pyautogui.moveTo(x,y, .3)
pydirectinput.moveTo(x,y, .3)
pyautogui.click(clicks=2, interval=.35)

View File

@ -1,5 +1,4 @@
{
"iterationsPerPhoto": 6,
"photoInterval": 2,
"targetColor": {
"r": 85,
@ -7,5 +6,5 @@
"b": 49,
"a": 255
},
"tolerance": 20
"tolerance": 2
}

17
main.js
View File

@ -3,7 +3,6 @@ const ss = require("node-screenshots");
const proc = require("child_process");
const fs = require("fs");
let config = JSON.parse(fs.readFileSync("./config.jsonc"));
const photoInterval = config.photoInterval;
@ -12,13 +11,22 @@ const targetColor = config.targetColor;
const tolerance = config.tolerance;
const iterationsPerPhoto = config.iterationsPerPhoto;
setInterval(eatDrywall, photoInterval * 1000);
var readline = require('readline');
readline.emitKeypressEvents(process.stdin);
if (process.stdin.isTTY)
process.stdin.setRawMode(true);
process.stdin.on('keypress', (chunk, key) => {
if (key && key.name == 'q')
process.exit();
});
async function eatDrywall() {
@ -45,7 +53,7 @@ function clickRandomPixelOfColor(width, height, image) {
}
console.log(hits.length);
clickRandomDrywalls(hits, width, iterationsPerPhoto);
clickRandomDrywalls(hits,width,1);
}
@ -57,7 +65,7 @@ async function clickRandomDrywalls(hits, width, repetitions) {
let target = deRasterize(hits[click], width);//get coordinates of random pixel
console.log("Clicking: " + JSON.stringify(target));
console.log(proc.exec("python click.py " + target.x + " " + target.y).toString());
await new Promise(resolve => setTimeout(resolve, 200));
await new Promise(resolve => setTimeout(resolve, 300));
}
}
function rasterize(x, y, width) { //scale to image
@ -76,7 +84,6 @@ function compareColors(c1, c2) { //compare two rgba color structs
let sum2 = c2.r + c2.g + c2.b + c2.a;
if (Math.abs(sum1 - sum2) < (tolerance * 4)) {
//console.log(Math.abs(sum1 - sum2));
return true;
} else return false;
}

View File

@ -1,5 +1,4 @@
python -m ensurepip
pip install pyautogui
pip install PyDirectInput
pip install keyboard
npm i

View File

@ -1,19 +0,0 @@
import subprocess
import keyboard
#async def subp():
proc = subprocess.Popen("node main")
#asyncio.run(subp())
while True:
try:
if keyboard.is_pressed('q'):
proc.kill()
exit()
except:
print("q")
proc.kill()
exit()