Log in

View Full Version : Finding colors



MatthiasGu
06-30-2011, 01:07 PM
So I've been trying to improve my first simba program to open the Internet Explorer from start menu on any machine so that it would detect the colours of the start menu and then click on it. However, I ran into troubles with the FindColor command. I just have no idea how to use it! Would someone be so kind as to give me an example how the command should be used because the SRL Wiki doesnt quite work for me :duh:.
Another thing, I am using Windows 7, so the start menu icon has a lot of different shades of blue from light blue to dark blue. Pretty much moving the cursor anywhere changes the colour, so how should I catch the correct colour?

weequ
06-30-2011, 03:24 PM
1) Set your desktop as client. You can do it manually or use SetDesktopAsClient();
2) Use the simba color picker to pick a color.
3) Use findcolor(x, y, color, x1, y1, x2, y2); to find the color
4) Use ClickMouse(x, y, true); to click the x and y coords saved by findcolor.

Here I will make an example for you.

program new;
var
x, y, w, h: Integer;//Declare the variables
begin
Wait(500);
SetDesktopAsClient();//This can also be done manually by targeting the desktop window with the "Set a client" tool.
GetClientDimensions(w, h);
if FindColor(x, y, 6408617, 0, 0, w-1, h-1) then//Searches for the whole client for the color picked by the color picker tool.
begin
MoveMouse(x, y);//Moves the mouse to the coords x, y where the color was first found.
ClickMouse(x, y, MOUSE_LEFT);//If the color was found it clicks the point where the color was first found.
end;
end.


Since the location of the start menu does not change you could as well just use coordinate clicking.
Example:

program new;
begin
SetDesktopAsClient();
MoveMouse(100, 100);//You can see coordinates on the bottom left corner of simba. Or you can use the color picker tool.
ClickMouse(100, 100, MOUSE_LEFT);
end.

Smarter Child
06-30-2011, 03:42 PM
Further knowledge/help can be found in the Simba doc: http://docs.wizzup.org/simba/scriptref/colourfinding.html

MatthiasGu
06-30-2011, 03:44 PM
Wow this works like a charm, thanks a lot!! :spot: