Function Reference


_MouseTrap

Confine the Mouse Cursor to specified coords

#include <Misc.au3>
_MouseTrap ( [$iLeft = 0 [, $iTop = 0 [, $iRight = 0 [, $iBottom = 0]]]] )

Parameters

$iLeft [optional] Left coord
$iTop [optional] Top coord
$iRight [optional] Right coord
$iBottom [optional] Bottom coord

Return Value

Success: True.
Failure: False.

Remarks

Use _MouseTrap() with no params to release the Mouse Cursor.

Example

#include <GUIConstantsEx.au3>
#include <Misc.au3>

Example()

Func Example()
        ; Create a GUI with various controls.
        Local $hGUI = GUICreate("Mouse Trap Example")

        ; Display the GUI.
        GUISetState(@SW_SHOW, $hGUI)

        ; Hold the window's position.
        Local $aCoords = 0

        ; Loop until the user exits.
        While 1
                $aCoords = WinGetPos($hGUI)
                If Not @error Then
                        ; If no error occurs, then trap the mouse cursor between the window client.
                        _MouseTrap($aCoords[0], $aCoords[1], $aCoords[0] + $aCoords[2], $aCoords[1] + $aCoords[3])
                EndIf
                Switch GUIGetMsg()
                        Case $GUI_EVENT_CLOSE
                                ExitLoop

                EndSwitch
        WEnd

        ; Release the mouse cursor
        _MouseTrap()
EndFunc   ;==>Example