Debugged and three examples added:
Code: Select all
OnExit("ExitApp")
Esc::ExitApp
^0::
MouseMoveBlock(,, 1) ;Block mouse
ToolTip, mouse blocked
Sleep, 2000
ToolTip, blocked mouse moves
Loop 200
{
MouseMoveBlock(1, 0, 1) ;Relative MoveBlock X=1,Y=0
Sleep, 10
}
ToolTip, blocked mouse stops
Sleep, 2000
MouseMoveBlock(,, -1) ;Unblock mouse
ToolTip, mouse unblocked
Sleep, 1000
ToolTip
Return
^1::MouseMoveBlock(500, 500) ;Absolute MoveBlock X=500,Y=500
^2::MouseMoveBlock(,, -1) ;Unblock mouse
MouseMoveBlock(X:=0, Y:=0, Mode:=0)
{ ;Mode: 0,1,-1 : Absolute+Block, Relative+Block, Unblock
Static X0, Y0, OldMode := 0
IF (Mode = 1)
{
IF (OldMode <> 1)
{
CoordMode, Mouse, Screen
MouseGetPos, X0, Y0
OldMode := 1
}
X0 := X += X0, Y0 := Y += Y0
}
Else If (0 > OldMode:=Mode)
{
DllCall("ClipCursor", "Ptr", 0)
Return
}
VarSetCapacity(I, 16, 0)
For k, v in [X, Y, X, Y]
NumPut(v, &I + 4*(k - 1), "Int")
DllCall("ClipCursor", "Ptr", 0)
DllCall("ClipCursor", "UInt", &I)
}
ExitApp()
{
MouseMoveBlock(,, -1) ;Unblock mouse
ExitApp
}