Results 1 to 2 of 2

Thread: I need help with Journal hooks

  1. #1

    Thread Starter
    Member
    Join Date
    Nov 2008
    Posts
    55

    I need help with Journal hooks

    Hello,
    I am tryying to get JournalRecord and JournalPlayback to work on my vista laptop but am finding that my Proc is not even being called.
    I am not having any problem with my GetMessage hook but only with the Journal hook.
    I have attached the relevant code.
    Any help is greatly appreciated.

    Code:
    1. Public Sub RecordMouse()
    2. 'Record the Mouse Events
    3.     If lHookID <> 0 Then Exit Sub
    4.     lMsgCountMax = 0
    5.     lMsgCount = 0
    6.     ReDim tEventList(0)
    7. 'Set an application hook to monitor for messages sent to this app
    8.     lAppHookID = SetWindowsHookEx(WH_GETMESSAGE, AddressOf GetMessageProc, App.hInstance, App.ThreadID)
    9. 'Set the Journal Hook to allow us to record all Mouse Movements
    10.     lHookID = SetWindowsHookEx(WH_JOURNALRECORD, AddressOf JournalRecordProc, 0&, 0&)
    11. End Sub
    12.  
    13. Private Function JournalRecordProc(ByVal Code As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
    14. On Error GoTo LogError
    15.     If Code < 0 Then
    16. 'Pass this message along...
    17.         JournalRecordProc = CallNextHookEx(lHookID, Code, wParam, ByVal lParam)
    18.     Else
    19. 'Grab the Event Message Structure
    20.         CopyMemory tEVENTMSG, ByVal lParam, Len(tEVENTMSG)
    21. 'Only record MOUSE_MOVE events
    22.         If tEVENTMSG.message = WM_MOUSEMOVE Then
    23.             lMsgCountMax = lMsgCountMax + 1
    24.             ReDim Preserve tEventList(lMsgCountMax)
    25.             tEventList(lMsgCountMax) = tEVENTMSG
    26.         End If
    27.         JournalRecordProc = 0
    28.     End If
    29. Exit Function
    30. LogError:
    31. Debug.Print "Error in JournalRecordProc()"
    32. End Function
    33.  
    34. Private Function GetMessageProc(ByVal Code As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
    35. Dim tMSG As MSG
    36. Dim Rec As Long
    37.     If Code < 0 Then
    38. 'Pass the message along...
    39.         GetMessageProc = CallNextHookEx(lAppHookID, Code, wParam, ByVal lParam)
    40.     Else
    41. 'Grab the MSG structure
    42.         CopyMemory tMSG, ByVal lParam, Len(tMSG)
    43.         Select Case tMSG.message
    44.             Case WM_CANCELJOURNAL
    45. 'An external process has requested us to stop this operation
    46.                 Call UnhookWindowsHookEx(lHookID)
    47.                 lHookID = 0
    48.         End Select
    49.     End If
    50. 'JournalRecordProc Code, wParam, lParam
    51. End Function
    52.  
    53. Public Sub PlayBackMouse()
    54. 'Playback the Journal Recorded with JournalRecord
    55.     If lHookID <> 0 Then Exit Sub
    56.     lMsgCount = 1
    57.     tEVENTMSG = tEventList(1)
    58. 'Set an application hook to monitor for messages sent to this app
    59.     lAppHookID = SetWindowsHookEx(WH_GETMESSAGE, AddressOf GetMessageProc, App.hInstance, App.ThreadID)
    60.     lHookID = SetWindowsHookEx(WH_JOURNALPLAYBACK, AddressOf JournalPlaybackProc, 0&, 0&)
    61. End Sub

  2. #2
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: I need help with Journal hooks

    This, this and this maybe relevant...
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width