Jump to content
ludger

Beginners help

Recommended Posts

I want to let scar search for a bitmap and as soon as it shows up it should click on it once and stop searching for it, can someone help me how to do this.

I thought something like this but it doesn't work, because i didn't identify result scar says, how do I fix this?

Thanks very much in advance

 

 

result:=false;

repeat

If FindBitmapTolerance(bmp, x, y, 40=true) then begin

clickMouse(x, y, true)

end;

until (result=true);

Edited by ludger
Link to comment
Share on other sites

I'm not sure what the purpose of that "40=" is? Also, if it says that the identifier result isn't found, i'm guessing you're in the main procedure, which means that there is no result field. so remove "result := false;" and replace "result = true;" with False.

Link to comment
Share on other sites

thanks freddy for your fast reply,

Now i have this:

but when it finds the bitmap it keeps clicking on it, so i want scar to stop searching for the bitmap, when it founds it.

procedure paint;

begin

bmp := BitmapFromString(19, 16, 'beNpr+OLa/hWInNs+AdGKB' +

'Suului3zTri0PzRtukLfgRUD1QGQTvSTDd6iV0sNbAI67HNP2Zf8' +

'9Su/o1dw7uwnpeNE/ZbFl+zqnhgCxRp/GTb+Bmo3r7lCxABDSkIi' +

'p+sJzjVXlnXsy6oeP3rvZFWpbesKh6u3ft0xpwTnvFzjVL3W5Tdt' +

'677YF0P1QJHvaV9qXENak7lhY3Lv5xdbpa2wyLvdN+qu7MWXnNNn' +

'KcTOs8077xVzVugRjSX9+9+FjL5vopTaW13+81VgcbRs80zdhzes' +

'vfg3NW67hXawTNM8s9Z1b2xAiu2QkK1c85ET78XnN6+fY3Nnj6+i' +

'PJ56UUz/8RKr3Z1NHKrMIheaVZ807LuvWUDika7hhddi84n115v7' +

'1v+9ZzIonb1/t2Pnq9q+GHOWKtlZ+BeZ5q83bLisVX9J6BGuC4gO' +

'3XGq4pVx706JvkVRH88yD63Rb9w1ZNntQFP9Hk608sNPZssMw5YV' +

'T23aviCrBGIvFqfbHh0zGu3lVI6261ljL011tFdF+7FWT8rT8itm' +

'WLk322Vd9K69g1coyUM2dY+nbXjzuwLS+MX55zc6716bdny/aff1' +

'zp/WD/DNqjEKGK2VfFlq/p3Vg1f0TQCuU1Lby04vsJ/SujmOZIbN' +

'mXe2t7+t0DpxtlTSrbZRglrrCruWTV8QHMqRG9Y181JB44ETAue1' +

'CY+a0Hmg76QhwVu01btUnGuMErbZVn11KrhsyVU4zcIsqwGIae6e' +

'1VrD4bPjqtqVNk4O/RHufaq5p6clrna/h1mucesal9bNX7BqtG65' +

'mnG1NNR87OSu+0PzM3+lKUxd+kOy8BSo+h5lsVXrOreWTV+hWtE+' +

'BGot+GLR92ljOmTa3as2nfs9rEFc8PzejW9Gs3Sd1hVPrKq/wjRB' +

'UTmTb+QEcioyoem2Qe0Q6YputbIO1SoeXUYJqyxBIYnLCJACADYo' +

'+Qm');

repeat

If FindBitmapTolerance(bmp, x, y, 40) then begin

clickMouse(x, y, true)

end;

until(False);

 

end;

begin

 

paint;

end.

Link to comment
Share on other sites

I'm not sure how you manage to run this without even defining any variables... Also, please use [scar]...[/scar] tags...

 

[scar]var

Bmp: Integer;

 

procedure LoadBitmap;

begin

Bmp := BitmapFromString(19, 16, 'beNpr+OLa/hWInNs+AdGKB' +

'Suului3zTri0PzRtukLfgRUD1QGQTvSTDd6iV0sNbAI67HNP2Zf8' +

'9Su/o1dw7uwnpeNE/ZbFl+zqnhgCxRp/GTb+Bmo3r7lCxABDSkIi' +

'p+sJzjVXlnXsy6oeP3rvZFWpbesKh6u3ft0xpwTnvFzjVL3W5Tdt' +

'677YF0P1QJHvaV9qXENak7lhY3Lv5xdbpa2wyLvdN+qu7MWXnNNn' +

'KcTOs8077xVzVugRjSX9+9+FjL5vopTaW13+81VgcbRs80zdhzes' +

'vfg3NW67hXawTNM8s9Z1b2xAiu2QkK1c85ET78XnN6+fY3Nnj6+i' +

'PJ56UUz/8RKr3Z1NHKrMIheaVZ807LuvWUDika7hhddi84n115v7' +

'1v+9ZzIonb1/t2Pnq9q+GHOWKtlZ+BeZ5q83bLisVX9J6BGuC4gO' +

'3XGq4pVx706JvkVRH88yD63Rb9w1ZNntQFP9Hk608sNPZssMw5YV' +

'T23aviCrBGIvFqfbHh0zGu3lVI6261ljL011tFdF+7FWT8rT8itm' +

'WLk322Vd9K69g1coyUM2dY+nbXjzuwLS+MX55zc6716bdny/aff1' +

'zp/WD/DNqjEKGK2VfFlq/p3Vg1f0TQCuU1Lby04vsJ/SujmOZIbN' +

'mXe2t7+t0DpxtlTSrbZRglrrCruWTV8QHMqRG9Y181JB44ETAue1' +

'CY+a0Hmg76QhwVu01btUnGuMErbZVn11KrhsyVU4zcIsqwGIae6e' +

'1VrD4bPjqtqVNk4O/RHufaq5p6clrna/h1mucesal9bNX7BqtG65' +

'mnG1NNR87OSu+0PzM3+lKUxd+kOy8BSo+h5lsVXrOreWTV+hWtE+' +

'BGot+GLR92ljOmTa3as2nfs9rEFc8PzejW9Gs3Sd1hVPrKq/wjRB' +

'UTmTb+QEcioyoem2Qe0Q6YputbIO1SoeXUYJqyxBIYnLCJACADYo' +

'+Qm');

end;

 

procedure Search;

var

x, y: Integer;

begin

repeat

Wait(500);

until FindBitmapTolerance(Bmp, x, y, 40);

ClickMouse(x, y, True);

end;

 

begin

LoadBitmap;

Search;

end.[/scar]

 

On a side-note, I'm assuming you're using an outdated copy of SCAR, as SCAR got a new bitmap encoding in 3.31, you should upgrade to avoid any bugs that may have been fixed in newer versions.

Link to comment
Share on other sites

thanks freddy you're very helpful and awesome! you were right, I forgot to paste the variables i had in my script. I also was on scar 3.30 just upgraded to 3.32 on your advice ;)

Going to work on long big bitmap finding script now i know how this works, always used the waiting time between different bitmaps. But not all computers have the same speed, so this is much better!

 

 

Thanks you to for your effort to help Bixby Says

 

---------- Post added at 12:15 PM ---------- Previous post was at 10:47 AM ----------

 

i get error at the end line it says type mismatch what did i do wrong here?

I wanted to let scar search for 30 seconds for the bitmap nietverzenden and if it founds it it should click on it.

[scar]procedure nietverzenden2;

var

x, y: Integer;

begin

repeat

Wait(200);

If FindBitmapTolerance(nietverzenden, x, y, 10) then

begin

ClickMouse(x, y, True);

end;

until wait(31000)

end;[/scar]

Edited by ludger
Link to comment
Share on other sites

If you want to stop searching after 30 seconds do something like this:

[sCAR]procedure nietverzenden2;

var

T: Integer;

x, y: Integer;

begin

T := GetSystemTime + 30000;

repeat

Wait(200);

If FindBitmapTolerance(nietverzenden, x, y, 10) then

begin

ClickMouse(x, y, True);

end;

until (GetSystemTime > T);

end;[/sCAR]

Link to comment
Share on other sites

[sCAR]procedure nietverzenden2;

var

T: Integer;

x, y: Integer;

begin

T := GetSystemTime + 30000;

repeat

Wait(200);

If FindBitmapTolerance(nietverzenden, x, y, 10) then

begin

ClickMouse(x, y, True);

end;

until (GetSystemTime > T)

end;[/sCAR]

Thanks for your help, but this code is just searching for 30 seconds for bitmap nietverzenden , and every time it finds bitmap nietverzenden it clicks on it. I want to stop the procedure after 30 seconds or it should stop after finding bitmap 'nietverzenden' and it should click just once on it. But is this possible?

 

I thought about this but with this code it won't click on it.

 

 

[sCAR]procedure nietverzenden2;

var

T: Integer;

x, y: Integer;

begin

T := GetSystemTime + 30000;

repeat

Wait(200);

until FindBitmapTolerance(nietverzenden, x, y, 10) or (GetSystemTime > T)

end;[/sCAR]

Link to comment
Share on other sites

So simply make one small change to the suggested code:

 

[sCAR]procedure nietverzenden2;

var

T: Integer;

x, y: Integer;

begin

T := GetSystemTime + 30000;

repeat

If FindBitmapTolerance(nietverzenden, x, y, 10) then

begin

ClickMouse(x, y, True);

Break;

end;

Wait(200);

until (GetSystemTime > T)

end;[/sCAR]

Link to comment
Share on other sites

ok thanks for your help!

i have one more question: scar says i have made a type mismatch, can you help me to fix it?

 

[sCAR]

repeat

wait(500)

If FindbitmapTolerance(loginfail, x, y, 10) then

FindBitmapTolerance(login, x, y, 5) and ClickMouse(x, y, True) ;///// this line is the type mismatch error

until FindBitmapTolerance(loginsucces, x, y, 0)

end; [/sCAR]

Link to comment
Share on other sites

ok thanks for your help!

i have one more question: scar says i have made a type mismatch, can you help me to fix it?

 

like this ?

[sCAR]

var i : Integer;

 

repeat

inc(i);

wait(500);

If FindbitmapTolerance(loginfail, x, y, 10) then

begin

FindBitmapTolerance(login, x, y, 5) ;

ClickMouse(x, y, True) ;

wait(1000);

end else Writeln('FindBitmapTolerance(login, x, y, 5) not found ');

if i>30 then exit; // or break;

until FindBitmapTolerance(loginsucces, x, y, 0)

end;

 

 

[/sCAR]

 

 

or

[sCAR]

while (FindBitmapTolerance(loginsucces, x, y, 0)=false) do

begin

inc(i);

If FindbitmapTolerance(loginfail, x, y, 10) then

begin

FindBitmapTolerance(login, x, y, 5) ;

ClickMouse(x, y, True) ;

wait(1000);

end else Writeln('FindBitmapTolerance(login, x, y, 5) not found ');

wait(500);

if i>300 then exit; // or break;

end;

[/sCAR]

Edited by opiumhautopium1
Link to comment
Share on other sites

jep it is a way out if something happen.... of course u can cange i>to 5000000002312 if you need more time

it is the easy way .... to count with inc(i) if u have fix waittimes... of corse u can use systemtime or time .... but it is good all times to write a second way out^^ the function

Edited by opiumhautopium1
Link to comment
Share on other sites

ok thanks, i have two more questions.

1 How can i get systemtime and write that down in the output of scar? because WriteLn(Getsysemtime) doesn't seem to work.

And is it possible to Take a picture of a bitmap every 400000 miliseconds and save it somewhere or isn't that possible with scar?

Edited by ludger
Link to comment
Share on other sites

Heres how you do it. It saves the bitmap to the screenshots folder. There is a few ways to do it these are only a few

 

[scar]

program SavewholeScreen;

 

begin

SaveScreenshot(screenpath+'Sample.bmp');

end.

 

 

 

program SaveWholeClient;

 

Procedure SaveWholeClient;

Var

BMP,Wi,He: Integer;

Name: AnsiString;

Begin

GetClientDimensions(Wi,He);

BMP := BitmapFromString(Wi,He,'');

CopyClientToBitmap(BMP,0,0,Wi,He);

Name := ScreenPath+Replace(TimeToStr(Time),':','-')+'.bmp'; // had to use replace because a ':' could n be saved as a name

SaveBitmap(BMP,Name);

end;

 

begin

SaveWholeClient;

end.

[/scar]

Link to comment
Share on other sites

Heres how you do it. It saves the bitmap to the screenshots folder. There is a few ways to do it these are only a few

 

[scar]

program SavewholeScreen;

 

begin

SaveScreenshot(screenpath+'Sample.bmp');

end.

 

 

 

program SaveWholeClient;

 

Procedure SaveWholeClient;

Var

BMP,Wi,He: Integer;

Name: AnsiString;

Begin

GetClientDimensions(Wi,He);

BMP := BitmapFromString(Wi,He,'');

CopyClientToBitmap(BMP,0,0,Wi,He);

Name := ScreenPath+Replace(TimeToStr(Time),':','-')+'.bmp'; // had to use replace because a ':' could n be saved as a name

SaveBitmap(BMP,Name);

end;

 

begin

SaveWholeClient;

end.

[/scar]

SaveScreenshot doesn't save the whole screen, it saves the whole client... and SaveScreenshotEx saves a certain area of the client.

Link to comment
Share on other sites

SaveScreenshot doesn't save the whole screen, it saves the whole client... and SaveScreenshotEx saves a certain area of the client.

 

Oh alright i guess a better example would be:

[scar]

program SavewholeScreen;

 

Procedure SaveWholeScreen;

Var

HWDC: LongWord;

begin

HWDC := GetClientWindowHandle;

SetDesktopAsClient;

SaveScreenshot(screenpath+'Sample.bmp');

SetClientWindowHandle(HWDC);

end;

 

Begin

SaveWholeScreen;

end.

[/scar]

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
  • Create New...