SRL Archive - SRL Suggestions

Mouse functions


masterBB

2012-05-02 03:15:08

Every time I wrote a script I used the following combination a lot:

GetMousePos(x,y);
Mouse(x,y,2,2,mouse_Left);

It is exactly quit an odd piece of code. I wouldn't expect this to be needed to click with barely moving the mouse. Why do I need to declare two integers, which don't even got proper naming in this example, when I don't do anything with them?

My suggestion?
Use a TPoint instead of an x and y value for all the mouse functions. So it can look like this:

Mouse(MousePos(),2,2,mouse_Left);

  • The code is shorter.
  • It is self explanatory.
  • It looks clean.
  • It does exactly what is says.
  • And It doesn't involve me declaring two variables called x and y.

I didn't write the code because I wanted to discuss this idea here and I don't think it really adds something. Discuss!

edit:
Maybe we can do this in the lape branch with overloading. That would work so nice.

xtrapsp

2012-05-02 03:22:06

I've never used GetMousePos(x,y); to be honest

so would it be

GetMousePos(x,y);
if MousePos(25, 45) then
Mouse(MousePos(),2,2,mouse_Left);

Or something like that?

Sirenia

2012-05-02 03:24:48

Why not just ClickMouse2(True); ? :/

masterBB

2012-05-02 03:44:23

From: Sirenia
Why not just ClickMouse2(True); ? :/


Cause that code is ugly. Also mine still got some random movement in it. Besides this isn't just for GetMousePos. What if you got an array of TPoints and want to check them all? When this function is overloaded in lape you can just do:

if(FindDtms(myDTM, someOtherParams, DTMPoints)) then
for i := High(DTMPoints) downto 0 do
begin
MMouse(DTMPoints[i],5,5);
if(GetUpText = "MyMonstersName") then
break;
end;

I understand it is not required, but with the option in lape to overload you aren't really loosing anything. You could just add the following to Mouse.simba:
procedure Mouse(MousePoint: TPoint; ranx, rany: Integer; button:Variant); overload;
begin
Mouse(MousePoint.x, MousePoint.y, ranx, rany, button);
end;

Daniel

2012-05-02 04:24:46

From: masterBB
Cause that code is ugly.

How is it ugly?

Complete Lape support and abandonment for PascalScript in SRL won't happen for quite some time.

masterBB

2012-05-02 04:27:29

From: Daniel
How is it ugly?

Complete Lape support in SRL won't happen for quite some time.


It doesn't use the SRL 5 mouse constants. You can't make it use the middle mouse button. It doesn't say where it clicks in the name. I believe the 2 is added just because ClickMouse already existed.

edit:
I thought Nielsie his SRL branch would become the main branch in some time?

Daniel

2012-05-02 04:34:40

From: masterBB
It doesn't say where it clicks in the name. I believe the 2 is added just because ClickMouse already existed.


You have MoveMouse which moves the mouse, and ClickMouse which clicks the mouse? :p Mouse if you want to move + click, MMouse to just move, and ClickMouse2 to just click.

masterBB

2012-05-02 04:41:38

From: Daniel
You have MoveMouse which moves the mouse, and ClickMouse which clicks the mouse? :p Mouse if you want to move + click, MMouse to just move, and ClickMouse2 to just click.


Never mind about the srl constants part:P Didn't know that it also supported Boolean. But why is that 2 there? Still want mouse functions with TPoint as an option when srl goes full lape.

Mat

2012-05-02 04:48:04

I Use MMMouse then a small wait then click, but its personal preference :P

weequ

2012-05-02 04:53:37

Actually your method is currently quite detectable as it can only move mouse right and down. Try this
GetMousePos(x,y);
Mouse(x-1,y-1,3,3,mouse_Left);

I wish pascal/simba supported function overloading. Then we could have multiple procedures called "Mouse" where the only difference is the parameters.

masterBB

2012-05-02 05:07:17

I got the feeling not everyone understands that I do not want to write a different mouse function. Just change the x and y integer parameters to one TPoint, preferably by overloading. But can also be done by creating function clones like this:
procedure MousePoint(MousePoint: TPoint; ranx, rany: Integer; button:Variant);
begin
Mouse(MousePoint.x, MousePoint.y, ranx, rany, button);
end;


From: weequ
Actually your method is currently quite detectable as it can only move mouse right and down. Try this
GetMousePos(x,y);
Mouse(x-1,y-1,3,3,mouse_Left);

I wish pascal/simba supported function overloading. Then we could have multiple procedures called "Mouse" where the only difference is the parameters.


Might be tackled with this:

procedure Mouse(MousePoint: TPoint; ranx, rany: Integer; button:Variant); overload;
begin
Mouse(MousePoint.x-ranx, MousePoint.y-rany, ranx, rany, button);
end;

But maybe it would be better to change in the regular mouse method, oh well.

Sirenia

2012-05-02 06:46:50

From: masterBB
Never mind about the srl constants part:P Didn't know that it also supported Boolean. But why is that 2 there? Still want mouse functions with TPoint as an option when srl goes full lape.

Normal clicmouse clicks the mouse super fast and holds down the mouse like 1 milisec, clicmouse2 holds down the mouse alittle longer and with randomness :)

Harry

2012-05-02 06:51:34

Mouse with randomness will do a little "jitter". I don't like it personally. Unsure why it does it, but looks bad.

ReadySteadyGo

2012-05-02 07:34:37

In my opinion you shouldn't use any randomness after grabbing the mouse position. Clickmouse2 is an awful name though.

putonajonny

2012-05-02 09:12:15

From: ReadySteadyGo
In my opinion you shouldn't use any randomness after grabbing the mouse position. Clickmouse2 is an awful name though.


Yeah you would look very bot like shifting a couple of pixels just before you click every time you do

Abu

2012-05-02 14:21:37

Support. I would personally love to see TPoints replacing x and y as it has more uses.

From: Harry
Mouse with randomness will do a little "jitter". I don't like it personally. Unsure why it does it, but looks bad.


Would it be possible to do:
GetMousePos(x, y);
xe := x + Random(4); // add randomness before moving
ye := y + Random(4);
Mouse(xe, ye, 0, 0, True);
To remove that 'jitter'?

Brandon

2012-05-02 15:00:15

Op wants:

MMouse(TPoint, RandomX, RandomY);

or

MMouse(TPoint, TPoint);

or

ClickMouse(TPoint, MOUSE_ACTION);

or

GetMousePos(TPoint);

See? No X, Y parameters. Instead it takes a TPoint. Also what he's saying is that instead of having so many mouse functions it'd be cool if you could overload them so that one function can take various parameters and do that many things. His lape was just an example.