Opt("TrayAutoPause",0) Global Const $user32dll = DllOpen("user32.dll") GUIRegisterMsg(0x00FF,WM_INPUT) Local $struct = DllStructCreate('struct;ushort UsagePage;ushort Usage;dword Flags;hwnd Target;endstruct') $struct.UsagePage=0x01 $struct.Usage=0x02 $struct.Flags=0x00000100 $struct.Target=GUICreate('') DllCall('user32.dll', 'bool', 'RegisterRawInputDevices', 'struct*', $struct, 'uint', 1, 'uint', DllStructGetSize(DllStructCreate('struct;ushort UsagePage;ushort Usage;dword Flags;hwnd Target;endstruct'))) Do Until GUIGetMsg()=-3 Func WM_INPUT($hWnd,$Msg,$wParam,$lParam) Local Static $HEADER ='struct;dword Type;dword Size;handle hDevice;wparam wParam;endstruct;' Local Static $TAG = $HEADER & 'ushort flag;ushort Alignment;ushort bflg;short bdta;ulong rbtn;long dx;long dy;ulong info;' Local Static $HEADSIZE = DllStructGetSize(DllStructCreate($HEADER)) Local Static $TAGSIZE = DllStructGetSize(DllStructCreate($TAG)) Local Static $locked = False Local $input = DllCall($user32dll, 'uint','GetRawInputData', 'handle', $lParam, 'uint', 0x10000003, 'struct*', DllStructCreate($TAG), 'uint*', $TAGSIZE, 'uint', $HEADSIZE ) Local $_ = $input[3] If $_.bflg Then If BitAnd(16,$_.bflg) Then Local $aCall = DllCall($user32dll,"dword","GetMessagePos") Local $x=BitAnd(0xffff,$aCall[0]),$y=BitShift($aCall[0],16) Local $clip = DllStructCreate("struct;long left;long top;long right;long bottom;endstruct") $clip.left = $x $clip.top = $y $clip.right = $x+1 $clip.bottom = $y+1 DllCall( $user32dll, "bool", "ClipCursor", "struct*", $clip ) $locked = True Endif If BitAnd(32,$_.bflg) Then DllCall( $user32dll, "bool", "ClipCursor", "struct*", Null ) $locked = False Endif ElseIf $locked Then ScrollMouseXY($_.dx,-$_.dy,$user32dll) EndIf If $wParam Then Return 0 EndFunc Func ScrollMouseXY($x, $y, $dll='user32.dll') Local Static $SIZE = DllStructGetSize(DllStructCreate('dword;struct;long;long;dword;dword;dword;ulong_ptr;endstruct;')) Local $count = ($x?1:0)+($y?1:0) Local $struct, $arr = DllStructCreate('byte[' & $count*$SIZE & ']'), $ptr = DllStructGetPtr($arr) If $x Then $struct = DllStructCreate('dword type;struct;long;long;dword data;dword flag;dword;ulong_ptr;endstruct;', $ptr) DllStructSetData($struct,1,0) DllStructSetData($struct,4,$x) DllStructSetData($struct,5,0x1000) EndIf If $y Then $struct = DllStructCreate('dword type;struct;long;long;dword data;dword flag;dword;ulong_ptr;endstruct;', $ptr+($x?$SIZE:0)) DllStructSetData($struct,1,0) DllStructSetData($struct,4,$y) DllStructSetData($struct,5,0x0800) EndIf Local $aCall = DllCall( $dll, 'uint', 'SendInput', 'uint', $count, 'struct*', $ptr, 'int', $SIZE ) Return $aCall[0] EndFunc