Click to See Complete Forum and Search --> : Detecting mouse clicks in Internet Explorer
HazeOfLove
Apr 17th, 2001, 11:31 PM
I'm stuck. I would like to detect the right mouse click in IE and be able to activate certain selections on the popup menu that appears as a result of the right-click. Anyone have any suggestions or code I could use to accomplish this? Any help is appreciated.
-Haze
eformx
May 15th, 2001, 06:28 PM
enter GetAsyncKeyState at codehound.com for samples. It is an api call that detects the mouse button. You can pass it VK_RBUTTON. Then you can use GetCursor
'in a timer
If GetAsyncKeyState(VK_RBUTTON) Then
Dim pt As POINTAPI
Dim hwndNow as Long
retVal = GetCursorPos(pt)
hwndNow = WindowFromPoint(pt.x, pt.y)
to determine the handle using WindowFromPoint api call. Then get the class name of that handle using GetClassName and check for "Internet Explorer_Server" (this is the class name for IE's browser object).
Dim sText as string
retVal = GetClassName(hwndNow, sText, 255)
Select Case sText
Case "Internet Explorer_Server"
SendKeys "%V" 'Alt+V to view source
End Select
End If
If the class name matches the coordinates under the cursor, you definitely have IE. You can then use SendKeys to activate any context menu with a shortcut key.
Hope this helps.
Rob
Matthew Gates
May 15th, 2001, 06:59 PM
Originally posted by eformx
You can pass it VK_RBUTTON.
Why don't you just use Vb's Right Mouse Button constant?
vbRightButton
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.