Relative Mouse Position Help

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
ForrrestMaster
Newbie
Posts: 8
Joined: Fri Sep 02, 2016 7:42 pm

Relative Mouse Position Help

Post by ForrrestMaster » Fri Sep 02, 2016 7:48 pm

Started using this program yesterday and I love it so far.

I was wondering if there was a way I can have a script use mouse positions inside the application itself. From what I have seen so far, the mouse location is based on monitor position, so I cant move the app at all. Is there some way to accomplish that? I debated using the built in window resolution and then have it move the application to the same spot each time the script is executed, but I wondered if there was an easier way first.

Thanks!

User avatar
JRL
Automation Wizard
Posts: 3526
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Re: Relative Mouse Position Help

Post by JRL » Fri Sep 02, 2016 7:59 pm

I debated using the built in window resolution and then have it move the application to the same spot each time the script is executed...
Not a bad idea to move the application window to the same location and resize it to the same size within the script but not always necessary either.

As for mouse moves, there are two functions for moving the mouse. MouseMove> places the mouse cursor relative to the absolute coordinates of the screen. MouseMoveRel> (mouse move relative) places the mouse cursor relative to the 0,0 coordinates of the currently focused window. Therefore, good practice would have you SetFocus> on the window you are moving relative to prior to moving the mouse.

ForrrestMaster
Newbie
Posts: 8
Joined: Fri Sep 02, 2016 7:42 pm

Re: Relative Mouse Position Help

Post by ForrrestMaster » Fri Sep 02, 2016 8:14 pm

JRL wrote: MouseMoveRel> (mouse move relative) places the mouse cursor relative to the 0,0 coordinates of the currently focused window. Therefore, good practice would have you SetFocus> on the window you are moving relative to prior to moving the mouse.
Thank you for your reply!

If I am understanding you correctly

Code: Select all

SetFocus>ApplicationWindow
MoveMouseRel>X,Y
And just use the macro editor, change mouse cords to relative, and copy those cords from the mouse? Would I have to click the application that is the target for the macro first to make it the Active Window?

User avatar
JRL
Automation Wizard
Posts: 3526
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Re: Relative Mouse Position Help

Post by JRL » Fri Sep 02, 2016 8:51 pm

SetFocus> makes the application window the active window. No need to also click on the window with the mouse.

To get the correct mouse coordinates to use MouseMoveRel> I usually move my window so the upper left corner of the window is at the 0,0 position of the screen. However that is just old habit. There is now a better way.

In the editor you can pick the drop down menu associated with the mouse coordinate display. One of the choices is "Relative". After picking the "Relative" menu item, the display will show the mouse coordinates relative to whatever window the mouse cursor is hovering over. So, then, yes, just use those numbers as the X,Y parameters in the MouseMoveRel> function.

If you also pick "Follow Cursor" from that same drop down menu, the cursor coordinates will display next to the mouse cursor... AND if you click both the left and right mouse buttons simultaneously, the mouse cursor coordinates will be placed in the clipboard. All you need do is paste them in behind MouseMoveRel>.

ForrrestMaster
Newbie
Posts: 8
Joined: Fri Sep 02, 2016 7:42 pm

Re: Relative Mouse Position Help

Post by ForrrestMaster » Fri Sep 02, 2016 9:00 pm

JRL wrote: if you click both the left and right mouse buttons simultaneously, the mouse cursor coordinates will be placed in the clipboard. All you need do is paste them in behind MouseMoveRel>.

That is a time saver, thank you so much!

Post Reply
cron
Sign up to our newsletter for free automation tips, tricks & discounts