Sign in to follow this  
Followers 0
james3mg

MouseMove() dual-monitor problem?

11 posts in this topic

I want to make sure this is a bug before I post in the Bugs section...

Here's the script I wrote for fun (something similar may exist, I don't know)

#Include <Misc.au3>
While 1
 If _IsPressed(11) = 1 AND _IsPressed(12) = 1 AND _IsPressed(27) = 1 Then MouseMove(MouseGetPos(0)+1,MouseGetPos(1),0);right
 If _IsPressed(11) = 1 AND _IsPressed(12) = 1 AND _IsPressed(25) = 1 Then MouseMove(MouseGetPos(0)-1,MouseGetPos(1),0);left
 If _IsPressed(11) = 1 AND _IsPressed(12) = 1 AND _IsPressed(28) = 1 Then MouseMove(MouseGetPos(0),MouseGetPos(1)+1,0);up
 If _IsPressed(11) = 1 AND _IsPressed(12) = 1 AND _IsPressed(26) = 1 Then MouseMove(MouseGetPos(0),MouseGetPos(1)-1,0);down
 ;ToolTip(MouseGetPos(0) & "," & MouseGetPos(1))
WEnd
Running this will allow you to control the mouse cursor with Ctrl+Alt and the arrow keys. The commented line at the end was helping me troubleshoot the following problem:

I have a dual-monitor card in my computer. Monitor 2 is my primary monitor, and to the left of monitor 1. They both have a resolution of 1280 by 1024 with 0 offset in the Y direction from each other (I'm probably saying that wrong). Though this script works fine on my primary monitor (monitor 2...thanks for that, windows), it acts strangely on monitor 1. When the cursor is on monitor 2, this script will not move it left anymore. Also, up turns to diagonal up and to the right, down becomes diagonal down and to the right, and right moves twice as fast as on monitor 2. It's like when an arrow key is pressed, it adds a right press to it as well, thus cancelling out left and adding right movement to the other directions. Note that normal mouse movement is not affected, only keyboard control via this script.

I just don't understand why this 'bug' would only show up on one monitor, rather than all the time, or not at all!

Anybody have any ideas, or should I post a topic in the bugs forum?


"There are 10 types of people in this world - those who can read binary, and those who can't.""We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true." ~Robert Wilensky0101101 1001010 1100001 1101101 1100101 1110011 0110011 1001101 10001110000101 0000111 0001000 0001110 0001101 0010010 1010110 0100001 1101110

Share this post


Link to post
Share on other sites



james3mg,

I have my monitor 2 setting on top of my monitor 1. When I run your script it works fine on either monitor. The one strange thing that happens is when I use CTRL-ALT-Up when the cursor is on my bottom monitor 1, it stops at the top and will not move on to monitor 2 until I use my mouse to get it past that barrier. But when I use CTRL-ALT-Down from my top monitor 2, it passes fine to the bottom monitor 1. It just can't go back up again without the help of my mouse.

taurus905


"Never mistake kindness for weakness."-- Author Unknown --"The highest point to which a weak but experienced mind can rise is detecting the weakness of better men."-- Georg Lichtenberg --Simple Obfuscator (Beta not needed.), Random names for Vars and Funcs

Share this post


Link to post
Share on other sites

I have my monitor 2 on the right. On monitor 1 your script works fine. I can move the cursor to monitor 2 using CTRL-ALT-RIGHT (there's no barrier) but on monitor 2 the cursor only want to go to the right. CTRL-ALT-LEFT don't work. CTRL-ALT-UP will move diagonally to rightup und CTRL-ALT-DOWN will move diagonally rightdown.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

OK, there's definately a problem with either MouseGetPos() or MouseMove() when there's multiple monitors in a side-by-side configuration. I ran this script:

MouseMove(1500,600)
Sleep(1000)
MsgBox(0,"Mouse Coordinates should be 1500,600",MouseGetPos(0) & "," & MouseGetPos(1))
and it returned "1501,600". According to AutoItWinInfo, the mouse is actually at 1501,600, but presumably that program uses the same MouseGetPos() as the scripts, so I can't tell which one is off by one pixel. However, if I tell windows my monitors are one above the other and send the mouse to 600,-600 (onto the secondary monitor, which is above and therefore negative Y from primary monitor which is 0,0), it correctly returns the coordinates. So maybe it's only in side-by-side configuration, or maybe it's only above certain resolutions, I'm not sure. I can't tell because you can't MouseMove() the cursor past the edge of the screen(s)

Developers or moderators: This looks like a bug to me, do you think I should post it in the Bugs section? I don't know all the conditions, obviously, but if you MouseMove() the cursor somewhere and MouseGetPos() returns a different value, something seems to be messed up in one of these functions, right?

Edit: spelling

Edited by james3mg

"There are 10 types of people in this world - those who can read binary, and those who can't.""We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true." ~Robert Wilensky0101101 1001010 1100001 1101101 1100101 1110011 0110011 1001101 10001110000101 0000111 0001000 0001110 0001101 0010010 1010110 0100001 1101110

Share this post


Link to post
Share on other sites

maybe it's just my pc but i ran the code, and it fliped my screen upside down. If i moved the mouse down, it would go up, and everthing else was upside down, and now my pc is lagging ALOT. anyone else having this problem?

Share this post


Link to post
Share on other sites

maybe it's just my pc but i ran the code, and it fliped my screen upside down. If i moved the mouse down, it would go up, and everthing else was upside down, and now my pc is lagging ALOT. anyone else having this problem?

That sounds pretty odd, considering the simplicity of code...a few questions for you:

-Do you mean that when you moved the physical mouse, the cursor moved the wrong direction, or that using the keyboard controls, it moved the wrong direction?

-'everything else' being upside-down - do you mean visually icons and wallpapers and your task bar were upside down, so if you physically turned your monitor over it would look right?

-Did you try ending the program via the tray icon?

-How many monitors do you have and in what configuration?


"There are 10 types of people in this world - those who can read binary, and those who can't.""We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true." ~Robert Wilensky0101101 1001010 1100001 1101101 1100101 1110011 0110011 1001101 10001110000101 0000111 0001000 0001110 0001101 0010010 1010110 0100001 1101110

Share this post


Link to post
Share on other sites

1. both

2. yes

3. no

4. one monitor. what do you mean by config? my screen size is 700 by 1200 (approx)

Share this post


Link to post
Share on other sites

1. both

2. yes

3. no

4. one monitor. what do you mean by config? my screen size is 700 by 1200 (approx)

Wow...there's gotta be something much bigger going on here, 'cause you can see the code can't do that on its own. I wonder (since you listed your screen size as narrow and tall) if you have some other piece of software (nvidia, etc) that rotates your screen, and maybe Ctrl+Alt+{arrow keys} are hotkeys for that program? Try using that key combination without running the script and see if the same thing happens...

(btw, by screen "config", I assumed you had several monitors and was asking how they were arranged next to each other - since you don't, then this wouldn't apply to you).


"There are 10 types of people in this world - those who can read binary, and those who can't.""We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true." ~Robert Wilensky0101101 1001010 1100001 1101101 1100101 1110011 0110011 1001101 10001110000101 0000111 0001000 0001110 0001101 0010010 1010110 0100001 1101110

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

Sorry to bump this topic out of the wreckage, but I posted a bug report here and it will be fixed in beta 3.2.1.2. Just for everyone's information, if you're looking at this post and want to use the script to control your cursor with your keyboard, you'll be able to soon. :)

Edited by james3mg

"There are 10 types of people in this world - those who can read binary, and those who can't.""We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true." ~Robert Wilensky0101101 1001010 1100001 1101101 1100101 1110011 0110011 1001101 10001110000101 0000111 0001000 0001110 0001101 0010010 1010110 0100001 1101110

Share this post


Link to post
Share on other sites

you could also try:

Func _MouseClickPlus($Window, $Button = "left", $X = "", $Y = "", $Clicks = 1)
  Local $MK_LBUTTON       =  0x0001
  Local $WM_LBUTTONDOWN   =  0x0201
  Local $WM_LBUTTONUP     =  0x0202
  
  Local $MK_RBUTTON       =  0x0002   
  Local $WM_RBUTTONDOWN   =  0x0204
  Local $WM_RBUTTONUP     =  0x0205

  Local $WM_MOUSEMOVE     =  0x0200
  
  Local $i                = 0
  
  Select 
  Case $Button = "left"
     $Button     =  $MK_LBUTTON
     $ButtonDown =  $WM_LBUTTONDOWN
     $ButtonUp   =  $WM_LBUTTONUP
  Case $Button = "right"
     $Button     =  $MK_RBUTTON
     $ButtonDown =  $WM_RBUTTONDOWN
     $ButtonUp   =  $WM_RBUTTONUP
  EndSelect
  
  If $X = "" OR $Y = "" Then
     $MouseCoord = MouseGetPos()
     $X = $MouseCoord[0]
     $Y = $MouseCoord[1]
  EndIf
  
  For $i = 1 to $Clicks
     DllCall("user32.dll", "int", "SendMessage", _
        "hwnd",  WinGetHandle( $Window ), _
        "int",   $WM_MOUSEMOVE, _
        "int",   0, _
        "long",  _MakeLong($X, $Y))
        
     DllCall("user32.dll", "int", "SendMessage", _
        "hwnd",  WinGetHandle( $Window ), _
        "int",   $ButtonDown, _
        "int",   $Button, _
        "long",  _MakeLong($X, $Y))
        
     DllCall("user32.dll", "int", "SendMessage", _
        "hwnd",  WinGetHandle( $Window ), _
        "int",   $ButtonUp, _
        "int",   $Button, _
        "long",  _MakeLong($X, $Y))
  Next
EndFunc  ;==>MouseClickPlus
;-----------------------------------------------------
Func _MakeLong($LoWord,$HiWord)
  Return BitOR($HiWord * 0x10000, BitAND($LoWord, 0xFFFF))
EndFunc  ;==>MakeLongoÝ÷ ٩ݶ§jëh×6Func MouseX()

_MouseClickPlus("title", "left/right",  Y, X, Clicks)
;Sleep(1000)

EndFunc

:)!


[quote name='AceLoc']I gots new sunglasses there cool.[/quote]

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

:):P:D

Um...and what exactly does that take the place of in my widdle ol' script? Or is that a verification of what the problem was before beta .2? I just can't even figure out how to call the functions... :D I'm not that good yet...dlls still stump me.

Edited by james3mg

"There are 10 types of people in this world - those who can read binary, and those who can't.""We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true." ~Robert Wilensky0101101 1001010 1100001 1101101 1100101 1110011 0110011 1001101 10001110000101 0000111 0001000 0001110 0001101 0010010 1010110 0100001 1101110

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0