Drifting mouse in multi monitor AHK scripts

10 views
Skip to first unread message

Tube...@gmail.com

unread,
Apr 23, 2007, 12:40:27 PM4/23/07
to alphagrip
Good news for people who like to use a mouse booster in Auto Hotkey
with a multi monitor setup: I have found 1) what causes the drifting
on the secondary monitor and 2) how to fix it!

It turns out that the MouseMove command has a bug when using negative
coordinates. This only affects monitors that are displayed to the left
of and/or above the primary monitor. The mouse will actually move 1
pixel towards the origin (upper left corner of the primary monitor) of
the negative coordinate (down or right depending on which is the
negative coordinate) on every iteration of the script. You can verify
this by making a stationary "booster" script that moves the mouse to
the location where it already is:

MouseGetPos, PosX, PosY
MouseMove, PosX, PosY, 0

This trivial script exhibits mouse drifting if your secondary display
is to the left of and/or above your primary monitor. I found that
MouseGetPos does return the correct values, but that the point -1,-1
maps to 0,0 in the MouseMove command.

The way to fix this is to subtract 1 from the negative coordinate
before you call MouseMove.
For example, in Carl Andersen's multi monitor mouse booster, just add
the following code directly before the MouseMove command:

if (AdjMousePosx < 0) {
AdjMousePosx -= 1
}
if (AdjMousePosy < 0) {
AdjMousePosy -= 1
}

Hopefully this will solve the problem as it did for me :-)
Greetings,
>>Tubeliar

Reply all
Reply to author
Forward
0 new messages