ludger Posted March 30, 2012 Share Posted March 30, 2012 (edited) 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 March 30, 2012 by ludger Quote Link to comment Share on other sites More sharing options...
FHannes Posted March 30, 2012 Share Posted March 30, 2012 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. Quote Link to comment Share on other sites More sharing options...
ludger Posted March 30, 2012 Author Share Posted March 30, 2012 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. Quote Link to comment Share on other sites More sharing options...
FHannes Posted March 30, 2012 Share Posted March 30, 2012 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. Quote Link to comment Share on other sites More sharing options...
Bixby Sayz Posted March 30, 2012 Share Posted March 30, 2012 Edit: Freddy is just too quick. I like his code better than what I hacked together anyway. Quote Link to comment Share on other sites More sharing options...
ludger Posted March 30, 2012 Author Share Posted March 30, 2012 (edited) 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 March 30, 2012 by ludger Quote Link to comment Share on other sites More sharing options...
opiumhautopium1 Posted March 30, 2012 Share Posted March 30, 2012 think until wait is not good because the loop is not counting the wait u can insert the integer waittime and and repeat it with waittime:=waittime + 200; then u can use until waittime<30000; Quote Link to comment Share on other sites More sharing options...
FHannes Posted March 30, 2012 Share Posted March 30, 2012 Wait is a procedure, it has no result, certainly not a boolean... Look at my first example... Quote Link to comment Share on other sites More sharing options...
Bixby Sayz Posted March 30, 2012 Share Posted March 30, 2012 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] Quote Link to comment Share on other sites More sharing options...
ludger Posted April 12, 2012 Author Share Posted April 12, 2012 [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] Quote Link to comment Share on other sites More sharing options...
Bixby Sayz Posted April 12, 2012 Share Posted April 12, 2012 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] Quote Link to comment Share on other sites More sharing options...
ludger Posted April 13, 2012 Author Share Posted April 13, 2012 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] Quote Link to comment Share on other sites More sharing options...
opiumhautopium1 Posted April 13, 2012 Share Posted April 13, 2012 (edited) 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 April 13, 2012 by opiumhautopium1 Quote Link to comment Share on other sites More sharing options...
ludger Posted April 13, 2012 Author Share Posted April 13, 2012 Thanks very much Opium, and the i variable is like a count of how many times it tried to search for loginfail? Quote Link to comment Share on other sites More sharing options...
opiumhautopium1 Posted April 13, 2012 Share Posted April 13, 2012 (edited) 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 April 13, 2012 by opiumhautopium1 Quote Link to comment Share on other sites More sharing options...
ludger Posted April 15, 2012 Author Share Posted April 15, 2012 (edited) 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 April 15, 2012 by ludger Quote Link to comment Share on other sites More sharing options...
opiumhautopium1 Posted April 15, 2012 Share Posted April 15, 2012 (edited) WriteLn(GetSystemTime);work WriteLn(Getsysemtime); dont work ^^ i dont know if its possible to take a picture in scar....... what u want to do with it? may be a software like X-Shot 2.7.0 help u ? Edited April 15, 2012 by opiumhautopium1 Quote Link to comment Share on other sites More sharing options...
FHannes Posted April 15, 2012 Share Posted April 15, 2012 It is possible with SCAR, the easiest way is probably the SaveScreenshot function. Quote Link to comment Share on other sites More sharing options...
shadowrecon Posted April 15, 2012 Share Posted April 15, 2012 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] Quote Link to comment Share on other sites More sharing options...
FHannes Posted April 15, 2012 Share Posted April 15, 2012 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. Quote Link to comment Share on other sites More sharing options...
ludger Posted April 15, 2012 Author Share Posted April 15, 2012 thank you very much shadow, and freddy how do i select the area SaveScreenshotEx has to take a screen shot of? because i can't find the function in the wiki yet Quote Link to comment Share on other sites More sharing options...
FHannes Posted April 15, 2012 Share Posted April 15, 2012 The same way you select a client area for a colorfinding function. It's just SaveScreenshotEx(Path: string; xs, ys, xe, ye: Integer) Quote Link to comment Share on other sites More sharing options...
ludger Posted April 15, 2012 Author Share Posted April 15, 2012 ok thanks freddy, and scar is really awesome Quote Link to comment Share on other sites More sharing options...
shadowrecon Posted April 16, 2012 Share Posted April 16, 2012 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] Quote Link to comment Share on other sites More sharing options...
LordJashin Posted April 16, 2012 Share Posted April 16, 2012 If Freddy added a Desktop boolean to SaveScreenshot, that'd eliminate 10 lines of code right there! Quote Link to comment Share on other sites More sharing options...