Hello,
Im trying to create a woodcutting script and am having an issue where the mouse continually clicks on the trees. I think it may be an issue with waitForPixelShift function but Im not entirely sure.
Here is the waitForPixelShift function Im using:
Code:
function waitForPixelShift(amount, timeOut: Integer; box: TBox): Boolean;
var
x1, y1, BMP, BMP2, tempShift: Integer;
t: Timer;
begin
result := false;
t.start();
BMP := bitmapFromClient(box.x1, box.y1, box.x2, box.y2);
repeat
if (t.timeElapsed() >= timeOut) then
break;
sleep(250);
BMP2 := bitmapFromClient(box.x1, box.y1, box.x2, box.y2);
tempShift := calculatePixelShift(BMP, BMP2, IntToBox(0,0,(box.x2 - box.x1),(box.y2-box.y1)));
if (calculatePixelShift(BMP, BMP2, IntToBox(0,0,(box.x2 - box.x1),(box.y2-box.y1))) >= amount) then
result := true;
freeBitmap(BMP2);
until (Result);
if (Result) then
writeln(toStr(tempShift) + ' pixels (amount: ' + toStr(amount) + ') changed after: ' + toString(t.timeElapsed()) + ' result: true')
else
writeln('less than ' + toString(amount) + ' pixels changed after: ' + toStr(timeOut) + ' (timeout) result: false');
freeBitmap(BMP);
end;
And here is where I use it:
Code:
function getState(): Integer;
begin
if (getTimeRunning >= breakAfterTime) and (USEBREAKS) then
exit(8);
if (not isLoggedIn()) then
exit(0);
if ((getCurrentTab <> TAB_INV) and (not isBankOpen())) then
exit(1);
if (getInvCount() = 28) then
exit(5);
if ((not waitForPixelShift(10, 2500, intToBox(MIX1, MIY1, MIX2, MIY2)))) then
exit(3);
inc(bowsMade);
exit(4);
end;
procedure executeState(State: Integer);
begin
case (State) of
0: setupPlayer();
1: gameTab(TAB_INV);
3: cuttrees();
4: antiban();
5: droptrees();
8: breakHandlerCustom();
end;
stats_Commit();
progress();
sleep(random(150, 200));
end;
I've tried using different wait times and number of pixels but it keeps returning a false value, and proceeds to click on the tree. Any suggestions?