SRL Archive - Research & Development Lounge

HBMouse/HAMouse


Sandstorm

2008-10-19 20:10:05

Human Mouse.

I thought it might be useful, because a human doesn't send the mouse to the point at the EXACT same speed, they slow down a bit. Mmouse and Mouse are used, so SRL has to be used with it.

Use:

HMouse(X, Y, Rx, Ry, Click, Left)

x, y, rx, ry are the same as in Mouse/Mmouse. Click is whether or not to click. Left is left or right click.


What is does:


1. Gets starting Mouse speed, logs it as Startspeed.
2. Moves mouse within 20-25 pixels of object.
3. Reduces Mouse speed, by 5.
4. Read #2, within 10-15 pixels of object.
5. Read #3.
6. Clicks object, or just leaves mouse there, depending on settings.
7. Reverts Mouse speed to Startspeed.

Here it is:

program New;
{.include srl/srl.scar}

var
x, y, xx, yy: integer;

procedure HMouse(x, y, Randx, Randy: integer; click, left: boolean);
var
Startspeed: integer;
begin
Startspeed := MouseSpeed;
WriteLn('Mouse speed is: ' + IntToStr(MouseSpeed));
WriteLn('X is: ' + IntToStr(x) + ' Y is: ' + IntToStr(y));
Xx := x;
Yy := y;
GetMousePos(x, y);
if (x < Xx) and (y < yy) then
begin
x := Xx
y := Yy
WriteLn('Mouse speed: ' + IntToStr(Mousespeed));
WriteLn('Above');
wait(1)
Mmouse(x - 20 - random(5), y - 20 - random(5), Randx, Randy);
Mousespeed := Mousespeed - 5 - random(2);
WriteLn('Mouse speed: ' + IntToStr(Mousespeed));
wait(1)
Mmouse(x - 10 - random(5), y - 10 - random(5), Randx, Randy);
Mousespeed := Mousespeed - 5 - random(2);
WriteLn('Mouse speed: ' + IntToStr(Mousespeed));
wait(1)
if Click then
begin
if Left then
begin
Mouse(x, y, Randx, Randx, true);
end else
Mouse(x, y, Randx, Randx, false);
end else
Mmouse(x, y, Randx, Randx);
MouseSpeed := StartSpeed;
end else
begin
x := Xx
y := Yy
WriteLn('Below');
wait(1);
Mmouse(x + 20 + random(5), y + 20 + random(5), Randx, Randy);
Mousespeed := Mousespeed - 5 + random(2);
WriteLn('Mouse speed is: ' + IntToStr(MouseSpeed));
wait(1)
Mmouse(x + 10 + random(5), y + 10 + random(5), Randx, Randy);
Mousespeed := Mousespeed - 5 + random(2);
WriteLn('Mouse speed is: ' + IntToStr(MouseSpeed));
wait(1)
if Click then
begin
if Left then
begin
Mouse(x, y, Randx, Randx, true);
end else
Mouse(x, y, Randx, Randx, false);
end else
Mmouse(x, y, Randx, Randx);
MouseSpeed := StartSpeed;
end;
end;

begin
Setupsrl;
Mousespeed := 15
Wait(1000)
if FindColorTolerance(x, y, 3428189, MIX1, MIY1, MIX2, MIY2, 10) then
HMouse(x, y, 3, 3, True, True);
end.

HBMouse is for when the mouse is below the item. HAMouse for above.

The color I used in FindColorTolerance to test it is the cork on a Vial.

Things I'd like to work on:


Effectiveness. Right now it has the same mousespeed reduction. I'm going to change that, since it's not hard + makes it less detectable then the speed always reducing by the same. Expect an edit soon.

The length. Right now, it's grossly overgrown. I'm gonna see if I can change this. Any suggestions?

Also, looking for feedback on the procedure itself :). This is my first selfmade one, but I think it works decently and is useful.

~Sandstorm

Edit:

Sorry for the ugly code! Updated it :).

Edit Two:

Updated it - it's now got inbuilt detection - only four (one being Wait) procedures called in the Mainloop now!

Added in Right Clicking capability.

Still looking at same x/y axis detectability, if I can do it.

mixster

2008-10-20 02:38:02

I would think it would be better to see SRL M/Mouse and adjust that to lower mouse speed as it comes closer to the end of it's arc. Also, your current procedure doesn't allow right clicking, which is what the Left boolean at the end of Mouse is for, so you should instead use a type or make a moving procedure and a clicking procedure (like SRL does) :)
Also, I would suggest making inbuilt detection of if it's above or below and maybe also the side, as I don't think yours takes into account if you were moving along the x axis rather than y and x ;)

Sandstorm

2008-10-22 19:45:29

@Inbuilt Detection - that's what I was working on before net was cut off, then I couldn't test it.

@Side Check - I don't think it's going to be often that it is on the exact same y or x axis as the object. I'll look into it anyways.

@Right Clicking - I thought it did. I'll look into it.

Thanks for the suggestions. I might try editing srl's M/Mouse, but not very good at scripting yet :P.

Sandstorm

2008-10-23 17:44:26

Updated it. Thanks for pointing those errors out Mixster, it now right clicks and detects whether it's above/below, in the procedure.

Will look into Side Checking.

Still looking for feedback.

~Sandstorm