SRL Archive - SRL Archives

Shortened DidClick()...


Quickmarch

2009-09-30 15:39:28

Much shorter DidClick(…), works exactly the same for me.


Function DidClick(Red: Boolean; Time: integer): boolean;
var
TimeOut, x, y, Trash: integer;
begin
GetMousePos(x, y);
TimeOut := GetSystemTime + Time;
while (GetSystemTime < TimeOut) do
begin
Result := FindColor(Trash, Trash, 255 + (Integer(not(Red))*65280), x - 15, y - 15, x + 15, y + 15);
wait(5);
if (Result) then Break;
end;
end;

marpis

2009-09-30 16:47:06

That doesn't do the same thing. That only checks for 1 color.
I already shortened the function in the original thread but RM said it's unreadable :p

Quickmarch

2009-09-30 16:56:05

I thought it was only ment to check for one colour?

senrath

2009-09-30 17:00:57

From: Quickmarch
I thought it was only ment to check for one colour?


Nah, it checks for both. The reason is so that if it detects either color, it'll stop looking, but it'll result in false if it detects the color you weren't looking for.

Quickmarch

2009-09-30 17:02:46

Ah, yes. :) I guess this is isn't really needed then. :p

EvilChicken!

2009-10-02 16:20:51

I guess noone would mind me closing this, then?

mastaraymond

2009-10-02 16:31:52

I thought the title said DickClick, made me open this thread.. Disappointing result :-(