'place this in your form module and add a WebBrowser control
Option Explicit
Private Sub Form_Load()
WebBrowser1.Navigate "
gLngMouseHook = SetWindowsHookEx(WH_MOUSE, AddressOf MouseHookProc, App.hInstance, GetCurrentThreadId)
End Sub
Private Sub Form_Unload(Cancel As Integer)
UnhookWindowsHookEx gLngMouseHook
End Sub
'and this in a code module
Option Explicit
Public 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
Public Declare Function UnhookWindowsHookEx Lib "user32" (ByVal hHook As Long) As Long
Public Declare Function CallNextHookEx Lib "user32" (ByVal hHook As Long, ByVal nCode As Long, ByVal wParam As Long, lparam As Any) As Long
Public Declare Function GetCurrentThreadId Lib "kernel32" () As Long
Public Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long
Public Const WM_RBUTTONUP = &H205
Public Const WH_MOUSE = 7
Public Type POINTAPI
x As Long
y As Long
End Type
Public Type MOUSEHOOKSTRUCT
pt As POINTAPI
hwnd As Long
wHitTestCode As Long
dwExtraInfo As Long
End Type
Public gLngMouseHook As Long
Public Function MouseHookProc(ByVal nCode As Long, ByVal wParam As Long, mhs As MOUSEHOOKSTRUCT) As Long
Dim strBuffer As String
Dim lngBufferLen As Long
Dim strClassName As String
Dim lngResult As Long
If (nCode >= 0 And wParam = WM_RBUTTONUP) Then
strBuffer = Space(255)
strClassName = "Internet Explorer_Server"
'Get the classname for the Window that has been clicked
'If the function returns 0, it has failed
lngResult = GetClassName(mhs.hwnd, strBuffer, Len(strBuffer))
If lngResult > 0 Then
If Left$(strBuffer, lngResult) = strClassName Then
MouseHookProc = 1
Exit Function
End If
End If
End If
MouseHookProc = CallNextHookEx(gLngMouseHook, nCode, wParam, mhs)
End Function
****
Always stop the program using the Unload method in code or clicking the close button on the forms titlebar. DO NOT use the end button on the IDE's toolbar.
"Two strings walk into a bar. The first string says to the bartender: 'Bartender, I'll have a beer. u.5n$x5t?*&4ru!2[sACC~ErJ'. The second string says: 'Pardon my friend, he isn't NULL terminated'."