MujaheD
2006-06-08 09:37:03
What is a Bitmap?
Assuming that you already know things about colours, a bitmap is more like a picture. It's a group of colours put together that form to make a picture.
Basic information on bitmaps.
Bitmaps are very basic and easy to understand. All you need to do is declare a bitmap and as soon as you have done that you can use it's functions. In this tutorial i will explain how to get the mouse to click on a bitmap
Bitmap Functions
SCAR can do many more things than just click a bitmap, it can use tolerences, specify boxs and many more things. Here is a list of bitmap functions:(NOTE: it is not neccessary to read the functions however it is recommeneded)
function FindBitmap(bitmap: Integer; var x, y: Integer): Boolean; - search for the bitmap in client window. If found coordinates are returned in x,y. bitmap contains handle to bitmap generated by LoadBitmap.
function FindBitmapIn(bitmap: Integer; var x, y, x1, y1, x2, y2: Integer): Boolean; - search for the bitmap in coordinates specified by x1, y1, x2, y2. bitmap contains handle to bitmap generated by LoadBitmap.
function FindBitmapToleranceIn(bitmap: Integer; var x, y: Integer; x1, y1, x2, y2: Integer; tolerance: Integer): Boolean - Works like FindBitmapIn but with a tolerance parameter for finding any similar colored bitmap. Tolerance is used to find a colored bitmap in range of the bitmap you are looking for. The greater color range you want, the higher the tolerance parameter should be.
function FindBitmapSpiral(bitmap: Integer; var x, y, x1, y1, x2, y2: Integer): Boolean; - search for the bitmap in coordinates specified by x1, y1, x2, y2 starting from x, y. bitmap contains handle to bitmap generated by LoadBitmap.
function FindBitmapSpiralTolerance(bitmap: Integer; var x, y: Integer; x1, y1, x2, y2: Integer; Tolerance: Integer): Boolean - Works like FindBitmapSpiral but with a tolerance parameter for finding any similar colored bitmap. Tolerance is used to find a colored bitmap in range of the bitmap you are looking for. The greater color range you want, the higher the tolerance parameter should be.
function FindBitmapMaskTolerance(mask: Integer; var x, y: Integer; x1, y1, x2, y2: Integer; Tolerance, ContourTolerance: Integer): Boolean - Essentially it works like FindBitmapIn except it identifies using the masks/shape of an object in the bitmap. Masks are specified by the colors black and white. ContourTolerance is the minimal tolerance for color difference between shape of a mask and the background in a bitmap, It makes sure the shape differs from the background.
<– sample mask for finding letter A in any color.
function FindDeformedBitmapToleranceIn(bitmap: Integer; var x, y: Integer; x1, y1, x2, y2: Integer; tolerance: Integer; Range: Integer; AllowPartialAccuracy: Boolean; var accuracy: Extended): Boolean; - Works similar to FindBitmapToleranceIn but allows searching for partially covered or transformed bitmaps. If range is 0, it checks pixels at positions that match bitmap we are looking for; if Range ir 1, it checks neighbor pixels as well, if range is bigger, it checks further. AllowPartialAccuracy allows accuracy that is not 100% match. accuracy returns accuracy of found bitmap to bitmap we are looking for. accuracy = 1.0 means it was 100% perfect match.
function FindDeformedBitmapToleranceRotationIn(bitmap: Integer; var x, y: Integer; x1, y1, x2, y2: Integer; tolerance: Integer; Range: Integer; var accuracy: Extended; AngleIntervals: Extended; StartAngle, MaxAngle: Extended; var angle: Extended): Boolean; - Works similar to FindDeformedBitmapToleranceIn but allows searching for rotated bitmaps as well. Basically it rotates bitmap, searches in target image, then rotates again, searches again. AngleIntervals specifies by how much it rotates every time, StartAndge specifies initial rotation angle, MaxAngle specifies how far it rotates and angle returns angle of found image. All angles are specified in radians (Pi = 180˚)
function RotateBitmap(bitmap: Integer; angle: Extended): Integer; - Rotates bitmap by specified angle in radians (Pi = 180˚)
In this tutorial i will only be teaching you how to click on a bitmap ( will update in the near future)
Retrieving a bitmap
Your probably wondering, how the hell am i suposed to get a bitmap! well dont worry its not rocket science. To get a bitmap simply
- Make sure the bitmap you want is visble on the screen
- Press the print screen key
- Press cntrl + C
- open ms paint
- press cntrl + v
- crop out the image. NOTE: when cropping the image, crop the middle of it because not all of it is needed, look at the picture if your confused.)
- save it somewhere you can remember

Converting a Bitmap
Well since SCAR doesnt allow you to paste pictures in the CDE (Cheat Development Environment) you must let SCAR know what the picture looks like, to do this we need to change the picture into a peice of code. The code type we are using is a Variable (numbers). To do this we must:
- In scar, goto script
- goto Bitmapt to string
- Load your image
- click ok
- Now look in the debug box, you will see a few lines of code
- it should look somthing like this:
Bitmap := BitmapFromString(18, 15, 'z78DA655459926D2908DC92' +
'03027E32B9FF25756A9D57DDF1FA545486815E9221417BDA11E56' +
'C653142AA6DF393C6947CFAEAC035D3BD623693EAC376660CD927' +
'CF70E352A09601A9F6306B257853C523ADD79E647CDA04C959BB8' +
'515C58A9DA1E491BC2CD7E914D90FCD650A9F4B9BF3E8EC3B81B2' +
'790C51EF8336E5F57C8AC67EFEF7F65A1FC265E9ECB8F5A9A6678' +
'485A70AC10DAD483A830AB9C864F3EA73CAB4CE5D6837150D2365' +
'3DA632157632E95B07AB45FEB218187D2B30402FA360BFD9F52AE' +
'9BE722CFC7F1593597E4E1B2C62B60EC319C2E98889833262C7CA' +
'1D8AB3EDB0E6BE04F56860595960F92FD7C502A3CEB1A36251542' +
'1A09423847EA13BE4A302054C210955EB7E8BC72160C9C7A5E05D' +
'69A8FCCC54DDE4345267E8974B6CBEFD02CA38C03D276208E432C' +
'1D2830E4F763D7D14AA67E88B6E9BC567DB629D3E40A14EDCD49C' +
'81FBA13AE3961CC1EA0A877F81FFDCEB6504E5CC06CBC7855C2EC' +
'BF285BA1DCB4A280AB743D153486073FAE00D51E13C70D6DDA1C3' +
'FD6103A2ED99C865E2FD9F5CD663F9C948A00D41D70A155B5F2EF' +
'1580CBA1D4F51FFEACA81B7FEFE6276E8BC1E22E777D687F2EBFF' +
'0F0B8385E1E84C4CC141248F0532C0FB8D5C04F15BCD41EAB9809' +
'C1D4A939C90B926B4AD1BF68B880476465E7C95FF303E44C147E1' +
'D6E750CB33590B59FFCC237E8AF86F0C0348593D1853DDA11DD5D' +
'1966A0D147AB741C0FE17DAC3FD6E15C8C03E041650E1CD1A4865' +
'CBCB85918B221774E72155EF469D4D277438DDFCCD21F609FA1F2' +
'D27CA792EE27C6F26309EDDA3273D0BE13CF07EE30C39DF49B93B' +
'E7F5453F168CC2C38E677DD39E567EE70BC3E44F026041911E5EA' +
'EB6D70E9F745030A625EE49248695B5608170A1CF4EAE11770AE2' +
'EEB437779785C0BEEECE41CD1BB3F066C805338B6FC509022383B' +
'7727AC162D2143EC741A7127A80CC3E5588356CC2303B0BE110D6' +
'4DFBFBEFE7430C578D2E196B297608F6DA3E2E580C07523A18171' +
'1ECABC7824ACEAEE7ED07C59666EB60C1323FB49AD78148B07CE3' +
'FCEFFBE59A2550EFB83B4DEF6E6439C134B4C79C8E15114F6985E' +
'DDA1F8B3D9679FA3CD8EA84513960914440364E3BF50F89B57509' +
'');All those weird characters you see there are codes for every pixel in the bitmap. Here are some images to aid you:


How to Use a Bitmap in SCAR
Now for the fun part. First off i will show you how to get SCAR to click on the very bitmap you just created. We will firstly need to put in some variables as follows (x,y,Bitmap:integer;) (x,y) will be where SCAR will store the coordinates of the bitmap (if it finds it). ie will be the code of the bitmap you have created. you code should look somthing like this:
program MUJTUT;// name of your program here
var//means that these are variables
x,y,Bitmap:integer;//x,y and ie are integers
In this program we are going to be using procedures, please veiw starter tutorials if you dont know what that means. To click a bitmap we will be using three basic procedures (DeclareBMPs,FindBMPS,ClickBMPS). In DeclareBMPS we will be declaring the bitmap, what that means is that we will be loading the picture into your computer's memory so it know what to look for. In FindBMPS we will be coding the procedures to find the bitmap. In ClickBMPS we will be putting basic code to click on the Bitmap. Your code should look something like this:
program MUJTUT;// name of your program here
var//means that these are variables
x,y,Bitmap:integer;//x,y and ie are integers
procedure DeclareBMPS;
begin
end;
procedure ClickBMPS;
begin
end;
Procedure FindBMPS;
begin
end;
Declare the Bitmap
Its fairly simple to declare a Bitmap in scar. In the DeclareBMP procedure after begin, put this in. Bitmap :=BitmapFromString(INSERT CODE HERE). In the insert code section simply copy and paste the code which SCAR generated from our picture. Heres what your code should look like:
program MUJTUT;// name of your program here
var//means that these are variables
x,y,Bitmap:integer;//x,y and ie are integers
procedure DeclareBMPS;
begin
Bitmap := BitmapFromString(18, 15, 'z78DA655459926D2908DC92' +
'03027E32B9FF25756A9D57DDF1FA545486815E9221417BDA11E56' +
'C653142AA6DF393C6947CFAEAC035D3BD623693EAC376660CD927' +
'CF70E352A09601A9F6306B257853C523ADD79E647CDA04C959BB8' +
'515C58A9DA1E491BC2CD7E914D90FCD650A9F4B9BF3E8EC3B81B2' +
'790C51EF8336E5F57C8AC67EFEF7F65A1FC265E9ECB8F5A9A6678' +
'485A70AC10DAD483A830AB9C864F3EA73CAB4CE5D6837150D2365' +
'3DA632157632E95B07AB45FEB218187D2B30402FA360BFD9F52AE' +
'9BE722CFC7F1593597E4E1B2C62B60EC319C2E98889833262C7CA' +
'1D8AB3EDB0E6BE04F56860595960F92FD7C502A3CEB1A36251542' +
'1A09423847EA13BE4A302054C210955EB7E8BC72160C9C7A5E05D' +
'69A8FCCC54DDE4345267E8974B6CBEFD02CA38C03D276208E432C' +
'1D2830E4F763D7D14AA67E88B6E9BC567DB629D3E40A14EDCD49C' +
'81FBA13AE3961CC1EA0A877F81FFDCEB6504E5CC06CBC7855C2EC' +
'BF285BA1DCB4A280AB743D153486073FAE00D51E13C70D6DDA1C3' +
'FD6103A2ED99C865E2FD9F5CD663F9C948A00D41D70A155B5F2EF' +
'1580CBA1D4F51FFEACA81B7FEFE6276E8BC1E22E777D687F2EBFF' +
'0F0B8385E1E84C4CC141248F0532C0FB8D5C04F15BCD41EAB9809' +
'C1D4A939C90B926B4AD1BF68B880476465E7C95FF303E44C147E1' +
'D6E750CB33590B59FFCC237E8AF86F0C0348593D1853DDA11DD5D' +
'1966A0D147AB741C0FE17DAC3FD6E15C8C03E041650E1CD1A4865' +
'CBCB85918B221774E72155EF469D4D277438DDFCCD21F609FA1F2' +
'D27CA792EE27C6F26309EDDA3273D0BE13CF07EE30C39DF49B93B' +
'E7F5453F168CC2C38E677DD39E567EE70BC3E44F026041911E5EA' +
'EB6D70E9F745030A625EE49248695B5608170A1CF4EAE11770AE2' +
'EEB437779785C0BEEECE41CD1BB3F066C805338B6FC509022383B' +
'7727AC162D2143EC741A7127A80CC3E5588356CC2303B0BE110D6' +
'4DFBFBEFE7430C578D2E196B297608F6DA3E2E580C07523A18171' +
'1ECABC7824ACEAEE7ED07C59666EB60C1323FB49AD78148B07CE3' +
'FCEFFBE59A2550EFB83B4DEF6E6439C134B4C79C8E15114F6985E' +
'DDA1F8B3D9679FA3CD8EA84513960914440364E3BF50F89B57509' +
'');
end;
procedure ClickBMPS;
begin
end;
Procedure FindBMPS;
begin
end;
Find the Bitmap
to find the bitmap in scar we simply use one of the procedures mension previoulsy in the tutorial. In this case i will be teaching you how to use the 'FindBitmap' function. However in this case we will be using an 'IF' statement, what that means is we will be telling scar only to click it if the bitmap is found. Put this in the FindBMPS; procedure,
if(FindBitmap(Bitmap,x,y))then
ClickBMPS;
This tells scar that if it finds the bitmap it will run the ClickBMPS; procedure.
Your code should look somthing like this:
program MUJTUT;// name of your program here
var//means that these are variables
x,y,Bitmap:integer;//x,y and ie are integers
procedure DeclareBMPS;
begin
Bitmap := BitmapFromString(18, 15, 'z78DA655459926D2908DC92' +
'03027E32B9FF25756A9D57DDF1FA545486815E9221417BDA11E56' +
'C653142AA6DF393C6947CFAEAC035D3BD623693EAC376660CD927' +
'CF70E352A09601A9F6306B257853C523ADD79E647CDA04C959BB8' +
'515C58A9DA1E491BC2CD7E914D90FCD650A9F4B9BF3E8EC3B81B2' +
'790C51EF8336E5F57C8AC67EFEF7F65A1FC265E9ECB8F5A9A6678' +
'485A70AC10DAD483A830AB9C864F3EA73CAB4CE5D6837150D2365' +
'3DA632157632E95B07AB45FEB218187D2B30402FA360BFD9F52AE' +
'9BE722CFC7F1593597E4E1B2C62B60EC319C2E98889833262C7CA' +
'1D8AB3EDB0E6BE04F56860595960F92FD7C502A3CEB1A36251542' +
'1A09423847EA13BE4A302054C210955EB7E8BC72160C9C7A5E05D' +
'69A8FCCC54DDE4345267E8974B6CBEFD02CA38C03D276208E432C' +
'1D2830E4F763D7D14AA67E88B6E9BC567DB629D3E40A14EDCD49C' +
'81FBA13AE3961CC1EA0A877F81FFDCEB6504E5CC06CBC7855C2EC' +
'BF285BA1DCB4A280AB743D153486073FAE00D51E13C70D6DDA1C3' +
'FD6103A2ED99C865E2FD9F5CD663F9C948A00D41D70A155B5F2EF' +
'1580CBA1D4F51FFEACA81B7FEFE6276E8BC1E22E777D687F2EBFF' +
'0F0B8385E1E84C4CC141248F0532C0FB8D5C04F15BCD41EAB9809' +
'C1D4A939C90B926B4AD1BF68B880476465E7C95FF303E44C147E1' +
'D6E750CB33590B59FFCC237E8AF86F0C0348593D1853DDA11DD5D' +
'1966A0D147AB741C0FE17DAC3FD6E15C8C03E041650E1CD1A4865' +
'CBCB85918B221774E72155EF469D4D277438DDFCCD21F609FA1F2' +
'D27CA792EE27C6F26309EDDA3273D0BE13CF07EE30C39DF49B93B' +
'E7F5453F168CC2C38E677DD39E567EE70BC3E44F026041911E5EA' +
'EB6D70E9F745030A625EE49248695B5608170A1CF4EAE11770AE2' +
'EEB437779785C0BEEECE41CD1BB3F066C805338B6FC509022383B' +
'7727AC162D2143EC741A7127A80CC3E5588356CC2303B0BE110D6' +
'4DFBFBEFE7430C578D2E196B297608F6DA3E2E580C07523A18171' +
'1ECABC7824ACEAEE7ED07C59666EB60C1323FB49AD78148B07CE3' +
'FCEFFBE59A2550EFB83B4DEF6E6439C134B4C79C8E15114F6985E' +
'DDA1F8B3D9679FA3CD8EA84513960914440364E3BF50F89B57509' +
'');
end;
procedure ClickBMPS;
begin
end;
Procedure FindBMPS;
if(FindBitmap(Bitmap,x,y))then
ClickBMPS;
begin
end;
How to get the mouse to click on the Bitmap
We're almost there. Now all we have to do is tell Scar how to click on the Bitmap. Add this to the ClickBMPS section.
wait(300+random(32))
movemousesmooth(x,y)
wait(32+random(16))
clickmouse(x,y,true)
This tells SCAR to wait 300 miliseconds along with a random number between 1 to 32 in miliseconds. It will then move the mouse smoothly to the position of the Bitmap, it waits another 32ms along with a random number of ms between 1 and 16. it will then click on the position of the Bitmap. You maybe wondering why we put in the waits, well thats so that you dont lag out. Your code should look somthing like this:
program MUJTUT;// name of your program here
var//means that these are variables
x,y,Bitmap:integer;//x,y and ie are integers
procedure DeclareBMPS;
begin
Bitmap := BitmapFromString(18, 15, 'z78DA655459926D2908DC92' +
'03027E32B9FF25756A9D57DDF1FA545486815E9221417BDA11E56' +
'C653142AA6DF393C6947CFAEAC035D3BD623693EAC376660CD927' +
'CF70E352A09601A9F6306B257853C523ADD79E647CDA04C959BB8' +
'515C58A9DA1E491BC2CD7E914D90FCD650A9F4B9BF3E8EC3B81B2' +
'790C51EF8336E5F57C8AC67EFEF7F65A1FC265E9ECB8F5A9A6678' +
'485A70AC10DAD483A830AB9C864F3EA73CAB4CE5D6837150D2365' +
'3DA632157632E95B07AB45FEB218187D2B30402FA360BFD9F52AE' +
'9BE722CFC7F1593597E4E1B2C62B60EC319C2E98889833262C7CA' +
'1D8AB3EDB0E6BE04F56860595960F92FD7C502A3CEB1A36251542' +
'1A09423847EA13BE4A302054C210955EB7E8BC72160C9C7A5E05D' +
'69A8FCCC54DDE4345267E8974B6CBEFD02CA38C03D276208E432C' +
'1D2830E4F763D7D14AA67E88B6E9BC567DB629D3E40A14EDCD49C' +
'81FBA13AE3961CC1EA0A877F81FFDCEB6504E5CC06CBC7855C2EC' +
'BF285BA1DCB4A280AB743D153486073FAE00D51E13C70D6DDA1C3' +
'FD6103A2ED99C865E2FD9F5CD663F9C948A00D41D70A155B5F2EF' +
'1580CBA1D4F51FFEACA81B7FEFE6276E8BC1E22E777D687F2EBFF' +
'0F0B8385E1E84C4CC141248F0532C0FB8D5C04F15BCD41EAB9809' +
'C1D4A939C90B926B4AD1BF68B880476465E7C95FF303E44C147E1' +
'D6E750CB33590B59FFCC237E8AF86F0C0348593D1853DDA11DD5D' +
'1966A0D147AB741C0FE17DAC3FD6E15C8C03E041650E1CD1A4865' +
'CBCB85918B221774E72155EF469D4D277438DDFCCD21F609FA1F2' +
'D27CA792EE27C6F26309EDDA3273D0BE13CF07EE30C39DF49B93B' +
'E7F5453F168CC2C38E677DD39E567EE70BC3E44F026041911E5EA' +
'EB6D70E9F745030A625EE49248695B5608170A1CF4EAE11770AE2' +
'EEB437779785C0BEEECE41CD1BB3F066C805338B6FC509022383B' +
'7727AC162D2143EC741A7127A80CC3E5588356CC2303B0BE110D6' +
'4DFBFBEFE7430C578D2E196B297608F6DA3E2E580C07523A18171' +
'1ECABC7824ACEAEE7ED07C59666EB60C1323FB49AD78148B07CE3' +
'FCEFFBE59A2550EFB83B4DEF6E6439C134B4C79C8E15114F6985E' +
'DDA1F8B3D9679FA3CD8EA84513960914440364E3BF50F89B57509' +
'');
end;
procedure ClickBMPS;
begin
wait(300+random(32))
movemousesmooth(x,y)
wait(32+random(16))
clickmouse(x,y,true)
end;
Procedure FindBMPS;
begin
if(FindBitmap(Bitmap,x,y))then
ClickBMPS;
end;
The Loop
Now we come to our main loop. Here we want to tell SCAR to begin the program. simply enter this in the code:
begin
repeat
wait(1300)
DeclareBMPS;
FindBMPS;
until(false)
end.
Your Code should look somthing like this:
program MUJTUT;// name of your program here
var//means that these are variables
x,y,Bitmap:integer;//x,y and ie are integers
procedure DeclareBMPS;
begin
Bitmap := BitmapFromString(18, 15, 'z78DA655459926D2908DC92' +
'03027E32B9FF25756A9D57DDF1FA545486815E9221417BDA11E56' +
'C653142AA6DF393C6947CFAEAC035D3BD623693EAC376660CD927' +
'CF70E352A09601A9F6306B257853C523ADD79E647CDA04C959BB8' +
'515C58A9DA1E491BC2CD7E914D90FCD650A9F4B9BF3E8EC3B81B2' +
'790C51EF8336E5F57C8AC67EFEF7F65A1FC265E9ECB8F5A9A6678' +
'485A70AC10DAD483A830AB9C864F3EA73CAB4CE5D6837150D2365' +
'3DA632157632E95B07AB45FEB218187D2B30402FA360BFD9F52AE' +
'9BE722CFC7F1593597E4E1B2C62B60EC319C2E98889833262C7CA' +
'1D8AB3EDB0E6BE04F56860595960F92FD7C502A3CEB1A36251542' +
'1A09423847EA13BE4A302054C210955EB7E8BC72160C9C7A5E05D' +
'69A8FCCC54DDE4345267E8974B6CBEFD02CA38C03D276208E432C' +
'1D2830E4F763D7D14AA67E88B6E9BC567DB629D3E40A14EDCD49C' +
'81FBA13AE3961CC1EA0A877F81FFDCEB6504E5CC06CBC7855C2EC' +
'BF285BA1DCB4A280AB743D153486073FAE00D51E13C70D6DDA1C3' +
'FD6103A2ED99C865E2FD9F5CD663F9C948A00D41D70A155B5F2EF' +
'1580CBA1D4F51FFEACA81B7FEFE6276E8BC1E22E777D687F2EBFF' +
'0F0B8385E1E84C4CC141248F0532C0FB8D5C04F15BCD41EAB9809' +
'C1D4A939C90B926B4AD1BF68B880476465E7C95FF303E44C147E1' +
'D6E750CB33590B59FFCC237E8AF86F0C0348593D1853DDA11DD5D' +
'1966A0D147AB741C0FE17DAC3FD6E15C8C03E041650E1CD1A4865' +
'CBCB85918B221774E72155EF469D4D277438DDFCCD21F609FA1F2' +
'D27CA792EE27C6F26309EDDA3273D0BE13CF07EE30C39DF49B93B' +
'E7F5453F168CC2C38E677DD39E567EE70BC3E44F026041911E5EA' +
'EB6D70E9F745030A625EE49248695B5608170A1CF4EAE11770AE2' +
'EEB437779785C0BEEECE41CD1BB3F066C805338B6FC509022383B' +
'7727AC162D2143EC741A7127A80CC3E5588356CC2303B0BE110D6' +
'4DFBFBEFE7430C578D2E196B297608F6DA3E2E580C07523A18171' +
'1ECABC7824ACEAEE7ED07C59666EB60C1323FB49AD78148B07CE3' +
'FCEFFBE59A2550EFB83B4DEF6E6439C134B4C79C8E15114F6985E' +
'DDA1F8B3D9679FA3CD8EA84513960914440364E3BF50F89B57509' +
'');
end;
procedure ClickBMPS;
begin
wait(300+random(32))
movemousesmooth(x,y)
wait(32+random(16))
clickmouse(x,y,true)
end;
Procedure FindBMPS;
begin
if(FindBitmap(Bitmap,x,y))then
ClickBMPS;
end;
begin
repeat
wait(1300)
DeclareBMPS;
FindBMPS;
until(false)
end.
Now test your code and leave me alone…I meant ask for help if you need it.
SCAR is copyright to kaitnieks (what ever his real name is)
I did this for many reasons,
Gain respect
Share knowledge
Make SCAR more popular
Teach
Become an SRL member
Please help me out by posting comments
~MuJ
