Jump to content
Halkclaw

Help making a script

Recommended Posts

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. :)

Link to comment
Share on other sites

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 by LordJashin
Link to comment
Share on other sites

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 by Halkclaw
Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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 by LordJashin
Link to comment
Share on other sites

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. :|

Link to comment
Share on other sites

[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 by LordJashin
Link to comment
Share on other sites

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 by Halkclaw
Link to comment
Share on other sites

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:

 

pzNmJ.gif

 

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 by LordJashin
  • Like 1
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...