Opened 3 years ago

Last modified 3 years ago

#3182 new Bug

MouseGetPos may return the wrong value when used with mulitple display screens.

Reported by: philkryder Owned by:
Milestone: Component: AutoIt
Version: Severity: None
Keywords: MouseGetPos MouseMove Cc:


This problem occurs when there are screens which return a negative value from MouseGetPos. These screens are to the LEFT of the "main screen."
That is, the mouse must be at a position returning negative values for x and/or y

In the code below, when the mouse is positioned to the left of the main screen, the mouse will move to the right toward the main screen, one-pixel-at-a-time.
Similarly, if there is a screen which has negative Y values,
the mouse one pixel at a time toward zero.

Please see:

    Sleep (1500) 
    Local $x = MouseGetPos(0)
    Local $y = MouseGetPos(1)
    Consolewrite(@CR & "x  >" & $x & "<   y>" & $y & "<")

here are the results on Windows 7

"C:\Program Files (x86)\AutoIt3\SciTE\..\AutoIt3.exe" "C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.au3" /run /prod /ErrorStdOut /in "R:\Operations\MacroTools\AutoIT\keepWindowUnlocked\TrackerCode.au3" /UserParams

+>15:47:00 Starting AutoIt3Wrapper v.15.920.938.0 SciTE v. Keyboard:00010409 OS:WIN_7/Service Pack 1 CPU:X64 OS:X64 Environment(Language:0409)
+> SciTEDir => C:\Program Files (x86)\AutoIt3\SciTE UserDir => C:\Users\Pkryder\AppData\Local\AutoIt v3\SciTE\AutoIt3Wrapper SCITE_USERHOME => C:\Users\Pkryder\AppData\Local\AutoIt v3\SciTE

Running AU3Check ( from:C:\Program Files (x86)\AutoIt3 input:R:\Operations\MacroTools\AutoIT\keepWindowUnlocked\TrackerCode.au3

+>15:47:00 AU3Check ended.rc:0

Running:(\Program Files (x86)\AutoIt3\autoit3.exe "R:\Operations\MacroTools\AutoIT\keepWindowUnlocked\TrackerCode.au3"

--> Press Ctrl+Alt+Break to Restart or Ctrl+Break to Stop

x >-3334< y>-131<
x >-3333< y>-130<
x >-3332< y>-129<
x >-3331< y>-128<
x >-3330< y>-127<
x >-3329< y>-126<
x >-3328< y>-125<
x >-3327< y>-124<

Process failed to respond; forcing abrupt termination...
Exit code: 1 Time: 13.53

Attachments (0)

Change History (2)

comment:1 Changed 3 years ago by BrewManNH

As I explained in your thread it's not MouseGetPos that is at fault, it is the MouseMove that is causing this issue.

MouseMove is moving the mouse 1 pixel to the right of where it should be when the screen position is negative. It could be that MouseMove isn't taking into account that a the x dimension on the left hand monitor starts (ends?) at -1 and not at 0. So a 1920 pixel wide monitor has mouse positions from -1 to -1920, and if it were the main screen those dimensions would be 0 to 1919.

comment:2 Changed 3 years ago by philkryder

Thanks - I hesitate to say that I know what is going wrong.
I'm happy to accept that you know.

The symptom also occurs to the y coordinate as well as x.

Guidelines for posting comments:

  • You cannot re-open a ticket but you may still leave a comment if you have additional information to add.
  • In-depth discussions should take place on the forum.

For more information see the full version of the ticket guidelines here.

Add Comment

Modify Ticket

as new The ticket will remain with no owner.

E-mail address and user name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.