Windows Hooks 
Author Message
 Windows Hooks

Is anyone here good with message hooking?

I am learning a lot with it, but the system crashing is
getting very frustrating, So far i have been able to trap
every right click of the mouse, and make the system ignore
it, how ever what i am trying to do is every time the user
clicks the right mouse button a double left click happens
instead.. I know how to make the mouse click and every thing
but i just cant get my left click procedure to work "inside" of my
MouseProc function... ANY ideas?? .. My module is below...

-----------------------

Option Explicit

Declare Sub mouse_event Lib "user32" (ByVal dwFlags As Long, ByVal dx As
Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long)

Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As
Integer
Declare Function CallNextHookEx Lib "user32" (ByVal hHook As Long, ByVal
ncode As Long, ByVal wParam As Long, lParam As Any) As Long
Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) As
Integer
Declare Function SetWindowsHookEx Lib "user32" Alias "SetWindowsHookExA"
(ByVal idHook As Long, ByVal lpfn As Long, ByVal hmod As Long, ByVal
dwThreadId As Long) As Long
Declare Function UnhookWindowsHookEx Lib "user32" (ByVal hHook As Long) As
Long

Public Const VK_LBUTTON = &H1
Public Const VK_RBUTTON = &H2
Public Const WH_MOUSE = 7

Public Const MOUSEEVENTF_LEFTDOWN = &H2
Public Const MOUSEEVENTF_LEFTUP = &H4
Public Const MOUSEEVENTF_MIDDLEDOWN = &H20
Public Const MOUSEEVENTF_MIDDLEUP = &H40
Public Const MOUSEEVENTF_RIGHTDOWN = &H8
Public Const MOUSEEVENTF_RIGHTUP = &H10
Public Const MOUSEEVENTF_MOVE = &H1

Public hHook As Long
Global dc As Boolean
Function MouseProc(ByVal hookCode As Long, ByVal messId As Long, ByVal
mouseCor As Long) As Long

If hookCode < 0 Or messId < 516 Then
    MouseProc = CallNextHookEx(hHook, hookCode, messId, ByVal mouseCor)
    Exit Function
Else
 If GetAsyncKeyState(VK_RBUTTON) Then
   'this is where i had my left click procedures but it wasnt working
    MouseProc = 1  ' 1 = ignore the click..
    Exit Function
 Else
    MouseProc = CallNextHookEx(hHook, hookCode, messId, ByVal mouseCor)
    Exit Function
 End If
End If
End Function

-----------------------
--
Joseph



Thu, 22 Jul 2004 05:49:11 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Windows hook and control hook

2. using windows HOOKS (system-wide)

3. Windows Hooks

4. Windows Hooks

5. Windows hook

6. Start windows hook functions with Registry ?

7. Windows Hooks

8. Subclassing and Windows Hooks in VB5

9. Windows Keyboard Hook in .NET

10. VB5: Hooking Windows Messages / minimized program

11. How to hook windows in other apps ?

12. Hook into Windows System Message Queue?

 

 
Powered by phpBB® Forum Software