Sign in to follow this  
Followers 0
strate

Restrict mouse movement?

4 posts in this topic

What I want is to limit the mouse from leaving the foot print (area) of a window.

I know I need to use:

WinActive ( "title" [, "text"] )

MouseGetPos ( )

WinGetPos ( "title" [, "text"] )

?? MouseMove ( x, y [, speed] ) ??

What I don't want is the mouse to break the perimeter of the window, and I don't want to use MouseMove(). The reason is it would look choppy or bad maybe.

The mouse needs to work like normal just in a smaller "Desktop". Any ideas??


INI TreeViewA bus station is where a bus stops, a train station is where a train stops. Onmy desk I have a work station...

Share this post


Link to post
Share on other sites



You'll need beta

#include <GuiConstants.au3>

$GUI = GUICreate("MyGUI", 392, 323)


GUISetState()
While 1
    $size = WinGetPos($GUI)
    _CursorClip($size[0], $size[1], $size[0] + $size[2], $size[1] + $size[3])
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case Else
        ;;;
    EndSelect
WEnd
_CursorRestore()
Exit

Func _CursorRestore()
    DllCall("user32.dll", "int", "ClipCursor", "int", 0)
EndFunc  ;==>_CursorRestore

Func _CursorClip($i_x, $i_y, $i_width, $i_height)
    Local $Rect = "int;int;int;int", $left = 1, $top = 2, $right = 3, $bottom = 4, $r
    $r = DllStructCreate($Rect)
    If @error Then Return -1
    DllStructSetData($r, $left, $i_x)
    DllStructSetData($r, $top, $i_y)
    DllStructSetData($r, $right, $i_width)
    DllStructSetData($r, $bottom, $i_height)
    DllCall("user32.dll", "int", "ClipCursor", "ptr", DllStructGetPtr($r))
    DllStructDelete($r)
EndFunc  ;==>_CursorClip

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

That is wonderful thanks alot!!


INI TreeViewA bus station is where a bus stops, a train station is where a train stops. Onmy desk I have a work station...

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