PrivateDeclareFunction UnhookWindowsHookEx Lib"user32" (ByVal hHook AsInteger) AsInteger
PrivateDeclareFunction SetWindowsHookEx Lib"user32"Alias"SetWindowsHookExA" (ByVal idHook AsInteger, ByVal lpfn As sourisHookDelegate, ByVal hmod AsInteger, ByVal dwThreadId AsInteger) AsInteger
PrivateDeclareFunction CallNextHookEx Lib"user32" (ByVal hHook AsInteger, ByVal nCode AsInteger, ByVal wParam AsInteger, ByRef lParam As MouseHookStruct) AsInteger
PrivateDelegateFunction sourisHookDelegate(ByVal Code AsInteger, ByVal wParam AsInteger, ByRef lParam As MouseHookStruct) AsInteger
<MarshalAs(UnmanagedType.FunctionPtr)> Private callback As sourisHookDelegate
PrivateMousHandle AsInteger
PrivateConst WH_MOUSE_LL = 14
PrivateConst WH_MOUSE = 7
PrivateConst HC_ACTION AsInteger = 0
PrivateStructure MouseHookStruct
Privatept As Point
Privatehwnd AsInteger
PrivatewHitTestCode AsInteger
PrivatedwExtraInfo AsInteger
EndStructure
PublicSub Hooksouris()
callback = New sourisHookDelegate(AddressOf sourisCallback)
MousHandle = SetWindowsHookEx( _
WH_MOUSE_LL, _
callback, _Marshal.GetHINSTANCE(Reflection.Assembly.GetExecutingAssembly().GetModules()(0)), _
0)
EndSub
PublicSub UnHooksouris()
UnhookWindowsHookEx (MousHandle)
EndSub
PrivateFunction sourisCallback(ByVal Code AsInteger, _
ByVal wParam AsInteger, _
ByRef lParam As MouseHookStruct) AsInteger
If (Code = HC_ACTION) Then
traitemant quelconque
lParam.pt.X = lParam.pt.X - 10