cypher Posted October 30, 2011 Share Posted October 30, 2011 I was browsing thrue the forum and found some scripts that click when a colour apears at a specific spot on the screen. What I would like is a code where when i move my mouse cursor over a colour it clicks it. Found this script in a previous post program New; const ColorCheck = 17840,206784,245821,12583814,8652036,986097,1671065; CheckX = 200; CheckY = 250; ClickX = 1200; ClickY = 900; Check_Wait = 250; begin repeat if(1 <> 2)then begin Wait(Check_Wait) if (GetColor(CheckX, CheckY) = ColorCheck) then begin ClickMouse(ClickX, ClickY, True); end; end; until(1 = 2); end. But thats not what I need, I want to move my mouse and when it goes over colours 17840,206784,245821,12583814,8652036,986097,1671065 I want it to click... Any help woud be greatly appreciated Quote Link to comment Share on other sites More sharing options...
jojofromjory Posted October 30, 2011 Share Posted October 30, 2011 You can use the FindColor tool, you just use FindColor(x,y,Color,xs,ys,xe,ye) x and y will be the coordinates of the place where your color will be detected, xs and ys will be the coordinates of the left top of the area which you want to scan and xe, ye will be the bottom right corner. Then you just use ClickMouse(x,y,True) or if you want a realistic mouse and movement, you can use: MoveWindMouse(x,y,rx,ry); //rx and ry are the number of pixels the mouse can be offset from the real location GetMousePos(x,y); ClickMouse(x,y,True); Quote Link to comment Share on other sites More sharing options...
cypher Posted October 30, 2011 Author Share Posted October 30, 2011 Whats the proper way to give my variable Color a list of values ? Color = 17840,206784,245821,12583814,8652036,986097,1671065; with ( ) or [ ] gives me syntax error... Quote Link to comment Share on other sites More sharing options...
jojofromjory Posted October 30, 2011 Share Posted October 30, 2011 Whats the proper way to give my variable Color a list of values ? Color = 17840,206784,245821,12583814,8652036,986097,1671065; with ( ) or [ ] gives me syntax error... Just make multiple variables, Color1, Color2,... I guess there's a way to make an array of Integers but I always use 1 variable for 1 Integer. Quote Link to comment Share on other sites More sharing options...
cypher Posted October 30, 2011 Author Share Posted October 30, 2011 That would give me a ton of if then if.... Has to be a way to combine them all. Quote Link to comment Share on other sites More sharing options...
Wanted Posted October 30, 2011 Share Posted October 30, 2011 const CheckX = 200; CheckY = 250; ClickX = 1200; ClickY = 900; Check_Wait = 250; var Colors: TIntegerArray; I, H: Integer; begin Colors := [17840, 206784, 245821, 12583814, 8652036, 986097, 1671065]; H := High(Colors); for I := 0 to H do if (GetColor(CheckX, CheckY) = Colors[i]) then begin ClickMouse(ClickX, ClickY, True); Break; end else Wait(Check_Wait); end. Quote Link to comment Share on other sites More sharing options...
Bixby Sayz Posted October 30, 2011 Share Posted October 30, 2011 I choose a different approach, plus I thought he wanted to check color under mouse cursor as the mouse roams around? program New; const WaitTime = 25; var X, Y, Color: Integer; SearchColors: TIntArray; begin ClearDebug; // Colors to search for SearchColors := [17840, 206784, 245821, 12583814, 8652036, 986097, 1671065]; // Repeat until user presses ESC key repeat // Get color at/under mouse GetMousePos(X, Y); Color := GetColor(X, Y); // If color matches our search colors, then click mouse if TIAContains(SearchColors, Color) then begin writeln('Color ' + IntToStr(Color) + ' found at position (' + IntToStr(X) + ',' + IntToStr(Y) + ')'); ClickMouse(X, Y, TRUE); end; // Small wait to reduce lag Wait(WaitTime); until IsKeyDown(VK_ESCAPE); end. Quote Link to comment Share on other sites More sharing options...
Wanted Posted October 30, 2011 Share Posted October 30, 2011 Yea idk, it's kind of hard to understand which he meant. Quote Link to comment Share on other sites More sharing options...
cypher Posted October 30, 2011 Author Share Posted October 30, 2011 (edited) Yes what I want is to move my mouse around and when the colour is under the cursor I want it to click. I'll try the codes out, thanks for your help --- Gives me error at line 23 Unknown identifier "TIAContains" Edited October 30, 2011 by Freddy Quote Link to comment Share on other sites More sharing options...
Bixby Sayz Posted October 30, 2011 Share Posted October 30, 2011 (edited) I'm using v3.28 beta of SCAR. Never occurred to me you might be using 3.27 (which I'm guessing does not contain that function). Try this function to do your compare instead of TIAContains. Ripped this off quickly has no bounds checking at all. function IntInArray(const Value: Integer; const IntArray: TIntArray): Boolean; var I: Integer; begin for I := 0 to High(IntArray) do begin Result := (Value = IntArray[i]); if Result then Exit; end; end; And this line if TIAContains(SearchColors, Color) then would now be if IntInArray(Color, SearchColors) then Edited October 30, 2011 by Bixby Sayz Quote Link to comment Share on other sites More sharing options...
cypher Posted October 30, 2011 Author Share Posted October 30, 2011 (edited) Where can I download v3.28 ??? Searched all over cant find it. And ty, your script works great! Edited October 30, 2011 by cypher Quote Link to comment Share on other sites More sharing options...
Bixby Sayz Posted October 30, 2011 Share Posted October 30, 2011 Unless you have a pressing need to have the latest greatest features of 3.28 beta I wouldn't update. It is still beta and subject to change. Plus you need a subversion client to download it (do not simply save using your browser - causes a world of hurt). http://forums.scar-divi.com/showthread.php?198-SCAR-Divi-3.28-Beta Quote Link to comment Share on other sites More sharing options...