Sign in to follow this  
Followers 0
er453r

Mouse movement direction ("outside" the screen)

9 posts in this topic

Hi. How can I detect the direction, of mouse movement "outside" the screen? I mean, that when mouse is at the border (or in the corner) of the screen, cords from MouseGetPos() don't change, but you can still move your mouse physically. Like playing FPS games, when you can do quick turns by sliding the mouse a few times... Eehh... It's hard to explain, but hopefully someone will understand ;P

Share this post


Link to post
Share on other sites



im im understadnign you that is entirely dependent on how the game interupits it. For example what if you have your axis inverted? when you scroll the mouse up it in fact slides your viewer down... There wouldnt be much to detect in this case...it all how the game woudl render it...

Share this post


Link to post
Share on other sites

This isn't a problem. I just can't detect mouse movement when the mouse is for example in the bottom right corner. You can slide it down and right, but you can't detect "mouse sliding" just thought coordinates...

Share this post


Link to post
Share on other sites

but you can't detect "mouse sliding" just thought coordinates...

err... why not?

Share this post


Link to post
Share on other sites

Lets continue the "bottom right corner" example. Lets say our screen is 800x600. Mouse pointer is at 800x600. We slide the mouse to the right, but coordinates don't change. We slide the mouse down, but coordinates don't change. So we can't detect the slide thought the coordinates.

Share this post


Link to post
Share on other sites

ah, i see you want more of a MouseHook type thing... ehh i think there's some for autoit around...if not try a goole serach for "Mouse hook" or somthing... trouble is trying to get one that hooks movement as most of them want to hook a click event or somthing...but there are some out-and-about if you look around

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

A quick and somewhat messy workaround would be to move the mouse to a position and then check how far from that position it has moved.

Something like this:

CODE
HotKeySet( "{ESC}", "OnAutoItExit" )
$x = @DesktopWidth/2
$y = @DesktopHeight/2
GUICreate("MouseRelative", 400, 300)
GUISetState()
DllCall("User32.dll","long","ShowCursor","short",False)
MouseMove ( $x, $y, 0)
While 1
    $pos = MouseGetPos()
    $dx = $pos[0]-$x
    $dy = $pos[1]-$y
    ConsoleWrite( $dx & ":" & $dy & @CRLF )
    MouseMove ( $x, $y, 0)
    Switch GUIGetMsg()
        Case -3
            Exit
    EndSwitch
WEnd
Func OnAutoItExit()
    Exit
EndFuncoÝ÷ Û÷(uæèÄêâ*.v÷öÜÖ°whÀmç(²Ú[z)ài¹^¶buëax+«²Ø¢ç(ºWm¯+(uæèÅ«­¢+Ù!½Ñ-åMÐ ÅÕ½ÐííM
ôÅÕ½Ðì°ÅÕ½Ðí=¹Õѽ%Ñá¥ÐÅÕ½Ðì¤)±½°ÀÌØíá}µ½ÕÍ¡½±ôͭѽÁ]¥Ñ ¼È)±½°ÀÌØíå}µ½ÕÍ¡½±ôͭѽÁ!¥¡Ð¼È)5½ÕÍ5½Ù ÀÌØíá}µ½ÕÍ¡½±°ÀÌØíå}µ½ÕÍ¡½±°À¤)]¡¥±Ä($ÀÌØí5½ÕÍ
¡¹ôÑ5½ÕÍ
½½É ¤(%
½¹Í½±]É¥Ñ ÀÌØí5½ÕÍ
¡¹lÁtµÀìÅÕ½ÐìèÅÕ½ÐìµÀìÀÌØí5½ÕÍ
¡¹lÅtµÀì
I1¤(%M±À ÈÀ¤)]¹)Õ¹Ñ5½ÕÍ
½½É ¤(%1½°ÀÌØílÉt($ÀÌØíÁ½Ìô5½ÕÍÑA½Ì ¤($ÀÌØílÁtôÀÌØíÁ½ÍlÁt´ÀÌØíá}µ½ÕÍ¡½±($ÀÌØílÅtôÀÌØíÁ½ÍlÅt´ÀÌØíå}µ½ÕÍ¡½±(%5½ÕÍ5½Ù ÀÌØíá}µ½ÕÍ¡½±°ÀÌØíå}µ½ÕÍ¡½±°À¤(%IÑÕɸÀÌØí)¹Õ¹)Õ¹=¹Õѽ%Ñá¥Ð ¤(%á¥Ð)¹Õ¹

Either way is quite messy and I'm sure there's a better way out there.

Edited by Gabburd

Share this post


Link to post
Share on other sites

Wow. I've just red your answer. Thank you very much. Unfortunately I solved this problem earlier. But the most interesting thing is that I solved it exactly the same way :shocked:

Share this post


Link to post
Share on other sites

Nice! Great minds think alike! :shocked:

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