SRL Archive - OSR Help

Finding a bitmap.


Littma

2011-07-17 09:00:05

I'm currently working on a project that is for a flash game (non-runescape related) which I'd like to find a bitmap in and simply click the bitmap if it's found.

I've tried even the simplest commands as in "FindBitmap" and it seems it clicks on the top left of the targeted screen apposed from the bitmap itself. So it finds the bitmap but the x, y cords are clicking at 0,0/1,1 automatically and I'm not sure what I'm doing wrong. I've tried searching for a tutorial on bitmaps but no luck. Any tips?

Goal: To have the script find a bitmap in a procedure and if it's found to simply click on the bitmap wherever that may be on the targeted screen.

Thanks in advance,
Littma.

Shuttleu

2011-07-17 09:46:21

then it must not be finding the bitmap

try putting the FindBitmap procedure inside Writeln();
then see if it says true or false in the debug, if it says false then it did not find the bitmap and there is your problem

~shut

Littma

2011-07-17 10:02:53

From: Shuttleu
then it must not be finding the bitmap

try putting the FindBitmap procedure inside Writeln();
then see if it says true or false in the debug, if it says false then it did not find the bitmap and there is your problem

~shut


Thanks, though I'm trying something out and it seems to work but it's quite buggy right now and I'd like some advice on why it's not working properly.

program zOMGbotBETA;

var i, x, y, teflon, accept : Integer;
fire, bandage, divinity : Integer;
sphere, divi, tefl, spher : Integer;

procedure FireRain;
begin
repeat
accept := BitmapFromString(49, 10, 'beNrNkeFKAlEQhZ/KCCMUQw' +
'xhHySWTWQzn8VyN1d7mEzXtbfpT9EHB4bp3vX/DofhzJlv7oImyVW' +
'v1zVdd69u+v1YP9+/69XaxvQhZSQMcvzxoyakw+jQC8AO/XmAIf/1' +
'26iKl0KYxizN8PW+JqfjScjlCcUzEiqJX5PXSevK13AwCARWvpb0W' +
'fbIKE+PMRSH9f4ELPGCzrX1Ph5Nd6OR16bYnD4bDB2vhMMAQ4QCgt' +
'ALQOde/lutL4//V3No/DlJVVaYfJ4HJCFwHML7ROd0FDyi1Tiq+8n' +
'EtMifYLZvW0me3IwBeAE6bA5neduaPBbo0mrq6nz8QvH4vFhi9Lt5' +
'YFe92+8JQxL8RwBipm11aZV0rf4AiCeBcg==');
If (FindBitmapToleranceIn(accept, x, y, 0, 0, 10000, 10000, 15)) Then
MoveMouseSmooth(x, y);
wait(2 * 500+random(50));
ClickMouse(x, y, True);
FreeBitmap(accept);
Wait(2 * 100+random(50));
Writeln('Casting Fire Rain.');
fire := BitmapFromString(13, 7, 'beNoNzU8oQwEcwPHvZo1s5s3wj' +
'NnB/HtiU8oSJSInRZHLbs5ODi6KUm6ztMOmN8ommyUbipFwpHal5G' +
'AuQo7KhX7e/fPta2XbyW4FOZXfkO9vuuajjxsolHHsRnbmJDYWtqM' +
'72ADdwuskstj25OHWxJWLCw1Ja5IP5v3oNhJmMs1c9yKrnaUg9+W8' +
'+KwHtUhYlctWyXXHFeJmnkfsR4ZJDct8XbGKz4CaNSHLlaJXy8lAV' +
'CVm53HUqAblbFw2m96GKHWQha+ZellxyGkw0UhM4TxgmJ7vBbfs+Y' +
'38J+TO2HiYQNb87yGloJFUOGxBoh6JeNPtyJKzNEWqgaJhIl0SDuy' +
'rbFlIuoy7VzL9d7Os/wMNXWmN');
If (FindBitmapToleranceIn(fire, x, y, 0, 0, 10000, 10000, 15)) Then
MoveMouseSmooth(x, y);
HoldMouse(x, y, True);
Wait(2 * 500+random(50));
ReleaseMouse(x, y, True);
FreeBitmap(fire);
Wait(6 * 1500+random(50));
Writeln('Healing with Bandage.');
bandage := BitmapFromString(17, 9, 'beNoBywE0/p5kpIBXsoxep4' +
'FTn3xNu5tr07SB3b6H47+G37h616xw265y4LF25bN5365x26hs4q5' +
'w4apswKJ7uJdtu5pwtJdqrpFkoIBQrYxWyaRp2a9w4bV216pw1Kdt' +
'2qty361z2aZq3alr3qdpuZx3vqJ6vKJ6u6F3up5ywqJ0vZlkpn1Dt' +
'YlKz6Fh5bh+3K921aZu3atz3Khv2qZq3qVps5p2r5ZyrpdytJt1uq' +
'B2s5NntI9d3rV79MaIv45Ry55l4rR+2qtz26lx3alw2aVp3qVpspt' +
'3tp97taF8uaJ9rZNruZlt6sWT5buEzZ5j6LZ8ilwmz6Nv2qx21aZu' +
'3Khx2aRr3KNptp15r5h0r5t2s5x3tpt25MOZ+tWk+c+a67yD7L2E5' +
'bmFmGw61adz0KBr1aFq1J9m155ksZZxuaB8tZ55sJdz6s6m89Ko99' +
'Gj06p5/9Sg+MqWzaJy4baGroJQ4bF+16Vu3Kdu3KNptZdur5Nrtpl' +
'06c2l8dOsyah+/9ux98+i+M6h/+Gx/9eq/9mszqFyuIpY1aJuy5Zf' +
'0plfsZBkuplv68qg99as8c+n/9609tKp/920/dmwxp938sqh982i0' +
'qd4xJZkv4xY0Jtk15VpKPo=');
If (FindBitmapToleranceIn(bandage, x, y, 0, 0, 10000, 10000, 15)) Then
MoveMouseSmooth(x, y);
Wait(2 * 150+random(50));
ClickMouse(x, y, True);
FreeBitmap(bandage);
Wait(2 * 2000+random(50));
Inc(i);
until(i = 1);
end;

procedure BandageProc;
begin
repeat
Wait(2 * 500+random(50));
Writeln('Healing with Bandage.');
bandage := BitmapFromString(17, 9, 'beNoBywE0/p5kpIBXsoxep4' +
'FTn3xNu5tr07SB3b6H47+G37h616xw265y4LF25bN5365x26hs4q5' +
'w4apswKJ7uJdtu5pwtJdqrpFkoIBQrYxWyaRp2a9w4bV216pw1Kdt' +
'2qty361z2aZq3alr3qdpuZx3vqJ6vKJ6u6F3up5ywqJ0vZlkpn1Dt' +
'YlKz6Fh5bh+3K921aZu3atz3Khv2qZq3qVps5p2r5ZyrpdytJt1uq' +
'B2s5NntI9d3rV79MaIv45Ry55l4rR+2qtz26lx3alw2aVp3qVpspt' +
'3tp97taF8uaJ9rZNruZlt6sWT5buEzZ5j6LZ8ilwmz6Nv2qx21aZu' +
'3Khx2aRr3KNptp15r5h0r5t2s5x3tpt25MOZ+tWk+c+a67yD7L2E5' +
'bmFmGw61adz0KBr1aFq1J9m155ksZZxuaB8tZ55sJdz6s6m89Ko99' +
'Gj06p5/9Sg+MqWzaJy4baGroJQ4bF+16Vu3Kdu3KNptZdur5Nrtpl' +
'06c2l8dOsyah+/9ux98+i+M6h/+Gx/9eq/9mszqFyuIpY1aJuy5Zf' +
'0plfsZBkuplv68qg99as8c+n/9609tKp/920/dmwxp938sqh982i0' +
'qd4xJZkv4xY0Jtk15VpKPo=');
If (FindBitmapToleranceIn(bandage, x, y, 0, 0, 10000, 10000, 15)) Then
MoveMouseSmooth(x, y);
Wait(2 * 150+random(50));
ClickMouse(x, y, True);
FreeBitmap(bandage)
Wait(2 * 2000+random(50));
Inc(i);
until(i = 1);
end;

procedure DivinityProc;
begin
Wait(2 * 500+random(50));
Writeln('Casting Divinity.');
divi := BitmapFromString(19, 8, 'beNodkd1LWnEYx/+zsYsuqkE3hW' +
'ITc2AwX4Ye3YEI0y4iGGOXG0HSRbQ20VHQmgvKrVMnW5qTFW3rzcq' +
'U+VJHz4vneM7v9N1Pb56LB76fD9/n2Ue9g+saWV/b0UTMTp85R3nb' +
'0Adr39zTR+/sjxftgxsuO8cy6ZaElbXyTQ0iQUmAP/i1okEFbkt16' +
'IjFBK/7p20kbhmYd/QtPOuPjw2n3eOZ5aV/korTIiSCmozjIvzM5h' +
'3QBgzjoaPg4gr+UMblSo1Zko6B984nCYd1g2UPzi4hamiqXZ2o4+A' +
'XgqHdawXVtmkCsgJBxeu3eY930zmaGrd8eW5bZxju1ZtDWYdiQjah' +
'AJKOT5+V6PRRoQyJSglIT11sIDTB+by5gDsX8HL+lyuVVhdI60gm7' +
'jUUTrCclIKh/e1j/K1CNCATIkKkzK09sJNHHl92MpJPcXWKpSm5N8' +
'sC+CwWPwoBZjeRVn9XcU+6+zYkKr1t4VsW4dk/Wz9Q66Chm2ovRXX' +
'nFXzPaFMzfP0OgyMvHO6Ij42y4WgHEAz6FhRKWOWRu0IT3V5t6OKD' +
'UWqQ3IkcW8rT2/L/AeoDaG4=');
If (FindBitmapToleranceIn(divi, x, y, 0, 0, 10000, 10000, 15)) Then
MoveMouseSmooth(x, y);
HoldMouse(x, y, True);
Wait(2 * 1000+random(50));
ReleaseMouse(x, y, True);
FreeBitmap(divi)
Wait(2 * 2500+random(50));
end;

procedure TeflonSpray;
begin
Wait(2 * 250+random(50));
Writeln('Casting Teflon Spray.');
tefl := BitmapFromString(14, 10, 'beNorb4kpbjhy+9nTP//f/f8f' +
'V9qQUN4UU9YUXdpoHhgrYWSnZOkmrmctZWgnbWRf1DntzX+Qstf//' +
'0cX1UbkVwVklXkm58uaO8uYOcmaOIrpWskYOwDR41//l+45nt3U2z' +
'xrKRDFlzUCDTTyiVCx8xIzsBHVsQQqljSwBZpc1juretLczIZuoL0' +
'F7ZPyWifElje7JeQAzQSqBCoDmiasZQ5UmdnQm982MaW6DehIoIFA' +
'MrK4HuhU/8xSbddAEW0LoDItR7+Q7IrkqnagsrTaDqCy2JJ6oMqoE' +
'hBKrG73SSvySS7wiM/xTsr3TSlMr+tOrmrNqO9KrGgGMoAqgbaH5F' +
'UBEdDBUYV1kQW1QGXBWeUZ9T1AZUBjQeFTXBeSXQa0HagmrKAGqBi' +
'oAGhgeF61a0ymoa2zib0rxPbQnPKowprA7PKgnAqgeiAZllsFUeYQ' +
'nvL/zEwGMADaHp5XCVQPDE+gMqCZwbmVngm5Xol5QZllCQADjqpZ');
If (FindBitmapToleranceIn(tefl, x, y, 0, 0, 10000, 10000, 15)) Then
MoveMouseSmooth(x, y);
HoldMouse(x, y, True);
Wait(2 * 1000+random(50));
ReleaseMouse(x, y, True);
FreeBitmap(tefl)
Wait(2 * 1000+random(50));
end;

procedure SphereProc;
begin
Wait(2 * 250+random(50));
Writeln('Casting Sphere');
spher := BitmapFromString(15, 11, 'beNodzklvEgEAhuGpLUUhTXo' +
'yMdGD/8Bf4EHjwVPTxJsHE6819WRtrNsBbRQ3iNKQitW0JMVaU4o2' +
'YsGC7TSIrAVmWIayw8AMnYFhCXXks/G9P8l70Xv5of/GE3bzIxLr+' +
'GUG50bS3GGdyEeQSYHy9bg4ij+7ohd8AI5V7Czg+fnsVYVxeTJUt6' +
'OydCh+hZhAOo5CBnSgw0chRMAF8eBM2HCu8ng0MnuWdGqrogdpQx0' +
'bOPiGIolCCoUc0uEWG+vngrJeybxWZ18pmVvHN2QPYqtCYU5sv0fP' +
'BtmP+j7y+y0+f1impCotG5VV0+jBLJHSnPTKP7D3rlzW1+UPaCwCu' +
'xDopljkBIaVGJ4L1cwn+LeK0jMiPaPe6a2jtNwv6qS2qf/XCskuS5' +
'G2xAh8jBUooUl1LUTcRIRN6tL04Jb5ShIuVOaRfMEJq52aTSx+l1o' +
'xtBk0khBisA0nrKrMm2O0RuW7OWKxXsvjC/Lz/dxSnV7MtUnQn7s5' +
'ErUoUtvQEa6XxLaW+K0Z8NxXOm6PrK2MZeBH5dPRfzGz0uC2kD0ib' +
'ohxXBq4PqaafDoUeDQUuEvsTg06751ymcczIFGx4M8mGnaAQnQNDr' +
'0En5H43xThmVbszaipiWH3ndPk3IUQa0BzASktamYYxoO6f853aZ0' +
'=');
If (FindBitmapToleranceIn(spher, x, y, 0, 0, 10000, 10000, 15)) Then
MoveMouseSmooth(x, y);
HoldMouse(x, y, True);
Wait(2 * 1000+random(50))
ReleaseMouse(x, y, True);
FreeBitmap(spher)
Wait(2 * 1000+random(50));
end;

begin
repeat
FireRain;
DivinityProc;
FireRain;
SphereProc;
FireRain;
TeflonSpray;
until(False);
end.

This is for a flash game (as said before) It does the first FireRain procedure and then goes to the DivinityProc procedure and executes that perfectly, though when it goes back to the second FireRain procedure it continues to use the FireRain procedure apposed from going down the list (ex. going to SphereProc, repeating FireRain once more then going to TeflonSpray) so in smaller terms it keeps repeating the first process an infinite amount of times even though it's found the bitmaps. Any tips on what I'm doing wrong? Thanks for your response by the way ^^

cycrosism

2011-07-17 10:18:31

If you need some more help, check out the link in my signature below. I have a bitmap tutorial.

Littma

2011-07-17 10:28:41

From: cycrosism
If you need some more help, check out the link in my signature below. I have a bitmap tutorial.


Thanks, it clears up a lot but I'm not sure why I'm having this issue (explained above your post which includes the script) Perhaps you could assist me in what I'm doing wrong?

Shuttleu

2011-07-17 12:19:27

on the BandageProc you have it exit when i=1 but if i never gets reset to 0 then it will only equal 1 once

so change it to this

procedure BandageProc;
begin
i:=0;
repeat

~shut

masterBB

2011-07-17 12:38:18

Same as with the other thread:

If (FindBitmapToleranceIn(bandage, x, y, 0, 0, 10000, 10000, 15)) Then
MoveMouseSmooth(x, y);
Wait(2 * 150+random(50));
ClickMouse(x, y, True);

Should be:

If (FindBitmapToleranceIn(bandage, x, y, 0, 0, 10000, 10000, 15)) Then
begin
MoveMouseSmooth(x, y);
Wait(2 * 150+random(50));
ClickMouse(x, y, True);
end;

KingKong

2011-07-17 18:25:39

IIRC, bitmap finding and other color related stuff is sometime buggy and doesn't work in flash, so you have to find another way around it if its the case.