-
Nov 13th, 2005, 07:41 AM
#1
[RESOLVED] hmmm MouseMove in webbrowser control
yo!
Is there any way to get the mousemove event in the webbrowser control?
Thanks
Added green "resolved" checkmark - Hack
Last edited by Hack; Nov 14th, 2005 at 09:40 AM.
-
Nov 13th, 2005, 07:52 AM
#2
Frenzied Member
Re: hmmm MouseMove in webbrowser control
well not in a webbrowser control but you could put a timer insted, it will work just as well.
what are you trying to do?
-
Nov 13th, 2005, 08:05 AM
#3
Re: hmmm MouseMove in webbrowser control
this is my code:
VB Code:
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
Call GetCursorPos(MousePos)
If (MousePos.x * 15.0117279124316) >= (Screen.Width - 200) Then
Timer3.Enabled = True
End If
If (MousePos.x * 15.0117279124316) <= 200 Then
Timer4.Enabled = True
End If
End Sub
If the mouse x coordinate is to the right of the screen, it activates timer3 ( wich is set to 1500 miliseconds)
And when the timer has counted to 1500 miliseconds, it checks the mouse position once again, and if the mouseposition is to the left of the screen this time, the webbrowser control goes "back in the history".
Thats what im trying to do, shortcuts to back and forward in the webbrowser.
The problem is that the webbrowser is covering most of the screen, so i would like to have the mousemove event there instead...
Atheist
-
Nov 13th, 2005, 09:58 AM
#4
Fanatic Member
Re: hmmm MouseMove in webbrowser control
Originally Posted by Atheist
yo!
Is there any way to get the mousemove event in the webbrowser control?
Thanks
why not try something like:
VB Code:
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If X >= WebBrowser1.Left And Y <= WebBrowser1.Left + WebBrowser1.Width Then
WebBrowser1.Navigate "www.google.com"
End If
End Sub
-
Nov 13th, 2005, 11:28 AM
#5
Re: hmmm MouseMove in webbrowser control
You can generate a mouse move event using a mouse hook like this
In a Module
VB Code:
Option Explicit
Private Type POINTAPI
x As Long
y As Long
End Type
Private Type MOUSEHOOKSTRUCT
pt As POINTAPI
hwnd As Long
wHitTestCode As Long
dwExtraInfo As Long
End Type
Private lpPrevWndProc As Long
Private IsHooked As Boolean
Private Const WH_MOUSE = 7
Private Const WM_MOUSEMOVE = &H200
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 Sub SetMouseHook()
If Not IsHooked Then
lpPrevWndProc = SetWindowsHookEx(WH_MOUSE, AddressOf MouseProc, 0, App.ThreadID)
IsHooked = True
End If
End Sub
Public Sub RemoveMouseHook()
UnhookWindowsHookEx lpPrevWndProc
IsHooked = False
End Sub
Public Function MouseProc(ByVal uCode As Long, ByVal wParam As Long, lParam As MOUSEHOOKSTRUCT) As Long
If uCode < 0 Then
MouseProc = CallNextHookEx(lpPrevWndProc, uCode, wParam, lParam)
Else
Select Case wParam
Case WM_MOUSEMOVE
'here is your mouse move event
Debug.Print "Mouse Move: "; lParam.pt.x; lParam.pt.y
End Select
MouseProc = CallNextHookEx(lpPrevWndProc, uCode, wParam, lParam)
End If
End Function
In your Form
VB Code:
Option Explicit
Private Sub Form_Load()
SetMouseHook
End Sub
Private Sub Form_Unload(Cancel As Integer)
RemoveMouseHook
End Sub
-
Nov 14th, 2005, 06:26 AM
#6
Fanatic Member
Re: hmmm MouseMove in webbrowser control
This is probably the easiest way to go.
Add 'Microsoft HTML Object Library' as a reference.
VB Code:
Option Explicit
Dim WithEvents objDocument As HTMLDocument
Private Sub Form_Load()
WebBrowser1.Navigate2 "http://www.google.com"
End Sub
Private Sub objDocument_onmousemove()
Debug.Print "mouse moved: " & objDocument.parentWindow.event.clientX & "x" & objDocument.parentWindow.event.clientY
End Sub
Private Sub WebBrowser1_NavigateComplete2(ByVal pDisp As Object, URL As Variant)
Set objDocument = WebBrowser1.Document
End Sub
Author for Visual Basic Web Magazine
-
Nov 14th, 2005, 06:53 AM
#7
-
Oct 4th, 2006, 03:53 PM
#8
Hyperactive Member
Re: hmmm MouseMove in webbrowser control
how can i use this code to tell the mouse to go to 175x 94y on the webbrowser then left click?
Originally Posted by TheVader
This is probably the easiest way to go.
Add 'Microsoft HTML Object Library' as a reference.
VB Code:
Option Explicit
Dim WithEvents objDocument As HTMLDocument
Private Sub Form_Load()
WebBrowser1.Navigate2 "http://www.google.com"
End Sub
Private Sub objDocument_onmousemove()
Debug.Print "mouse moved: " & objDocument.parentWindow.event.clientX & "x" & objDocument.parentWindow.event.clientY
End Sub
Private Sub WebBrowser1_NavigateComplete2(ByVal pDisp As Object, URL As Variant)
Set objDocument = WebBrowser1.Document
End Sub
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
|