getting mouseposition

Ranorex Spy, Recorder, and Studio.
wyll
Posts: 34
Joined: Wed Aug 01, 2012 3:19 pm

getting mouseposition

Post by wyll » Thu Aug 16, 2012 3:26 pm

hello,

Not sure if its a bug, but when i try to get the mouseposition X,Y and try to add 50 pixel to x my mouse goes diagonally right+down.

here is my codesnippet

Code: Select all

        int x,y;
                x = Mouse.Position.X;
        	y = Mouse.Position.Y;
        	Location a = new Location((x+50),y);
        	myrepo.myApp.Self.MoveTo(a);
it should only move to the right, no?
also tried to Report.info(x.toString()+y.toString()); y stays the same, but still mouse moves down

regards
wyll

[ps.: works fine when i try to add 50 to y, mouse goes up just fine

EDIT: ps is wrong, it actually moves to the spot i got the mouse position from

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: getting mouseposition

Post by Support Team » Fri Aug 17, 2012 10:24 am

Hello,

If you use the method "Adapter.MoveTo(Location location)" the mouse will move to the location relative to the adapter, as you can see in our online API: MoveTo.
If you want to move the mouse to a absolute location I would use the following code:
int x,y;
x = Mouse.Position.X;
y = Mouse.Position.Y;
Point point = new Point((x+50),y);
Mouse.MoveTo(point);
Regards,
Markus
Ranorex Support Team
.
Image

wyll
Posts: 34
Joined: Wed Aug 01, 2012 3:19 pm

Re: getting mouseposition

Post by wyll » Mon Aug 20, 2012 2:01 pm

Hello markus,

thank you a lot.
worked like a charm.

regards,
wyll