SRL Archive - SRL Archives

MColour & MCColour


Rich

2008-11-17 14:08:10

Basically, I was bored, and decided to make colour finding and mouse moving easier, and into one function.

Since these use/are modified versions of MMouse and Mouse, I must give credits to Benland100, Mutant Squirrel, and Hy for modifying them. The actual credits for these functions go to meh :p

MColour:

{*******************************************************************************
function MColour(colour, tol, x, y, randx, randy, x1, y1, x2, y2 : Integer; uptxt : string):Boolean;
By: R1ch4 (Richard)
Description: If the colour specified was found in the box, it moves the mouse there,
and checks for the uptext.
Used: Eg. MColour(123456, 50, x, y, 7, 7, 0, 0, 50, 50, 'uptxt');
*******************************************************************************}

function MColour(colour, tol, x, y, randx, randy, x1, y1, x2, y2 : Integer; uptxt : string):Boolean;
var
a : Integer;
begin
repeat
if FindColorSpiralTolerance(x, y, colour, x1, y1, x2, y2, tol) then
begin
MMouse(x, y, randx, randy);
Wait(150 + Random(150));
if IsUpText(uptxt) then
Break;
end else
a:= a + 1;
end else
a:= a + 1;
until(a > 5);
end;

What this does is, if it finds the colour that was specified in the box that you set, it will move the mouse there, then check for the uptext. If the uptext and colour are both found, it returns true.

So instead of having to have
var a, x, y : Integer;

begin
repeat
if FindColorSpiralTolerance(123456, x, y, 0, 0, 50, 50, 50) then
begin
Wait(100 + Random(150))
MMouse(x, y);
if IsUpText('uptxt') then
Break;
else
a:= a + 1;
until(a > 5);
end;

You could just have
MColour(123456, 50, x, y, 7, 7, 0, 0, 50, 50, 'uptxt');
Easier?

MCColour:

{*******************************************************************************
function MCColour(colour, tol, x, y, randx, randy, x1, y1, x2, y2 : Integer; uptxt : string; left: Boolean):Boolean
By: R1ch4 (Richard)
Description: If the colour specified was found in the box, it moves the mouse to it,
checks for the uptext, then clicks.
Used: Eg. MCColour(123456, 50, x, y, 7, 7, 0, 0, 50, 50, 'uptxt', True);
*******************************************************************************}

function MCColour(colour, tol, x, y, randx, randy, x1, y1, x2, y2 : Integer; uptxt : string; left: Boolean);
var
a, b, c: Integer;
begin
repeat
if FindColorSpiralTolerance(x, y, colour, x1, y1, x2, y2, tol) then
begin
Mouse(x, y, randx, randy, left);
Wait(150 + Random)150));
if IsUpText(uptxt) then
Break;
else
a:= a + 1;
end else
a:= a + 1;
until(a > 5);
end;

What this does is the same as MColour, except that it clicks. I won't bother to write an example, but hopefully you can see how easier it is to use these.

If you want to use these, just place them in Mouse.scar, in the Core folder.

Thanks to everyone who helped me improve and pointed out little bugs!

HyperSecret

2008-11-17 16:10:13

Keep up the work. I honestly don't see these as being used but I could be wrong. A couple things :

1)FindColor isn't used much
2)No uptext check?
3)Maybe make it a function instead of procedure?
4)FindColorSpiral maybe too

Rich

2008-11-17 16:37:09

Thanks for the feedback. I'll do them later.

Baked0420

2008-11-17 17:13:26

maybe findcolortol(x,y,…. instead of findcolor, I use the tolerance everytime, I never use it w/o, and if you do need it to have no tolerance you can just put 0, so imo findcolortol would be more convenient. I like the idea though.

MylesMadness

2008-11-18 07:12:08

I shortened MCColour:
procedure MCColour(colour, x, y, randx, randy, x1, y1, x2, y2: Integer; left: Boolean);
var
a, b, c: Integer;
begin
repeat
if FindColor(x, y, colour, x1, y1, x2, y2) then
begin
Mouse(x, y, randx, randy, Left);
Break;
end else
a:= a + 1;
until(a > 5);
end;

Rich

2008-11-18 08:28:50

I don't see why I didn't do that Myles…Thanks, I probably would have noticed but I was tired when I made these. I'll change it to FindColorSpiralTolerance, and add an uptext check. I'll also make it as a function so it can be used as
if MCColour(bla) then
begin
//code
end else
Also, I'm just being curious, how many people would be interested in using this?

Rich

2008-11-18 09:25:14

Massive update!


They now both include checks for uptext, and use FindColorSpiralTolerance instead of just FindColor.
Also, they are both now functions, so if the uptext is found and the commands are fulfilled, it returns true, if not, then false.

Hope you like it!

Method

2008-11-18 10:09:12

You want to check for the uptext after you move the mouse, not beforehand. Plus, you want to add some wait after you move the mouse to make sure the uptext has completely appeared.

Rich

2008-11-18 10:16:37

Oh, I thought I put the uptext check after the mouse…Oh well, time for another edit. Thanks for pointing that out Method.

Richard

EDIT: Changed it.

Again, please say if you would even consider to use either of these functions.