jDavies97 Posted February 4, 2013 Share Posted February 4, 2013 Hey guys I need a script that will : -Loop begin. -Find image 1. -If found, left click it. -If not found, find image 2. -Left Click image 2 once. -Loop end. Can someone please sort this out for me? Need ASAP. Here's the images - Image 1 - Image 2 - Quote Link to comment Share on other sites More sharing options...
Janilabo Posted February 5, 2013 Share Posted February 5, 2013 (edited) Ello jDavies97, Test if this does what you are looking for: // Script stops with CTRL + ALT + S const INTERVAL = 250; // Minimum interval between button clicks? 1000 milliseconds = 1 second. INTERVAL_R = 150; // Randomness for the interval between button clicks. CLIENT_ACTIVATION = True; // Activate client in script setup? False to disable. AREA_XS = 0; // Custom area for bitmap detection. Keep values as 0 if you want full client area to be scanned! AREA_YS = 0; AREA_XE = 0; AREA_YE = 0; MOUSE_SPEED = 25; // The higher value, the faster mouse movement. var area: TBox; click: TPoint; mark, randomness: Integer; yesButton, skipAD: TSCARBitmap; procedure SetupScript; var w, h: Integer; begin if CLIENT_ACTIVATION then GetClient.Activate; yesButton := TSCARBitmap.Create('deNrtl99LWmEYx88f0cXWhdfhosKS/L' + 'HCEEEQSZAgIiIKvPV++AcIu2gLHDbGzu1GG9pWtLEf0kXbWilNIt1mm8f90LXJ' + '0XPStHPMHTuPetxosK6eA+/L5+Z8n+cI3/frec57/NRl6nR+noCQ2twcASHi7C' + 'wBIcLMDAEhJ9PTBIRUp6YICKlMTuJm/LGG8lANfMbxls4YNbLo0RgZ7BYuwvHE' + 'BG7oGl+XVyni3wLRufeKBZXfO8Fu4SKU3G7svMxABPXEvuVMsfiTEAsv3nWrwM' + 'L/c+RyoeeOyEEw2ftDBy7X61ACrjMv2m32IR8FE6+BdlTxC6OLypI0EofsyF3z' + 'TqcKeM5AEOxm/KouCrFw4m1oSOm6Pd5Iqa5YCdrTrUtJVZvOR9HZescqb99Cbr' + 'nocKiBJQHeMmySbu4/86xZNW1E5LnGVOVm+fliIxsmx8frm9Cfhv7jOH8aX0Ju' + 'uWC3q4PgO6HjL88JwWbJ8FB+HCrRICjrn+Smw5Wxw+0CzEBammCXQmPq8MvabG' + 'qhmlbEkn7a0t+HPyh2/ozmTCu/XSzvcorb2KS30XBDj91s3mpVDYGdCmxvkQ20' + '9aOdYv2cVdsN5K1PxL/07L0rCdxmf1ks6uFRHvY1lVPqawcwtUKm8+9d70insJ' + 'XDbfbnyIh6WGnlklXqN2MifHh6F/pb+vCDLkq63O/putYzDGL/MhzMuBiP2+wP' + 's1k9hNu5dJa4GPfnK4bySt+e+bD5+5uClBeINJywhTXsZnMGg3pYbR7JPpf/VW' + '0vYdXARblOjasuqMBsVq8nIOTb4CABIV8HBggI+dLXR0BIpreXgBBGqyUg5De/' + 'FZ5Q'); skipAD := TSCARBitmap.Create('deNrtlM0NwyAMhT1Bh+kyjMQMDBD5zghcW' + 'CEbcMgQbQKG2Py0iZRIPRRxSKzY/vx45AkPeP3XVctbAAPKhds7LagMwIShGy/' + 'b+gFVwGkL6vlM01nzskepUlYOBqfAaH+dVqlO3Nofpmq7B4eSymtDzym4aUWzq' + 'CyywuVTR78NW3VRwA+oR5U2P5pCFVjBhiqWIgN0pNhzpSCElM607yuSosImKqt' + '5Sk1FVkl+a+Xi8dHz2O2NpGtfrmEx6oCKxT8YJqYwS2RtO1QBrXydhIWUQ80O9' + '5RWYi7DPf9Vq/SBxK7uILNQn0reYmkMgVrSuVf76dXPSlooJpKAK0NNNbhBw17' + '7LLlmucgDX51b0le/su6iegMJtWwu'); area := Box(AREA_XS, AREA_YS, AREA_XE, AREA_YE); GetBoxSize(area, w, h); if ((w < yesButton.Width) or (h < yesButton.Height) or (w < skipAD.Width) or (h < skipAD.Height)) then area := GetClient.ImageArea; end; procedure Wait2(MS: LongInt); var t: Integer; k: Byte; begin t := GetSystemTime; k := CharToVKey('s'); repeat if (GetCurrentKeyState(VK_CONTROL) and GetCurrentKeyState(VK_MENU) and GetCurrentKeyState(k)) then // CTRL + ALT + S TerminateScript; Wait(1); until ((GetSystemTime - t) > MS); end; procedure OffsetPoint(var pt: TPoint; xOffset, yOffset: Integer); begin pt.X := (pt.X + xOffset); pt.Y := (pt.Y + yOffset); end; function FindButton(var pt: TPoint): Boolean; var x, y: Integer; begin Result := FindBitmap(x, y, yesButton, area.X1, area.Y1, area.X2, area.Y2); case Result of False: begin Result := FindBitmap(x, y, skipAD, area.X1, area.Y1, area.X2, area.Y2); if Result then pt := BoxCenter(Box(x, y, (x + skipAD.Width), (y + skipAD.Height))); end; True: pt := BoxCenter(Box(x, y, (x + yesButton.Width), (y + yesButton.Height))); end; if Result then OffsetPoint(pt, RandomRange(-6, 5), RandomRange(-3, 2)); end; begin SetupScript; Wait(1000); repeat if ((GetSystemTime - mark) >= (INTERVAL + randomness)) then if FindButton(click) then begin MoveMouseEx(click.X, click.Y, MOUSE_SPEED); MouseBtnDown(click.X, click.Y, mbLeft); Wait(35 + Random(25)); MouseBtnUp(click.X, click.Y, mbLeft); randomness := Random(INTERVAL_R); mark := GetSystemTime; end; Wait2(10); until False; end. Obviously I couldn't test it.. So, I hope it does what you need. Let me know if it doesn't work the way you needed and I will tweak it. -Jani Edited February 5, 2013 by Janilabo Quote Link to comment Share on other sites More sharing options...
jDavies97 Posted February 5, 2013 Author Share Posted February 5, 2013 Hey thanks for helping It's coming up with 'Unknown Typ TSCARBitmap' compile error on line 17. Any ideas? Quote Link to comment Share on other sites More sharing options...
Janilabo Posted February 5, 2013 Share Posted February 5, 2013 Use SCAR Divi 3.38 Quote Link to comment Share on other sites More sharing options...
jDavies97 Posted February 5, 2013 Author Share Posted February 5, 2013 Aah right downloading now - - - Updated - - - No longer getting errors, but it's not clicking the buttons for me. Quote Link to comment Share on other sites More sharing options...
Janilabo Posted February 5, 2013 Share Posted February 5, 2013 Are the buttons changing colors? Take new PNG's from buttons or even from screen and post here. I will check em out Quote Link to comment Share on other sites More sharing options...
jDavies97 Posted February 5, 2013 Author Share Posted February 5, 2013 Doesn't matter now, I'm using an external auto mouse clicker that works fine with scar. Cheers for the help! Quote Link to comment Share on other sites More sharing options...