Jump to content
Dizzle

Colour + Click

Recommended Posts

Hello.

 

I just started playing a new MMO, where I really need a script to do the boring work. All it need to do, is simply detect a colour and then click it. I know, it seems very simple, and I used to know, but I haven't created scripts for 5 years now, and I really can't remember.

 

I have searched the net, this forum, and found some things I thought would work, but when I try to run the script and the colour shows up, nothing happens.

 

So hopefully someone can guide me in the right direction, link to a guide or something. I'm open to anything at this point.

 

Sincerely. B|

Link to comment
Share on other sites

[scar]

Program FindColorClickColor;

 

Const

Color = 0000000; // color you wish to click

 

Procedure FindClick;

Var

X,Y,W,H: Integer;

begin

GetClientDimensions(W,H);

If FindColor(X,Y,Color,0,0,W,H) then

Begin

MoveWindMouse(X,Y,0,0);

ClickMouse(X,Y,True);

end;

end;

 

begin

Repeat // Repeats for ever.. or until program is stopped.

FindClick;

Wait(150);

Until False;

end.

[/scar]

 

This is basic and there are alot of customizations you could do for the search area to look in and other findcolor methods that use tol and ect.

Edited by shadowrecon
Link to comment
Share on other sites

Alright! Thanks alot. It worked as a charm, but I hav one problem though. It seems, that there might be more than one place on the target screen, the colour appears, so it move to one of them and then it stops doing anything. So I was wondering, if it's possible to add in, that when it has click on the object, it moves back to the middle or a certain cordinate x,y wise?

Also, it seems to be fine clicking the first object after I start it, but when it comes the 2nd time, it doesnt move or click it. Since I know where the object will come, maybe it's easier to set it to cick x,y instead of colour?

 

I will look myself, I'm sure a move command is quite easily, so I will return if I find a soloution before I get a reply.

 

Edit: So I found the MoveMouse procedure, but can't quite get it to work. I keep getting 'Invalid number of parameters'.

Edited by Dizzle
Link to comment
Share on other sites

Well, that didn't work, or I did it wrong. I don't see how setting a 'box' where to find it would help. It's quite a big area. The problem is not, that the colour is there by default, the problem is the object i wanna click might appear more than once at one time. The colour works, and the first object that appears is clicked, but the next is not. It seems at is stops after clicking he first.

 

Okay, I think I figured out why it doesn't work properly.

It seems the colour code is not exactly the same when it appears in other places. Is it possible to make it click on different variants of one colour, or even make it click like 10 different colours?

 

Edit: So I looked trough some tutorials, and was wondering, since my objects appear at different locations on the scrren, would I not be able to adapt those as DTMs or Bitmaps, and ask it to click those objects when identified? I just read the tutorial, so I don't know if it's actual doable. Just thought it would seem easier as the objects are very close to identical, but not 100%.

Edited by Dizzle
Link to comment
Share on other sites

Well, that didn't work, or I did it wrong. I don't see how setting a 'box' where to find it would help. It's quite a big area. The problem is not, that the colour is there by default, the problem is the object i wanna click might appear more than once at one time. The colour works, and the first object that appears is clicked, but the next is not. It seems at is stops after clicking he first.

 

Okay, I think I figured out why it doesn't work properly.

It seems the colour code is not exactly the same when it appears in other places. Is it possible to make it click on different variants of one colour, or even make it click like 10 different colours?

 

Edit: So I looked trough some tutorials, and was wondering, since my objects appear at different locations on the scrren, would I not be able to adapt those as DTMs or Bitmaps, and ask it to click those objects when identified? I just read the tutorial, so I don't know if it's actual doable. Just thought it would seem easier as the objects are very close to identical, but not 100%.

it should click every item on screen that appears with that color. If you want to click something different just make an array of colors and loop through it like so -

 

[scar]

Program FindColorClickColor;

 

const

MaxColors = 2; //Change to add more colors..

 

Var

Colors: Array[0..MaxColors] of Integer;

 

Procedure DeclareColors;

begin

Colors[0] := 000000; // Color 1

Colors[1] := 000000; // Color 2

end;

 

Procedure FindClick;

Var

I,X,Y,W,H: Integer;

begin

GetClientDimensions(W,H);

For I := Low(Colors) to High(Colors) do // This loops though all the colors and clicks them

If FindColor(X,Y,Colors,0,0,W,H) then

Begin

MoveWindMouse(X,Y,0,0);

ClickMouse(X,Y,True);

end;

end;

 

begin

Repeat // Repeats for ever.. or until program is stopped.

FindClick;

Wait(150);

Until False;

end.

[/scar]

Link to comment
Share on other sites

Alright, I'll try that. But as of, I'm pretty much hooked on using bitmaps, as it gives me the ability to add a picture for it to locate, and make it have sligh tolerance aswell. Maybe you can give a few tips on that?

 

I tried to write my own script from tutorials, but they all have things I do not understand. Like this one http://rsdoom.2.forumer.com/a/bitmap-tutorial_post20.html

Missin pictures and such, but it explains you're able to add bitmap with tolerance, and make it click those pictures. But putting it all together, I failed. :rolleyes:

 

Also, is there a way to limit the scar target window? As of now, when I target the game, it marks my entire browser window - as it's a game played in the brower - So say I pick a dark grey/black colour, it often goes up and clicks on text in my brower menu.

 

Edit: I added some colours, but when I try to run it, I get an error. "Unexpected end of file"

[scar]Program FindColorClickColor;

 

const

MaxColors = 9; //Change to add more colors..

 

Var

Colors: Array[0..MaxColors] of Integer;

 

Procedure DeclareColors;

begin

Colors[0] := 322557;

Colors[1] := 323326;

Colors[2] := 193790;

Colors[3] := 258046;

Colors[4] := 129535;

Colors[5] := 450813;

Colors[6] := 193790;

Colors[7] := 322301;

Colors[8] := 44718;

end;

 

Procedure FindClick;

Var

I,X,Y,W,H: Integer;

begin

GetClientDimensions(W,H);

For I := Low(Colors) to High(Colors) do // This loops though all the colors and clicks them

If FindColor(X,Y,Colors,0,0,W,H) then

Begin

MoveWindMouse(X,Y,0,0);

ClickMouse(X,Y,True);

end;

end;

[/scar]

Edited by Dizzle
Link to comment
Share on other sites

You might wanna use the first code ShadowRecon posted but with a tolerance:

[sCAR]

Program FindColorClickColor;

 

Const

Color = 0000000; // color you wish to click

 

Procedure FindClick;

Var

X,Y,W,H: Integer;

begin

GetClientDimensions(W,H);

If FindColorTolerance(X,Y,Color,0,0,W,H, 4) then

Begin

MoveWindMouse(X,Y,0,0);

ClickMouse(X,Y,True);

end;

end;

 

begin

Repeat // Repeats for ever.. or until program is stopped.

FindClick;

Wait(150);

Until False;

end.

[/sCAR]

Link to comment
Share on other sites

I see you added tolerance, but how do I edit that? I assume the 4 is the tolerance, but what does that do, and what if I change it? How much difference in colour is that, so to say.

 

Edit: Okay, so that worked great. It clicked them all after I adjusted the tolerance. Now my problem is that I need it to move the mouse away from the colour/object right after it clicked. What do I need to add in order for it to do so?

Edited by Dizzle
Link to comment
Share on other sites

I see you added tolerance, but how do I edit that? I assume the 4 is the tolerance, but what does that do, and what if I change it? How much difference in colour is that, so to say.

 

Edit: Okay, so that worked great. It clicked them all after I adjusted the tolerance. Now my problem is that I need it to move the mouse away from the colour/object right after it clicked. What do I need to add in order for it to do so?

 

Just use the color picker to get ur coordinates and write after ClickMouse(x, y, True):

[sCAR]MoveWindMouse(CX,CY,10,10);[/sCAR] And put ur coordinates in instead of CX and CY

Link to comment
Share on other sites

Okay.. I just need help with one small thing. I have this script, but I would like it to be able to click itself between tabs in the browser. I tried to add them with simple ClickMouse, but I want this to be done after the Repeat, but if I change the end, after Repeat to end;, it will make an error and require end.

 

You're not able to add anything after a Repeat?

Program FindColorClickColor;

Const
 Color = 962039;

Procedure FindClick;
Var
 X,Y,W,H: Integer;
begin
 GetClientDimensions(W,H);
 If FindColorTolerance(X,Y,Color,0,0,W,H, 5) then
 Begin
    MoveWindMouse(X,Y,0,0);
    ClickMouse(X,Y,True);
    MoveWindMouse(656,448,10,10);
 end;
end;

begin
 Repeat
   FindClick;
   Wait(1500);
 Until False;
end.

Link to comment
Share on other sites

u have to call the browser and get the dimensions like

procedure findRightWindow; // finds windows
begin
 if FindWindowTitlePart('abc.com',true)  then
 begin
 SM := GetClientWindowHandle;
 Writeln('abcHandle found: '+inttostr(SM));
 end;
 wait(100);
end;

procedure abccom;
begin
 writeln('kontrollpunkt abc);
 SetClientWindowHandle(SM);
 GetClientDimensions(abc_x2, abc_y2);
 ActivateClient;
 Writeln('abc_x2xy2: '+inttostr(abc_x2)+'x '+inttostr(abc_y2));
end;

Procedure FindTab(var x,y:Integer);
begin
abccom;  // if u work with only 1 browser window dont need to call

    ClickMouse(X,Y,True);

end;



begin
findRightWindow;
abccom;
repeat
FindTab(x,y);  // x y coordinates from tab1
wait(1500);
FindTab(x,y);  // x y coordinates from tab2
wait(1500);
until(false);
end.

then u got always the right window on top and u can click with mousefunktions on the tap u need by coordinate dont forget to set global var like SM ^^

 

if u want to do something after the repeat u can try to make a funktion like

function FindClick:Boolean;
begin
result:=true;
end

then u can try

begin
 Repeat
   FindClick;
   Wait(1500);
 Until FindClick=true;
FindTab(x,y);  // x y coordinates from tab2
end.

Edited by opiumhautopium1
Link to comment
Share on other sites

No, that's not what I want. It's for a broswer game; So if I can make it switch tabs while still clicking my colour, it would double the benefits.

And if that's what that code does... I don't know what to do with it, looks so complicated lol.

 

Well, your codes make it seem very complicated. All I want to do, is it to click at two destinations. That way, it switch back and forth with a wait between.

I can do it myself, but when i write anything below Repeat, it doesn't do it, cause it will make an error if I don't make it end. instead of end;

Edited by Dizzle
Link to comment
Share on other sites

smile of course u can call in the mainloop every function u want to

I would like it to be able to click itself between tabs in the browser. I tried to add them with simple ClickMouse, but I want this to be done after the Repeat, but if I change the end, after Repeat to end;, it will make an error and require end.

u write that u want to change the tabs in browser ...... that is what the funktion do

and u want something to do after the mainloop

so have to end the loop by a event then u can call functions between mainloop and end.

but remember after end. the script is over

Edited by opiumhautopium1
Link to comment
Share on other sites

smile of course u can call in the mainloop every function u want to

 

u write that u want to change the tabs in browser ...... that is what the funktion do

and u want something to do after the mainloop

so have to end the loop by a event then u can call functions between mainloop and end.

but remember after end. the script is over

Then explain me how I do? When I change the end at Repeat to ;, it gives error that it expects an .

Program FindColorClickColor;

Const
 Color = 962039;

Procedure FindClick;
Var
 X,Y,W,H: Integer;
begin
 GetClientDimensions(W,H);
 If FindColorTolerance(X,Y,Color,0,0,W,H, 5) then
 Begin
    MoveWindMouse(X,Y,0,0);
    ClickMouse(X,Y,True);
    MoveWindMouse(656,448,10,10);
 end;
end;

begin
 Repeat
   FindClick;
   Wait(15000);
 Until False;
end;

begin
MouseClick(454,165,0,0);
end.

Just an example. This causes an error, as it expects the script to end after Repeat.

Edited by Dizzle
Link to comment
Share on other sites

Then explain me how I do? When I change the end at Repeat to ;, it gives error that it expects an .

 

Dont ever delete the end. at the end of the script. It marks that the script is over, and nothing else is written after it.

 

I wrote this little simple script some times ago. The good thing about it is that it's using timers instead of just Wait:

 

[sCAR]program New;

var

T1, T2: Integer;

const

{=-=-=-=-=-=-=-=-=Settings=-=-=-=-=-=-=-=-=-=}

 

//Remember to drag the target to the client !

xCoordinate = 0; //Use the color picker (Ctrl + P) The first coordinate is x

yCoordinate = 0; //Use the color picker (Ctrl + P) The second coordinate is y

xRandom = 0; //The randomness of x.

yRandom = 0; //The randomness of y

 

Color = 16777215; //What color to look for.

Tolerance = 4; //The tolerance of the color

 

WaitTime = 60; //Time to wait until it click the coordinates. This is in seconds.

WaitTimePlus = 240; //This is a random added time to WaitTime. This is in seconds.

 

{=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-}

 

procedure ClickColor;

var

w, h, x, y: Integer;

begin

GetClientDimensions(w, h);

if findColorTolerance(x, y, Color, 0, 0, w, h, Tolerance) then begin

ClickWindMouse(x, y, 2, 2, True);

Wait(500 + random(250));

end;

end;

 

procedure ClickCoordinates;

begin

ClickWindMouse(xCoordinate, yCoordinate, xRandom, yRandom, true);

T1 := GetTimeRunning + WaitTime * 1000 + Random(WaitTimePlus * 1000);

end;

 

begin

T1 := GetTimeRunning + WaitTime * 1000 + Random(WaitTimePlus * 1000);

repeat

ClickColor;

if T1 < GetTimeRunning then begin

ClickCoordinates;

end;

ClearDebug;

Writeln('Next click on coordinates in: ' + IntToStr((T1 - GetTimeRunning) div 1000) + ' seconds');

Wait(500);

until(false);

end.[/sCAR]

 

edit: Just fixed something

Edited by sjesper
Link to comment
Share on other sites

Dont ever delete the end. at the end of the script. It marks that the script is over, and nothing else is written after it.

 

I wrote this little simple script some times ago. The good thing about it is that it's using timers instead of just Wait:

 

[sCAR]...[/sCAR]

 

Well, I didn't delte the end. My problem is, that itwon't let me extended the script further than repeat. If I write in new things within the repeat, all those things will get repeated at the same time, and I don't want that.

 

As for the script you posted, I see a few things wrong with it. First of all, I want the colour picking to repeat itself all the time. I'm thinking it should repeat, so that it can press several buttons(colour), on every tab. It also need 2 destionations, as it has to go from tab1 to tab2, and back. :confused:

Link to comment
Share on other sites

that is what i explain u only have to insert in the mainloop your color function ^^ like

begin
findRightWindow;
abccom;
repeat
FindTab(x,y);  // x y coordinates from tab1
wait(1500);
FindClick;
FindTab(x,y);  // x y coordinates from tab2
wait(1500);
FindClick;
until(false);
end.

also u can look at

 

http://forums.scar-divi.com/showthread.php?149-Methods-(procedures-amp-functions)

Edited by opiumhautopium1
Link to comment
Share on other sites

it loop between repeat and until if u want to exit the loop u need a event look at this tutorial http://forums.scar-divi.com/showthread.php?151-Loops-(for-while-repeat-labels)

if u dont want to loop something dont use (repeat.... until) then it do things only one time

I don't think you understand what I want to do. I have a working script to locate and click a colour with tolerance. I am using that for a browser game. Now, if I have the game open in two tabs, with 2 accounts, I gain more. So it should keep repeating the colour+click while going back and forth between the two tabs.

 

As of, I can't do that with the script you suggest, as if I put it in my script, it will repeat all those clicks after eachother. If I insert it after, it will cause an error.

Link to comment
Share on other sites

Well, I didn't delte the end. My problem is, that itwon't let me extended the script further than repeat. If I write in new things within the repeat, all those things will get repeated at the same time, and I don't want that.

 

As for the script you posted, I see a few things wrong with it. First of all, I want the colour picking to repeat itself all the time. I'm thinking it should repeat, so that it can press several buttons(colour), on every tab. It also need 2 destionations, as it has to go from tab1 to tab2, and back. :confused:

 

It does repeat the color finding all the times, thats the concept of using timers. If you want it i can make one that uses more coordinates but only if you can't use opiumhautopium1's script, cause it's a little more advanced when using timers.

 

---------- Post added at 05:31 PM ---------- Previous post was at 05:27 PM ----------

 

I don't think you understand what I want to do. I have a working script to locate and click a colour with tolerance. I am using that for a browser game. Now, if I have the game open in two tabs, with 2 accounts, I gain more. So it should keep repeating the colour+click while going back and forth between the two tabs.

 

As of, I can't do that with the script you suggest, as if I put it in my script, it will repeat all those clicks after eachother. If I insert it after, it will cause an error.

 

Okay look at this code and if you have a little experience in coding you will understand:

 

[sCAR]var

T1: Integer;

 

begin

T1 := GetTimeRunning + 5000 + random(2500); //Waits between 5-7.5 seconds

repeat

if T1 < GetTimeRunning then begin

//Call function

end;

until false;

end.[/sCAR]

Link to comment
Share on other sites

look scar is working with the aktive window

the procedure findright window and abccom stet your browsergame window to aktive window and work with the window

the procedure tab make clicks at the right tabs u only have to insert the right coordinates from the tabs u want to use

then u can insert your colorfinding procedur in your script

 

at the last step u write the main

betwen begin and end.

like

procedure1
procedure 2
procedure3



begin
procedure 3
procedure 2
if you want to repeat something
repeat
procedure2
until ( a event like keydown is true or procedure2 is repeatet 20 times if u dont want to loop something dont use repeat until ^^)
procedure 1
end.

u can call the funktions like u want at the main loop

it is not possible with scar to find colors while a tab or a window is hidden minimized or closed only what u see scar can find with color funktions

Edited by opiumhautopium1
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...