Jump to content

Restrict mouse movement?


Recommended Posts

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...
Link to comment
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.

 

Link to comment
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
 Share

  • Recently Browsing   0 members

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