lukas123123 Posted October 21, 2020 Share Posted October 21, 2020 This is my script trying to steal from a "Stall" , the program can't seem to find the "stall" and i don't know why. Ive got the colors right and it should find it within my BITMAP my it wont. function findStall() { var x = 200, y = 170, width = 700, height = 500; var img = robot.screen.capture(x, y, width, height); var size = (700, 500); var img = robot.screen.capture(0, 0, size, size); var multi = img.width / size; ; var stallColors = ["#8e7493", "#424254", "#51093d", "#393946", "#69094e"]; for(var i = 0; i < 1000; i++) { var randomX = getRandomInt(0, width-1); var randomY = getRandomInt(0, height-1); var sampleColor = img.colorAt(200 * multi, 170 * multi); if(stallColors.includes(sampleColor)) { var screenX = randomX + x; var screenY = randomY + y; console.log("found stall: " + screenX + "," + screenY + " color " + sampleColor); return {x: screenX, y: screenY} } } // this is the part where im trying to find the stall using colorpixels and bitmap width and lenght. ------------------------------------------------------------------------------------------ // this is my whole code. // import the robotjs library var robot = require('robotjs'); // hela functionen av programmet function main() { console.log("Starting..."); sleep(4000); var stall = findStall(); if(stall == false) { //om ingen stall hittar break programet console.log('could not find stall'); } // tar från stall och droppar while (true) { robot.moveMouse(stall.x, stall.y); robot.mouseClick(); sleep(3000); dropSilk(); break; } } //function för att droppa silk function dropSilk() { var inventoryX = 950; var inventoryY = 437; robot.moveMouse(inventoryX, inventoryY); robot.mouseClick('right'); robot.moveMouse(inventoryX, inventoryY + 50); robot.mouseClick(); sleep(3000); } function findStall() { var x = 200, y = 170, width = 700, height = 500; var img = robot.screen.capture(x, y, width, height); var size = (700, 500); var img = robot.screen.capture(0, 0, size, size); var multi = img.width / size; ; var stallColors = ["#8e7493", "#424254", "#51093d", "#393946", "#69094e"]; for(var i = 0; i < 1000; i++) { var randomX = getRandomInt(0, width-1); var randomY = getRandomInt(0, height-1); var sampleColor = img.colorAt(200 * multi, 170 * multi); if(stallColors.includes(sampleColor)) { var screenX = randomX + x; var screenY = randomY + y; console.log("found stall: " + screenX + "," + screenY + " color " + sampleColor); return {x: screenX, y: screenY} } } // hittade inte Stall return false; } //sleep funktion används genom att skriva sleep(3000); function sleep(ms) { Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms); } function getRandomInt(min, max) { min = Math.ceil(min); max = Math.floor(max); return Math.floor(Math.random() * (max - min + 1)) + min; } //kör hela programet main(); Quote Link to comment Share on other sites More sharing options...
Medusa Posted October 21, 2020 Share Posted October 21, 2020 (edited) Soooooooooo why not just use the new osbot hwmouse EDIT: just realized that this might've been for an rsps Edited October 21, 2020 by Medusa Quote Link to comment Share on other sites More sharing options...
lukas123123 Posted October 21, 2020 Author Share Posted October 21, 2020 14 minutes ago, Medusa said: Soooooooooo why not just use the new osbot hwmouse EDIT: just realized that this might've been for an rsps Yes, Im trying to make a script for an rsps but do you know the reason why bitmap thing wont work?? Quote Link to comment Share on other sites More sharing options...