SRL Archive - SRL Archives

DidClick(Red: boolean, Time: integer): boolean; - Mouse.scar


Sir R. M8gic1an

2009-07-18 18:45:36


Function DidClick(Red: Boolean; Time: integer);
var
TimeOut, x, y, Trash: integer;
begin
GetMousePos(x, y);
TimeOut := GetSystemTime + Time;
while not GetSystemTime > TimeOut do
begin
wait(25);
if FindColor(Trash, Trash, 255, x - 5, y - 5, x + 5, y + 5) then
begin
if Red then
Result := true
else
Result := false;
break;
end;

if FindColor(Trash, Trash, 128, x - 5, y - 5, x + 5, y + 5) then
begin
if not Red then
Result := true
else
Result := false;
break;
end;
end;
end;

Function DidRedClick: boolean;
begin
Result := DidClick(true, 500);
end;

Function DidYellowClick: boolean;
begin
Result := DidClick(false, 500);
end;

{
useful to check if we clicked something correctly
}

what do you guys think?

~RM

Runescapian321

2009-07-18 18:52:25

Ooh, nice. I was thinking about something like this the other day. Will be useful. Rep++

Da 0wner

2009-07-18 19:10:53

Didn't somebody suggest this before, RM?

ian.

2009-07-18 19:33:49

Yes. I still don't know what it would be use for, though.

Sir R. M8gic1an

2009-07-18 19:34:25

From: Da 0wner
Didn't somebody suggest this before, RM?



probably, but it didn't get added, so here it is again.

~RM

DeSnob

2009-07-18 20:07:03

Might i just ask how this function works?

Home

2009-07-18 20:16:21

From: DeSnob
Might i just ask how this function works?


After you have called Mouse(x,y,0,0) [As Example] You will call Some of above functions to check is X Red or Yellow

I hope i helped :)

~Home

Da 0wner

2009-07-18 20:17:04

When you click a spot on RuneScape the cursor is red if an action other than move is performed, and it is red if you equipped an item, clicked an NPC, etc.

Edit: Ninja'd :(.

ShowerThoughts

2009-07-18 20:21:46

Not very original, but still nice to bring it up.

For the people who act like,"wtf, doez noez understandzz???".
When you click on the mainscreen, on the place you clicked will be an X which will be yellow or either red, AFAIK a yellow X means walking a different action will be a red X.

I think this is pretty clear :).

Dynamite

2009-07-18 20:40:17

ooh this could be useful for failsafe, say if you tried to click something but accidentally missed you could call this to check if you clicked it right?

T~M

ShowerThoughts

2009-07-18 21:01:07

From: The Man
ooh this could be useful for failsafe, say if you tried to click something but accidentally missed you could call this to check if you clicked it right?

T~M


Yes, possible but there are other things too.

Naum

2009-07-18 21:20:48

RM If you could maybe add one for getting the color after a click is Red. It would be useful for updating coal rock colors.

Such as:
Function UpdateColor(x, y : Integer) : TColor;
Begin
While DidRedClick Do
Wait(800)
Else
Result := GetColor(x, y);
End;

EvilChicken!

2009-07-18 23:52:17

Function DidClick(Red: Boolean; Time: integer): Boolean;
var
X, Y, tmpX, tmpY, TimeOut: Integer;
col: Byte;

begin
GetMousePos(x, y);
TimeOut := (GetSystemTime + Time);
if (Red) then
col := 255
else
col := 128;

while (GetSystemTime < TimeOut) do
begin
Wait(15 + Random(10));
Result := FindColor(tmpX, tmpY, col, X - 5, Y - 5, X + 5, Y + 5);
if (Result) then exit;
end;
end;

Function DidRedClick: Boolean;
begin
Result := DidClick(True, 500);
end;

Function DidYellowClick: Boolean;
begin
Result := DidClick(False, 500);
end;


begin
end.

By the way, I think I saw this in some fighter.
Might've been one of Narcle's.


By the way, why do you need two colorchecks?

Floor66

2009-07-18 23:55:48

Add an 'AreaSize' param? And make the max like 20.

Naum

2009-07-19 00:15:45

From: Floor66
Add an 'AreaSize' param? And make the max like 20.



Function DidClick(Bx, By : Integer; Red: Boolean; Time: integer): Boolean;
var
X, Y, tmpX, tmpY, TimeOut: Integer;
col: Byte;

begin
If (Bx > 20) Then BX := 20;
If (By > 20) Then BY := 20;
GetMousePos(x, y);
TimeOut := (GetSystemTime + Time);
if (Red) then
col := clRed
else
col := 128;

while (GetSystemTime < TimeOut) and (Not (Result)) Do
begin
Wait(15 + Random(10));
Result := FindColor(tmpX, tmpY, col, X - Bx, Y - By, X + Bx, Y + By);
end;
end;

Function DidRedClick: Boolean;
begin
Result := DidClick(5, 5, True, 500);
end;

Function DidYellowClick: Boolean;
begin
Result := DidClick(5, 5, False, 500);
end;

Function UpdateColor(Var x, y : Integer) : TColor;
Begin
While DidRedClick Do
Wait(800)
Else
Result := GetColor(x, y);
End;

Btw, It was suggested before here: http://www.villavu.com/forum/showthread.php?t=1320

Sir R. M8gic1an

2009-07-19 01:14:34

EC: i did two color checks because if it is the yellow x it obviously isn't the red x, and therefore if you want the red one AND you find a yellow one it avoids further looking for it.

~RM

Lance

2009-07-19 01:39:08

haha i made something like that before, i think i showed it to you kyle that might be what you were thinking of.

Daniel

2009-07-19 05:01:30

What what? Colour 128 is maroon, not yellow..

Quickmarch

2009-07-19 13:03:31

I used a simplified version of this in my goblin killer - it's very useful to check if you've clicked the goblin.

marpis

2009-07-19 13:26:45

I think this is a good idea but it should be put in some MouseEx() function or something?

function MouseEx(x, y, rx, ry: integer; red: boolean): boolean;
var
col, tmp, T: integer;
begin
col := Integer(red)*127 + 128;
Mouse(x, y, rx, ry, true);
T := GetSystemTime + 300;
while (GetSystemTime < T) do
begin
result := FindColor(tmp, tmp, col, x-5, y-5, x+5, y+5);
if result then exit;
end;
end;

and i think the box parameters BX, BY are useless. just make the box 10*10, there's no need to make it any bigger nor smaller.