|
-
Feb 23rd, 2005, 04:48 PM
#4
Thread Starter
Admodistrator
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:
Option Explicit
'Functions, constants and types for the hook
Private 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
Private Declare Function UnhookWindowsHookEx Lib "user32" ( _
ByVal hHook As Long _
) As Long
Private Declare Function CallNextHookEx Lib "user32" ( _
ByVal hHook As Long, _
ByVal ncode As Long, _
ByVal wParam As Long, _
lParam As Any _
) As Long
Public Const WH_MOUSE_LL = 14
Public Type POINTAPI
x As Long
y As Long
End Type
Public Type MSLLHOOKSTRUCT
pt As POINTAPI
mouseData As Long
flags As Long
time As Long
dwExtraInfo As Long
End Type
Private hHook As Long
Public IsHooked As Boolean
'functions for getting windows properties
Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" ( _
ByVal hwnd As Long, _
ByVal lpString As String, _
ByVal cch As Long _
) As Long
Private Declare Function GetClassName Lib "user32" Alias "GetClassNameA" ( _
ByVal hwnd As Long, _
ByVal lpClassName As String, _
ByVal nMaxCount As Long _
) As Long
Private Declare Function WindowFromPoint Lib "user32" ( _
ByVal xPoint As Long, _
ByVal yPoint As Long _
) As Long
Sub GetWindowData(x As Long, y As Long)
Dim hWndFrm As Long
Dim lpClassName As String, lpString As String
lpClassName = Space(100)
lpString = Space(100)
'get handle to window
hWndFrm = WindowFromPoint(CLng(x), CLng(y))
If hWndFrm = 0 Then Exit Sub
'get window text (caption)
Call GetWindowText(hWndFrm, lpString, Len(lpString))
'get window class name
Call GetClassName(hWndFrm, lpClassName, Len(lpClassName))
With Form1
.txthandle = Hex(hWndFrm)
.txtCaption = lpString
.txtClassName = lpClassName
End With
End Sub
Public Sub SetMouseHook()
If IsHooked Then
MsgBox "Don't hook the MOUSE_LL hook twice or you'll be sorry."
Else
'This has to be set up as a system-wide hook
hHook = SetWindowsHookEx(WH_MOUSE_LL, AddressOf MouseProc, App.hInstance, 0)
IsHooked = True
End If
End Sub
Public Sub RemoveMouseHook()
Dim temp As Long
temp = UnhookWindowsHookEx(hHook)
IsHooked = False
End Sub
Public Function MouseProc(ByVal uCode As Long, ByVal wParam As Long, lParam As MSLLHOOKSTRUCT) As Long
If uCode >= 0 Then
Call GetWindowData(lParam.pt.x, lParam.pt.y)
End If
MouseProc = CallNextHookEx(hHook, uCode, wParam, lParam)
End Function
Added this to a form:
VB Code:
Option Explicit
'Always on top stuff
Private Const HWND_TOPMOST = -1
Private Const SWP_NOSIZE = &H1
Private Const SWP_NOMOVE = &H2
Private Const SWP_NOACTIVATE = &H10
Private Const SWP_SHOWWINDOW = &H40
Private Declare Sub SetWindowPos Lib "user32" ( _
ByVal hwnd As Long, _
ByVal hWndInsertAfter As Long, _
ByVal x As Long, _
ByVal y As Long, _
ByVal cx As Long, _
ByVal cy As Long, _
ByVal wFlags As Long _
)
Private Sub cmdStart_Click()
'make window always on top
SetWindowPos Me.hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOACTIVATE Or _
SWP_SHOWWINDOW Or SWP_NOMOVE Or SWP_NOSIZE
'set the system-wide low level mouse hook
Call SetMouseHook
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
Call RemoveMouseHook
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|