Halkclaw Posted November 2, 2012 Share Posted November 2, 2012 Hi everyone I'm attempting to make a script using scar ver. 3.36 to make a auto script, but i have no clue how to do it. what i basically want to do is learn how to make a auto clicker that clicks on a color or pixel color (color number 6778487) and like double click it every two or three minutes, and keep doing this, but there is multiple of all these colors so i want it to like select one at a time. is that possible? If so how might i go by making this? Please be as simple as possible i have almost no clue what i'm doing. All I've every done with this program is make a simple auto hotkey presser which seems to be a pretty simple script from what I've seen a lot of people do. Thanks in advance guys and girls. Quote Link to comment Share on other sites More sharing options...
LordJashin Posted November 2, 2012 Share Posted November 2, 2012 You can use the functions: Wait, FindColor, MoveMouse, or ClickMouse. I'll make a script example for you when I get the chance. I suggest you check out the tutorials section, and the wiki. 1 Quote Link to comment Share on other sites More sharing options...
Halkclaw Posted November 2, 2012 Author Share Posted November 2, 2012 Alright thanks i'll look a bit, but im swamped this weekend with homework and a new puppy for a household so it will take me a bit to get to it. I'll be eagerly awaiting your example too. Thanks again. Quote Link to comment Share on other sites More sharing options...
LordJashin Posted November 4, 2012 Share Posted November 4, 2012 (edited) I recommend you read the beginner tutorial i made here - http://forums.scar-divi.com/showthread.php?1811-The-All-In-One-Beginners-Guide-To-SCAR-Divi! That tutorial covers just about everything... There is also other tuts that are useful in the tutorials section. Well here it is: [scar] program New; var w, h: Integer; procedure SetupClient; begin GetClient.Activate; // Whatever you select with the crosshairs, this will bring it into view // If nothing is selected with the crosshairs, usually the default will be the whole screen or desktop with GetClient.ImageArea do // The image area of whatever you selected with the crosshairs begin w := X2; // The width statement is the only way to do this h := Y2; // we set the w and h vars to the bottom most right most point of the image area (box) WriteLn('w variable (using for width) is set to: ' + IntToStr(w)); WriteLn('h variable (using for height) is set to: ' + IntToStr(h)); // here we write to the debug box // the values of w and h after we set them // you can also see this info inside of View->Show Target Client in SCAR Divi interface end; end; procedure MainLoop; var x, y: Integer; begin repeat // If the color is found in the client, findcolor returns true, and x, y will be where it was found if FindColor(x, y, 6778487, 0, 0, w, h) then // Looks for the color 6778487 from 0,0 to w, h on the client ClickMouse(x, y, mbLeft); // will move the mouse for you and click the mouse at x, y wait(60000 * 3); // 1000 milliseconds = 1 second. So 60,000 = 60 seconds x 3 = 3mins until False; // This is an INFINITE loop WHICH IS NOT RECOMMENDED end; begin // the real main loop is always the begin end. SetupClient; MainLoop; end. [/scar] Edited November 4, 2012 by LordJashin Quote Link to comment Share on other sites More sharing options...
Halkclaw Posted November 8, 2012 Author Share Posted November 8, 2012 (edited) well i got it too work, and i don't mean to be super picky, but is there a command for a double click on a color i can't seem to find the command. Also i still don't completely get these parts of your coding. w := X2; // The width statement is the only way to do this h := Y2; // we set the w and h vars to the bottom most right most point of the image area (box) WriteLn('w variable (using for width) is set to: ' + IntToStr(w)); WriteLn('h variable (using for height) is set to: ' + IntToStr(h)); // here we write to the debug box x, y: Integer;begin repeat // If the color is found in the client, findcolor returns true, and x, y will be where it was found if FindColor(x, y, 6778487, 0, 0, w, h) then // Looks for the color 6778487 from 0,0 to w, h on the client ClickMouse(x, y, mbLeft); // will move the mouse for you and click the mouse at x, y Edited November 8, 2012 by Halkclaw Quote Link to comment Share on other sites More sharing options...
LordJashin Posted November 9, 2012 Share Posted November 9, 2012 Use [sCAR-][-/SCAR] tags when Posting code, Without the dashes (-)... 1. That first part gives the width value of X2. Since I used the with Blank do statement. It is with ImageArea do. So it is like doing ImageArea.X2 just without the ImageArea. part So there we assign the value of X2 and Y2 to the w, and h variables that are of the type Integer (number). The WriteLn command well write to the Debug Box. 2. This is a repeat (loop). So this will loop, and continue doing that statement for as long as forever is. Then there is FindColor, which will search for a color in a specific area. Then IF statement, so IF FindColor returns true, then ClickMouse will click the mouse at the position it found the color which was stored in x, y variables. If you wanted to do TWO mouse clicks you would just add another one: [scar] if FindColor(x, y, 6778487, 0, 0, w, h) then begin ClickMouse(x, y, mbLeft); ClickMouse(x, y, mbLeft); end; [/scar] If you need help, or don't understand, I suggest you read my beginners tutorial for SCAR Divi here: http://forums.scar-divi.com/showthread.php?1811-The-All-In-One-Beginners-Guide-To-SCAR-Divi! Quote Link to comment Share on other sites More sharing options...
Halkclaw Posted November 9, 2012 Author Share Posted November 9, 2012 Thanks, that came in faster then i expected lol. The double click works now, but clicks on the top of the client im using and maximizes and minimizes, trying to figure out that coordinates thing. Quote Link to comment Share on other sites More sharing options...
LordJashin Posted November 9, 2012 Share Posted November 9, 2012 (edited) Thanks, that came in faster then i expected lol. The double click works now, but clicks on the top of the client im using and maximizes and minimizes, trying to figure out that coordinates thing. Is the color your trying to find at the top of the client? That may be why its clicking there. You can also just use MouseMove function instead of ClickMouse, so it doesn't click there itll just move there. (So you can see it without it minimizing/maximizing it) [scar] MoveMouse(x, y); [/scar] Edited November 9, 2012 by LordJashin Quote Link to comment Share on other sites More sharing options...
Halkclaw Posted November 9, 2012 Author Share Posted November 9, 2012 No im using like a redish brown color, and where it's clicking is a dark blue like the top of a window in Windows 7 os. Quote Link to comment Share on other sites More sharing options...
LordJashin Posted November 9, 2012 Share Posted November 9, 2012 Show me your code. And what exactly are you selecting as the client? Can you post a pic or no? Quote Link to comment Share on other sites More sharing options...
Halkclaw Posted November 9, 2012 Author Share Posted November 9, 2012 This is the code program AutoSelectNPC; var w, h: Integer; procedure SetupClient; begin GetClient.Activate; with GetClient.ImageArea do begin w := X2; h := Y2; WriteLn('w variable (using for width) is set to: ' + IntToStr(w)); WriteLn('h variable (using for height) is set to: ' + IntToStr(h)); end; end; procedure MainLoop; var x, y: Integer; begin repeat if FindColor(x, y, 1529539, 0, 0, w, h) then ClickMouse(x, y, mbLeft); ClickMouse(x, y, mbLeft); wait(5000); until False; end; begin SetupClient; MainLoop; end. For the picture do you mind it on photobucket it's too big for here. Quote Link to comment Share on other sites More sharing options...
LordJashin Posted November 9, 2012 Share Posted November 9, 2012 (edited) [noparse] Use [scar]SCAR Code goes here e.g. program AutoClicker;[/scar] tags in your posts for you SCAR scripts [/noparse] Like so below, Try this: [scar] program AutoSelectNPC; var CBox: TBox; procedure SetupClient; begin GetClient.Activate; CBox := GetClient.ImageArea; end; procedure MainLoop; var X, Y: Integer; begin repeat if FindColor(X, Y, 1529539, 0, 0, CBox.X2, CBox.Y2) then begin ClickMouse(X, Y, mbLeft); ClickMouse(X, Y, mbLeft); end; wait(5000); until False; end; begin SetupClient; MainLoop; end. [/scar] Edited November 9, 2012 by LordJashin Quote Link to comment Share on other sites More sharing options...
Halkclaw Posted November 9, 2012 Author Share Posted November 9, 2012 (edited) It works a lot better thanks never wanted it to select it like a human, but i just wanted it to get the things i couldnt thanks a million for your patience and help! one last question is it possible to add more colors for it too search 1-4 or or something? and by doing that would i just add the same code i have now within the parameters? Edited November 9, 2012 by Halkclaw Quote Link to comment Share on other sites More sharing options...
LordJashin Posted November 9, 2012 Share Posted November 9, 2012 (edited) Yes but change the color in the FindColor function. e.g. FindColor(X, Y, 1529539, 0, 0, CBox.X2, CBox.Y2) to: FindColor(X, Y, Whatever color here, 0, 0, CBox.X2, CBox.Y2) Also by "Selecting" a client I mean this in SCAR: So for instance here is full code for multiple colors second color i added was (16777215): [scar] program AutoSelectNPC; var CBox: TBox; procedure SetupClient; begin GetClient.Activate; CBox := GetClient.ImageArea; end; procedure MainLoop; var X, Y: Integer; begin repeat if FindColor(X, Y, 1529539, 0, 0, CBox.X2, CBox.Y2) then begin ClickMouse(X, Y, mbLeft); ClickMouse(X, Y, mbLeft); end; if FindColor(X, Y, 16777215, 0, 0, CBox.X2, CBox.Y2) then begin ClickMouse(X, Y, mbLeft); ClickMouse(X, Y, mbLeft); end; wait(5000); until False; end; begin SetupClient; MainLoop; end.[/scar] Edited November 9, 2012 by LordJashin 1 Quote Link to comment Share on other sites More sharing options...
Halkclaw Posted November 9, 2012 Author Share Posted November 9, 2012 Alright i think i got it dude thanks for everything. I'm gonna bookmark this so i can reference it later. You helped me a lot, and im grateful. I'd rep you again, but it won't let me till i rep somebody else lol. Quote Link to comment Share on other sites More sharing options...