Danitheman Posted May 3, 2012 Share Posted May 3, 2012 (edited) Hi I was wondering if someone can quickly give me a code to this explain in normal words "If the bitmap is on the screen - perform a certain action (i.e click it), if not repeat the loop as usual." Does not have to apply to bitmap, but I want the general rule. Edited May 3, 2012 by Danitheman Quote Link to comment Share on other sites More sharing options...
FHannes Posted May 3, 2012 Share Posted May 3, 2012 (edited) I'm not sure what you're asking for... Do you mean you want the code to do this? EDIT: If you want that description translated into code... [scar]while not FindBitmap(bmp, x, y) do Wait(500); ClickMouse(x, y, True);[/scar] Though it might be best to add some additional failsafes to that. Edited May 3, 2012 by Freddy Quote Link to comment Share on other sites More sharing options...
Danitheman Posted May 3, 2012 Author Share Posted May 3, 2012 I'm not sure what you're asking for...Do you mean you want the code to do this? EDIT: If you want that description translated into code... [scar]while not FindBitmap(bmp, x, y) do Wait(500); ClickMouse(x, y, True);[/scar] Though it might be best to add some additional failsafes to that. Not familiar with the codes but this is basically what I want it to do: If a certain Bitmap or DTM picture is on the screen - click it / if not, restart loop or continue loop as usual. ( If a condition applies click it, if not continue as usual. ) Quote Link to comment Share on other sites More sharing options...
LordJashin Posted May 3, 2012 Share Posted May 3, 2012 You could make a procedure that would check for that bitmap/condition in your main loop, and then call it after every item in your main loop. Or you could go as far as using a TTimer. Edit: With a TTimer, it would run that procedure at a set Interval in milliseconds (ms). [sCAR] procedure BitmapCondition; begin if FindBitmap(Bitmap, x, y) then ClickIt; end; begin Repeat UsualLoop; BitmapCondition; until Complete; end. [/sCAR] Quote Link to comment Share on other sites More sharing options...
sjesper Posted May 3, 2012 Share Posted May 3, 2012 Not familiar with the codes but this is basically what I want it to do: If a certain Bitmap or DTM picture is on the screen - click it / if not, restart loop or continue loop as usual. ( If a condition applies click it, if not continue as usual. ) If you need to restart the loop then use the statement "Continue" example: [sCAR] function BitmapCondition: Boolean; var BitMap, x, y: Integer; begin result := FindBitmap(Bitmap, x, y); if (result) then ClickWindMouse(x, y, 5, 5, True); end; begin repeat //UsualLoop; if (BitmapCondition) then // (if the result in the function is true then) continue; //This restart the loop. //Something else until false; end. [/sCAR] But this probally isn't needed (Ofc depending of the script), but it's good to know this as it can be really usefull ^^. Quote Link to comment Share on other sites More sharing options...
Danitheman Posted May 3, 2012 Author Share Posted May 3, 2012 You guys are brilliant just like the Jedi masters, thanks:)! @Sjesper - (result) = true/false? Isn't this mouse clicks (right/left) though? Another question: Let's say I want it to check the bitmap within specific areas. For example: http://desmond.imageshack.us/Himg854/scaled.php?server=854&filename=bitmapp.png&res=landing Quote Link to comment Share on other sites More sharing options...
Wanted Posted May 4, 2012 Share Posted May 4, 2012 You guys are brilliant just like the Jedi masters, thanks:)! @Sjesper - (result) = true/false? Isn't this mouse clicks (right/left) though? Another question: Let's say I want it to check the bitmap within specific areas. For example: http://desmond.imageshack.us/Himg854/scaled.php?server=854&filename=bitmapp.png&res=landing Psuedocode {$DEFINE RS2} {$I OSI\OSI.scar} begin SetUpOSI; FindBitmapToleranceIn(Bitmap, X, Y, MSX1, MSY1, MSX2, MSY2, Tolerance); end. Quote Link to comment Share on other sites More sharing options...
LordJashin Posted May 4, 2012 Share Posted May 4, 2012 You guys are brilliant just like the Jedi masters, thanks:)! @Sjesper - (result) = true/false? Isn't this mouse clicks (right/left) though? Another question: Let's say I want it to check the bitmap within specific areas. For example: http://desmond.imageshack.us/Himg854/scaled.php?server=854&filename=bitmapp.png&res=landing Set your client. Then you can use Scar's GetClientDimensions function. Which would get the dimensions of that Runescape window. Then you could use that to pick out a certain area within that area. Top left to bottom right. Here's an example: [sCAR] program New; var x, y, w, h: Integer; begin GetClientDimensions(w, h); // So this would get the Clients Height and Width // Then search for Bitmap in area w - 150, h - 150 ( box ) // - 150 from the total width from the right ---> // - 150 from the total height from the bottom _ FindBitmapIn(Bitmap, x, y, 0, 0, w - 150, h - 150); end. [/sCAR] Edit: %$(#%*) OSI beat me to it. Quote Link to comment Share on other sites More sharing options...
Wanted Posted May 4, 2012 Share Posted May 4, 2012 That's alright, you explained it better.. though I may have answered his specific question more. Quote Link to comment Share on other sites More sharing options...
Danitheman Posted May 4, 2012 Author Share Posted May 4, 2012 This isn't OSI or any addon is it? Can't use those You guys are far too kind And the -150 is subtracting 150pixels from both sides and shrinking the window or what ? Quote Link to comment Share on other sites More sharing options...
LordJashin Posted May 4, 2012 Share Posted May 4, 2012 This isn't OSI or any addon is it? Can't use those You guys are far too kind And the -150 is subtracting 150pixels from both sides and shrinking the window or what ? Hubbadubba what? FindBitmapIn, searchs the screen, from 2 points to another 2 points. A box to say. We aren't resizing anything. We are just narrowing the search area from the original area of the client. Quote Link to comment Share on other sites More sharing options...
Danitheman Posted May 4, 2012 Author Share Posted May 4, 2012 So this means: FindBitmapIn(Bitmap, x, y, 0, 0, w - 150, h - 150); From 0, 0 to 150, 150 (in Pixels?) ? Quote Link to comment Share on other sites More sharing options...
LordJashin Posted May 4, 2012 Share Posted May 4, 2012 So this means: FindBitmapIn(Bitmap, x, y, 0, 0, w - 150, h - 150); From 0, 0 to 150, 150 (in Pixels?) ? Alright let me break it down. I feel dumb. Anyway. When you select a client, A BIG RED BOX GOES AROUND IT . And once the client is selected, all Scar's stuff goes according to that. Like if you did MoveMouse(0, 0); It would go to the top left of that client u selected. So if the client was say Scar's Debug box, it would go to the top left corner of that red box. Same goes for the Bitmap finding. So we find the Dimensions of the client w, h. Then lets say those are both 300. So instead of searching the full 0, 0 to 300, 300 we are searching 0, 0 to 300 - 150, 300 - 150. Ta da ~ Quote Link to comment Share on other sites More sharing options...
Danitheman Posted May 4, 2012 Author Share Posted May 4, 2012 This was just as I said, I feel dumb:( No but on a serious note; thanks ---------- Post added at 08:31 AM ---------- Previous post was at 08:27 AM ---------- And if I were to implement these two functions how would it look (Search bitmap within area - if found, click it)? Cannot use OSI! Sorry for being lazy but my knowledge doesn't extend this far Quote Link to comment Share on other sites More sharing options...
FHannes Posted May 4, 2012 Share Posted May 4, 2012 [scar]if FindBitmapIn(Bitmap, x, y, ...) then ClickMouse(x, y, True);[/scar] Quote Link to comment Share on other sites More sharing options...
Danitheman Posted May 4, 2012 Author Share Posted May 4, 2012 [scar]if FindBitmapIn(Bitmap, x, y, ...) then ClickMouse(x, y, True);[/scar] That simple? Compared to the other guys who posted walls of texts this is so little. I guess sometimes simplicity is genious ---------- Post added at 08:57 AM ---------- Previous post was at 08:39 AM ---------- Well since you guys are helping a shitton I thought I could ask another question. What I'm looking for: I need a function that can perform one click and then wait until a certain condition (or DTM) image applies. Example: I need it to click a monster and wait til the monster appears to be dead. THEN I want it to proceed the loop by picking up what the monster dropped. After that continue loop as usual Quote Link to comment Share on other sites More sharing options...