Jump to content
Macro Express Forums

Mouse Move Math


Recommended Posts

I tried searching for "Mouse Move" but can't find a thing, so sorry if this is an oft-requested issue.

 

I am trying to move my cursor from one end of screen to another, on the same X-Axis.

 

However, I can't understand the logic behind this function.

 

I set X and Y integer variables from mouse position. Then I add a number to X axis integer with modify integer, then supply both results into the X and Y fields of Mouse Move.

 

However, the result varies depending on where the mouse is, ie-further away from top left screen, further the mouse moves. I even tried feeding the mouse move function with unedited mouse X/Y parameters... and it STILL moves somewhere else from where it was.

 

I'm not a beginner with this stuff. It just seems counter-intuitive the way this is playing out.

Thanks for any input!

Link to comment
Share on other sites

That sounds strange. Perhaps your actual mouse is interfering. Or the mouse control software. Try turning your mouse of and disabling any mouse software like Logitech's SetPoint. Them maybe post a simple sample macro that produces the unexpected behavior and one of us can try it.

Link to comment
Share on other sites

Variable Set Integer %DesktopWidth%: Set to the Desktop Width
Variable Set Integer %DesktopHeight%: Set to the Desktop Height
Variable Modify Integer: %DesktopHalfHeight% = %DesktopHeight% / 2
Text Box Display: Ready to move mouse pointer to left side of screen
Mouse Move: 0, %DesktopHalfHeight% Relative to Current Window
Text Box Display: Ready to move mouse pointer to right side of screen
Mouse Move: %DesktopWidth%, %DesktopHalfHeight% Relative to Current Window

<VARIABLE SET INTEGER Option="\x1D" Destination="%DesktopWidth%"/>
<VARIABLE SET INTEGER Option="\x1E" Destination="%DesktopHeight%"/>
<VARIABLE MODIFY INTEGER Option="\x03" Destination="%DesktopHalfHeight%" Value1="%DesktopHeight%" Value2="2"/>
<TEXT BOX DISPLAY Title="Ready to move mouse pointer to left side of screen" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang4105{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs16 0, %DesktopHalfHeight%\\f1 \r\n\\par }\r\n" Left="Center" Top="Center" Width="278" Height="200" Monitor="0" OnTop="FALSE" Keep_Focus="TRUE" Mode="\x00" Delay="0"/>
<MOUSE MOVE Option="\x02" X="0" Y="%DesktopHalfHeight%" _PROMPT="0x000A"/>
<TEXT BOX DISPLAY Title="Ready to move mouse pointer to right side of screen" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang4105{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs16 %DesktopWidth%, %DesktopHalfHeight%\\f1 \r\n\\par }\r\n" Left="Center" Top="Center" Width="278" Height="200" Monitor="0" OnTop="FALSE" Keep_Focus="TRUE" Mode="\x00" Delay="0"/>
<MOUSE MOVE Option="\x02" X="%DesktopWidth%" Y="%DesktopHalfHeight%" _PROMPT="0x000A"/>

Try running this test macro. It moves the mouse cursor to the left edge of the screen (x = 0); and then to the right edge of the screen (x = ScreenWidth)

 

The macro uses y = half the screen height.

 

In other words, from (0, y) to (ScreenWidth, y)

Link to comment
Share on other sites

I ran the macro and it works as I expect after reading it. No matter where the mouse is when it's launched it moved to the middle of the far left screen. Then I hit enter at the next dialog and it moves to the middle of the right screen. I tried this from various start positions and the result is always the same. Is this what you intended?

Link to comment
Share on other sites

Hi Alan,

 

I think the Mouse Move should be relative to the screen, not the current window?

 

 

Cory: So I'm surprised you got the result you described? As it stands, here the first move goes to the TBD.

 

With that change made to both move commands, it works fine. (Although I can't actually see the mouse cursor on my 1920 x 1080, until I nudge it a bit, or use the Mouse Locator.)

 

Rustywinger: Here's another example to complement Alan's:

// Get initial mouse position into variables.
Get Mouse Position into (nMouseX, nMouseY) Relative to Screen // Now move it to extreme left.
// Now move it to extreme left, leaving Y co-ordinate unchanged.
Mouse Move: 0, %nMouseY% Relative to Screen
Text Box Display: Check
// Now move it to extreme right, leaving Y co-ordinate unchanged.
// I've used an arbitray value of 600. Change it to your screen's width. Or use Alan's preset method.
Mouse Move: 600, %nMouseY% Relative to Screen
// Now it's at x = 600.

<COMMENT Value="Get initial mouse position into variables."/>
<GET MOUSE POSITION Option="\x00" X="nMouseX" Y="nMouseY" _COMMENT="Now move it to extreme left."/>
<COMMENT Value="Now move it to extreme left, leaving Y co-ordinate unchanged."/>
<MOUSE MOVE Option="\x01" X="0" Y="%nMouseY%" _PROMPT="0x000A"/>
<TEXT BOX DISPLAY Title="Check" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang2057{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n{\\colortbl ;\\red255\\green0\\blue0;}\r\n\\viewkind4\\uc1\\pard\\qc\\b\\f0\\fs20 You should see your cursor at extreme left.\r\n\\par \r\n\\par (My 1920 x1080 screen has some sort of weird permanent offset, so I sometimes \\cf1 cannot\\cf0  see a cursor at an edge.)\r\n\\par \r\n\\par Close this to continue.\\f1 \r\n\\par }\r\n" Left="821" Top="Center" Width="337" Height="200" Monitor="0" OnTop="TRUE" Keep_Focus="TRUE" Mode="\x00" Delay="0"/>
<COMMENT Value="Now move it to extreme right, leaving Y co-ordinate unchanged."/>
<COMMENT Value="I've used an arbitray value of 600. Change it to your screen's width. Or use Alan's preset method."/>
<MOUSE MOVE Option="\x01" X="600" Y="%nMouseY%" _PROMPT="0x000A"/>
<COMMENT Value="Now it's at x=600."/>

You could instead use Relative to Last Position, instead of Relative to Screen, in which case your integer-modifying commands would have to reflect that.

 

If you're still unable to see why your own macro isn't working, post a simple extract so that we can take a look.

 

--
Terry, East Grinstead, UK

Link to comment
Share on other sites

I'm sorry, I didn't write that correctly. The mouse moves to the middle of the left side of my left screen then to the middle of the right side of my right screen. Exactly as the macro is written.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...