Postmessage VS webbrowser issue (experienced coders only (I think!))
I have a bug... Actually, not a bug, but I suspect something is missing in my code... I'm using a postmessage statement to send a click to a webbrowser - and it partially works. Very odd. More details to come.
I am pasting my current code so that people can use it:
I am first browsing to a web page and then getting the webbrowser's HWND.
Code:
Private Sub cmdNavigateUrlAndGetHwnd_Click()
frmMain.Webbrowser.Navigate "http://www.google.com/"
Call proWaitUntilWebPageFullyLoaded()
webhwnd = GetBrowserHandle(Me.hwnd)
End Sub
(tell me if you need the GetBrowserHandle procedure)
Now I click this command button which will send tons of click to the webbrowser (google.com), at random x,y positions on the page.
Code:
Private Sub cmdClickThePage_Click()
Dim i As Integer
For i = 0 To 1000
Call PostMessage(webhwnd, WM_LBUTTONDOWN, 0&, ByVal MakeDWord(Int(Rnd * 1000), Int(Rnd * 1000)))
DoEvents
Call PostMessage(webhwnd, WM_LBUTTONUP, 0&, 0&)
DoEvents
Call proWaitUntilWebPageFullyLoaded()
Next i
MsgBox "ended"
End Sub
I don't even need to use Winspector (or any other app) to check if the postmessages reaches the browser: when I click that command button, I can see the google page links (and buttons) flashing and getting focus one after the other. The problem is that they seem to only get focus without being clicked at all...
I've been trying to debug for some time now and I have no idea what to try next... Is sending a WM_LBUTTONDOWN and WM_LBUTTONUP enough? Must I use some sort of WM_MOUSEMOVE or something I don't know of?
I know this is a tough one. If you feel you can help, feel free to post.
(btw, I'm simply trying to master this postmessage method for clicking the mouse in a webbrowser. I know that a simple line of code (like this one: frmMain.Webbrowser.Document.Forms(0).submit.Click) could make a button click easily).
Thanks in advance, fellow programmers.
Re: Postmessage VS webbrowser issue (experienced coders only (I think!))
*bump*
(one week ago, my "bump" message got deleted - tell me if this is NOT allowed anymore...)
Thanks!
Re: Postmessage VS webbrowser issue (experienced coders only (I think!))
Bumping threads is a bad idea in general, as it understandably puts people off helping you - see this discussion for the reasons, and an explanation of why your previous bump post was deleted.