Results 1 to 20 of 20

Thread: Sendmessage help?

Threaded View

  1. #4

    Thread Starter
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: Sendmessage help?

    well, first ive never seen that thread, but i did visit another one of your threads that got me this far..
    edit**my stupidity, i see my own post on there, although i dont remember it..


    added this to a module:
    VB Code:
    1. Option Explicit
    2.  
    3. 'Functions, constants and types for the hook
    4. Private Declare Function SetWindowsHookEx Lib "user32" Alias "SetWindowsHookExA" ( _
    5.     ByVal idHook As Long, _
    6.     ByVal lpfn As Long, _
    7.     ByVal hmod As Long, _
    8.     ByVal dwThreadId As Long _
    9. ) As Long
    10.  
    11. Private Declare Function UnhookWindowsHookEx Lib "user32" ( _
    12.     ByVal hHook As Long _
    13. ) As Long
    14.  
    15. Private Declare Function CallNextHookEx Lib "user32" ( _
    16.     ByVal hHook As Long, _
    17.     ByVal ncode As Long, _
    18.     ByVal wParam As Long, _
    19.     lParam As Any _
    20. ) As Long
    21.  
    22. Public Const WH_MOUSE_LL = 14
    23.  
    24. Public Type POINTAPI
    25.         x As Long
    26.         y As Long
    27. End Type
    28.  
    29. Public Type MSLLHOOKSTRUCT
    30.     pt As POINTAPI
    31.     mouseData As Long
    32.     flags As Long
    33.     time As Long
    34.     dwExtraInfo As Long
    35. End Type
    36.  
    37. Private hHook As Long
    38. Public IsHooked As Boolean
    39.  
    40. 'functions for getting windows properties
    41. Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" ( _
    42.     ByVal hwnd As Long, _
    43.     ByVal lpString As String, _
    44.     ByVal cch As Long _
    45. ) As Long
    46.  
    47. Private Declare Function GetClassName Lib "user32" Alias "GetClassNameA" ( _
    48.     ByVal hwnd As Long, _
    49.     ByVal lpClassName As String, _
    50.     ByVal nMaxCount As Long _
    51. ) As Long
    52.  
    53. Private Declare Function WindowFromPoint Lib "user32" ( _
    54.     ByVal xPoint As Long, _
    55.     ByVal yPoint As Long _
    56. ) As Long
    57.  
    58. Sub GetWindowData(x As Long, y As Long)
    59.  Dim hWndFrm As Long
    60.  Dim lpClassName As String, lpString As String
    61.  lpClassName = Space(100)
    62.  lpString = Space(100)
    63.  'get handle to window
    64.  hWndFrm = WindowFromPoint(CLng(x), CLng(y))
    65.  If hWndFrm = 0 Then Exit Sub
    66.  'get window text (caption)
    67.  Call GetWindowText(hWndFrm, lpString, Len(lpString))
    68.  'get window class name
    69.  Call GetClassName(hWndFrm, lpClassName, Len(lpClassName))
    70.  
    71.  With Form1
    72.   .txthandle = Hex(hWndFrm)
    73.   .txtCaption = lpString
    74.   .txtClassName = lpClassName
    75.  End With
    76. End Sub
    77.  
    78. Public Sub SetMouseHook()
    79.     If IsHooked Then
    80.         MsgBox "Don't hook the MOUSE_LL hook twice or you'll be sorry."
    81.     Else
    82.         'This has to be set up as a system-wide hook
    83.         hHook = SetWindowsHookEx(WH_MOUSE_LL, AddressOf MouseProc, App.hInstance, 0)
    84.         IsHooked = True
    85.     End If
    86. End Sub
    87.  
    88. Public Sub RemoveMouseHook()
    89.     Dim temp As Long
    90.     temp = UnhookWindowsHookEx(hHook)
    91.     IsHooked = False
    92. End Sub
    93.  
    94.  
    95. Public Function MouseProc(ByVal uCode As Long, ByVal wParam As Long, lParam As MSLLHOOKSTRUCT) As Long
    96.     If uCode >= 0 Then
    97.         Call GetWindowData(lParam.pt.x, lParam.pt.y)
    98.     End If
    99.                 MouseProc = CallNextHookEx(hHook, uCode, wParam, lParam)
    100. End Function

    Added this to a form:
    VB Code:
    1. Option Explicit
    2.  
    3. 'Always on top stuff
    4. Private Const HWND_TOPMOST = -1
    5. Private Const SWP_NOSIZE = &H1
    6. Private Const SWP_NOMOVE = &H2
    7. Private Const SWP_NOACTIVATE = &H10
    8. Private Const SWP_SHOWWINDOW = &H40
    9.  
    10. Private Declare Sub SetWindowPos Lib "user32" ( _
    11.     ByVal hwnd As Long, _
    12.     ByVal hWndInsertAfter As Long, _
    13.     ByVal x As Long, _
    14.     ByVal y As Long, _
    15.     ByVal cx As Long, _
    16.     ByVal cy As Long, _
    17.     ByVal wFlags As Long _
    18. )
    19.  
    20. Private Sub cmdStart_Click()
    21. 'make window always on top
    22.  SetWindowPos Me.hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOACTIVATE Or _
    23.     SWP_SHOWWINDOW Or SWP_NOMOVE Or SWP_NOSIZE
    24.  'set the system-wide low level mouse hook
    25.  Call SetMouseHook
    26. End Sub
    27.  
    28. Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    29.  Call RemoveMouseHook
    30. End Sub

    But nothing happends, the textboxs say text1, text2, and text3 no matter what i do. i am positive ive set nothing wrong.
    Last edited by |2eM!x; Feb 23rd, 2005 at 04:56 PM.

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