Jump to content

Recommended Posts

Posted

the code below reproduces a problem where the mouse moves one pixel to the right.

? why? - 


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

WEnd

 

Posted

philkryder,

When does the mouse move?  I ran it as follows...

>"C:\Program Files (x86)\AutoIt3\SciTE\..\AutoIt3.exe" "C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.au3" /run /prod /ErrorStdOut /in "C:\Users\ADMIN010\Documents\mousemove.au3" /UserParams    
+>20:05:33 Starting AutoIt3Wrapper v.15.729.1555.0 SciTE v.3.5.4.0   Keyboard:00000409  OS:WIN_7/Service Pack 1  CPU:X64 OS:X64    Environment(Language:0409)
+>         SciTEDir => C:\Program Files (x86)\AutoIt3\SciTE   UserDir => C:\Users\ADMIN010\AppData\Local\AutoIt v3\SciTE\AutoIt3Wrapper   SCITE_USERHOME => C:\Users\ADMIN010\AppData\Local\AutoIt v3\SciTE 
>Running AU3Check (3.3.14.1)  from:C:\Program Files (x86)\AutoIt3  input:C:\Users\ADMIN010\Documents\mousemove.au3
+>20:05:33 AU3Check ended.rc:0
>Running:(3.3.14.1):C:\Program Files (x86)\AutoIt3\autoit3.exe "C:\Users\ADMIN010\Documents\mousemove.au3"    
--> Press Ctrl+Alt+Break to Restart or Ctrl+Break to Stop

x  >670<   y>208<
x  >670<   y>208<
x  >670<   y>208<
x  >670<   y>208<
x  >670<   y>208<
x  >670<   y>208<
x  >670<   y>208<
x  >670<   y>208<
x  >670<   y>208<
x  >670<   y>208<
x  >670<   y>208<
x  >670<   y>208<
x  >670<   y>208<
x  >670<   y>208<
x  >670<   y>208<
x  >670<   y>208<
x  >670<   y>208<
x  >670<   y>208<
x  >670<   y>208<
x  >670<   y>208<
x  >670<   y>208<
x  >670<   y>208<
x  >670<   y>208<
x  >670<   y>208<
x  >670<   y>208<
x  >670<   y>208<
x  >670<   y>208<
x  >670<   y>208<
x  >670<   y>208<
x  >670<   y>208<
x  >670<   y>208<
x  >670<   y>208<
x  >670<   y>208<
x  >670<   y>208<
x  >670<   y>208<
x  >670<   y>208<
x  >670<   y>208<
x  >670<   y>208<
x  >670<   y>208<
x  >670<   y>208<
x  >670<   y>208<
x  >670<   y>208<
x  >670<   y>208<
x  >670<   y>208<
x  >670<   y>208<
x  >670<   y>208<
x  >670<   y>208<
x  >670<   y>208<
x  >670<   y>208<
x  >670<   y>208<
x  >670<   y>208<
x  >670<   y>208<
x  >670<   y>208<
x  >670<   y>208<
x  >670<   y>208<
x  >670<   y>208<
x  >670<   y>208<
x  >670<   y>208<
x  >670<   y>208<
x  >1081<   y>1006<+>20:07:05 AutoIt3.exe ended.rc:0
+>20:07:05 AutoIt3Wrapper Finished.
>Exit code: 0    Time: 92.92

kylomas

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Posted

hmm -

when I saw the problem, it was on my machine at work, where I have 4 monitors.

I just ran it here at home with only a single monitor and it works just fine....


x  >415<   y>372<
x  >415<   y>372<
x  >415<   y>372<
x  >415<   y>372<
x  >415<   y>372<
x  >415<   y>372<

Posted

so, I configured a second monitor at home.

At first there was no problem. But, then I changed the primary monitor and moved the mouse to the "negative" screen. 

Then, as shown below, the x value counted "upward" toward the right and toward zero. 
?is this as expected? why? 
And, is MouseMove causing the move? or does the MouseGetPos return the wrong value for x?

x  >-723<   y>188<
x  >-722<   y>188<
x  >-721<   y>188<
x  >-720<   y>188<
x  >-719<   y>188<
x  >-718<   y>188<
x  >-717<   y>188<
x  >-716<   y>188<
x  >-715<   y>188<
x  >-714<   y>188<
x  >-713<   y>188<
x  >-712<   y>188<
x  >-711<   y>188<

I'm going to try to see if the effect continues once x becomes a positive integer...

Posted

and here we have the problem stopping as soon as we reach zero...

x  >-4<   y>386<
x  >-3<   y>386<
x  >-2<   y>386<
x  >-1<   y>386<
x  >0<   y>386<
x  >0<   y>386<
x  >0<   y>386<
x  >0<   y>386<
x  >0<   y>386<
>Process failed to respond; forcing abrupt termination...
>Exit code: 1    Time: 58.65

 

Posted

That was easier to test than to ask the question. I commented out the MouseMove and the pointer stopped moving. With the mouse move in the mouse would move right by one pixel every loop. It stopped moving when it hit positive 8 on my computer.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Posted

here's a version with several MouseMoves - 

Local $x = MouseGetPos(0)
Local $y = MouseGetPos(1)

While(True)
    MouseMove($x,$y,0)
    MouseMove($x,$y,0)
    MouseMove($x,$y,0)
    MouseMove($x,$y,0)
    MouseMove($x,$y,0)
    MouseMove($x,$y,0)
    MouseMove($x,$y,0)
    MouseMove($x,$y,0)
    MouseMove($x,$y,0)
    MouseMove($x,$y,0)
    MouseMove($x,$y,0)
    MouseMove($x,$y,0)
    MouseMove($x,$y,0)

    Sleep (1500) ;(3*60*100) ; sleep 3 minutes

    $x = MouseGetPos(0)
    $y = MouseGetPos(1)

    Consolewrite(@CR & "x  >" & $x & "<   y>" & $y & "<")

WEnd


x  >-3660<   y>201<
x  >-3659<   y>201<
x  >-3658<   y>201<
x  >-3657<   y>201<
x  >-3656<   y>201<
x  >-3655<   y>201<

 

The $x position only moves by one pixel per loop.
If MouseMove were the culprit, wouldn't we see $x move once for each MouseMove?

To me, this implicates the MouseGetPos code.

 

 

Posted

Here is a variation with two sets of MouseGetPos within the loop and only One MouseMove.

Local $x = MouseGetPos(0)
Local $y = MouseGetPos(1)

While(True)

    MouseMove($x,$y,0)

    Sleep (1500) ;(3*60*100) ; sleep 3 minutes

    $x = MouseGetPos(0)
    $y = MouseGetPos(1)

    $x = MouseGetPos(0)
    $y = MouseGetPos(1)

Consolewrite(@CR & "x  >" & $x & "<   y>" & $y & "<")

WEnd

the "drift" is only 1 pixel per loop.

x  >-3711<   y>339<
x  >-3710<   y>339<
x  >-3709<   y>339<
x  >-3708<   y>339<
x  >-3707<   y>339<
 

Posted

I was only trying to point out that the MouseGetPos numbers never changed without MouseMove, so MouseGetPos is getting the right numbers, but MouseMove is moving the mouse to the wrong place.

Having multiple MouseMoves and only one MouseGetPos won't change that, the $x value is going to always be the same so it just moves it to the wrong spot multiple times, always in the same spot.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Posted

I was only trying to point out that the MouseGetPos numbers never changed without MouseMove, so MouseGetPos is getting the right numbers, but MouseMove is moving the mouse to the wrong place.

Having multiple MouseMoves and only one MouseGetPos won't change that, the $x value is going to always be the same so it just moves it to the wrong spot multiple times, always in the same spot.

I agree that the error is most likely in MouseMove - but, it poses an interesting chicken and egg type problem. 
The movement doesn't happen without both functions being used.
It seems sort of like a relativity thought experiment. 
Which is the frame of reference?

Is there anyone with access to the code who can settle this? 
I'm guessing that the negative numbers imply a failure to account for zero when repositioning. 
But, the code will know in the end.

 

adding a couple of lines to the code makes an adequate "UDF" 


    If $x < 0 Then $x = $x - 1
    If $y < 0 Then $y = $y - 1

Could someone help me open the ticket?


Phil

 

Posted

I don't think it has anything to do with MouseGetPos at all, MouseGetPos seems to be working fine. The problem is that MouseMove is moving to the wrong spot, so when you use MouseGetPos, it's reading the spot the pointer is actually at, which is one pixel to the right of where it should be, so every time you move the mouse it moves right one more position because MouseMove put it there, and not because MouseGetPos did anything.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Posted

I don't think it has anything to do with MouseGetPos at all, MouseGetPos seems to be working fine. The problem is that MouseMove is moving to the wrong spot, so when you use MouseGetPos, it's reading the spot the pointer is actually at, which is one pixel to the right of where it should be, so every time you move the mouse it moves right one more position because MouseMove put it there, and not because MouseGetPos did anything.

that does seem most likely, but, suppose that MouseGetPos is returing a value that is one greater than the actual mouse position when the mouse position is less than zero? Wouldn't that yield results that would look the same from the observer's point of view?

Posted

Move your mouse to the upper left corner of your screen, MouseGetPos will read 0,0. Move it to the upper left corner of your second screen and do the same, it should read the X dimension of that screen's resolution (negative of course). My screens are set to 1920x1200, so when I move the mouse to the upper left corner of the second screen I get -1920 for $x.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Posted

Move your mouse to the upper left corner of your screen, MouseGetPos will read 0,0. Move it to the upper left corner of your second screen and do the same, it should read the X dimension of that screen's resolution (negative of course). My screens are set to 1920x1200, so when I move the mouse to the upper left corner of the second screen I get -1920 for $x.

But, shouldn't you get -1919? where is pixel ZERO?
The second "negative screen" should have a range off -1919 to 0 - that is 1920 pixels...

This is a good test, but, I interpret it to mean that the problem is in MouseGetPos....

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...