[RESOLVED] strange problem with webbrowser control
i am trying to connect to the google accounts page using a webbrowser control .the zipped file has the project which connects to the login page .
now if i click the step1 button it shows as disconnected but if i click secondmethod 1 button followed by secondmethod 2 button it shows as connected though both are executing the same set of statements..
i also tried the following to wait for the webbrowser to complete loading
VB Code:
Do While webbrowser1.busy
DoEvents
sleep(1000)
Loop
any ideas why it does so??
Re: strange problem with webbrowser control
here's the code
VB Code:
'for method one
Private Sub Command1_Click()
WebBrowser1.Navigate2 "https://www.google.com/accounts/ServiceLoginBox?continue=https%3A%2F%2Fwww.orkut.com%2FRedirLogin.aspx%3Fmsg%3D0%26page%3Dhttp%253A%252F%252Fwww.orkut.com%252F&followup=https%3A%2F%2Fwww.orkut.com%2FGLogin.aspx&service=orkut&nui=2&uilel=1&skipvpage=true&hl=en-US"
Do While blnBusy
'DoEvents
Sleep (10000)
Loop
WebBrowser1.Navigate2 "http://www.google.com/accounts/Logout?continue=https%3A%2F%2Fwww.google.com%2Faccounts%2FServiceLoginBox%3Fcontinue%3Dhttps%253A%252F%252Fwww.orkut.com%252FRedirLogin.aspx%253Fmsg%253D0%2526page%253Dhttp%25253A%25252F%25252Fwww.orkut.com%25252F%26followup%3Dhttps%253A%252F%252Fwww.orkut.com%252FGLogin.aspx%26service%3Dorkut%26nui%3D2%26uilel%3D1%26skipvpage%3Dtrue%26hl%3Den-US&il=true&zx=11ni6cru3aqhf"
Do While blnBusy
'DoEvents
Sleep (10000)
Loop
If (InStr(urlstring, "http://www.google.com/accounts") > 0) Or (InStr(urlstring2, "https://www.google.com/accounts") > 0) Then
MsgBox "Connected"
Else
MsgBox "Disconnected"
End If
end sub
VB Code:
'for step one of second method
Private Sub Command3_Click()
WebBrowser1.Navigate2 "https://www.google.com/accounts/ServiceLoginBox?continue=https%3A%2F%2Fwww.orkut.com%2FRedirLogin.aspx%3Fmsg%3D0%26page%3Dhttp%253A%252F%252Fwww.orkut.com%252F&followup=https%3A%2F%2Fwww.orkut.com%2FGLogin.aspx&service=orkut&nui=2&uilel=1&skipvpage=true&hl=en-US"
Do While WebBrowser1.Busy
DoEvents
Sleep (500)
Loop
WebBrowser1.Navigate2 "http://www.google.com/accounts/Logout?continue=https%3A%2F%2Fwww.google.com%2Faccounts%2FServiceLoginBox%3Fcontinue%3Dhttps%253A%252F%252Fwww.orkut.com%252FRedirLogin.aspx%253Fmsg%253D0%2526page%253Dhttp%25253A%25252F%25252Fwww.orkut.com%25252F%26followup%3Dhttps%253A%252F%252Fwww.orkut.com%252FGLogin.aspx%26service%3Dorkut%26nui%3D2%26uilel%3D1%26skipvpage%3Dtrue%26hl%3Den-US&il=true&zx=11ni6cru3aqhf"
Do While WebBrowser1.Busy
DoEvents
Sleep (500)
Loop
End Sub
VB Code:
'step 2 of second method
Private Sub Command2_Click()
If (InStr(urlstring, "http://www.google.com/accounts") > 0) Or (InStr(urlstring2, "https://www.google.com/accounts") > 0) Then
MsgBox "Connected"
Else
MsgBox "Disconnected"
End If
end sub
the problem could be that it is taking time for the webbrowser to obtain the url from google's side.i am thinking of using timers to control the fire the events but that would be really silly :(
Re: strange problem with webbrowser control
Check the URLs. Looks like they are invalid.
Re: strange problem with webbrowser control
there are just 2 urls
the first one
https://www.google.com/accounts/Serv...=true&hl=en-US
the second one
http://www.google.com/accounts/Logou...=11ni6cru3aqhf
in the instr iam only matching the stored urls in the urlstring variable with the partial url
Re: strange problem with webbrowser control
I'm just putting in my pennyworth here, but sites like google, yahoo, MSN et al usually have dynamic data in their POST strings and also some use POST while others use GET...both of these issues make it harder to directly access certain features.
Again, I am suggesting you use HTTP Interceptor (I suggested same to someone else recently :-)) which will let you see what is sent to google and under "data found after header end" will be any GET data...if there's any GET data you can't just put it as part of the URL in webbrowser, you have to define it in the headers when you request the data...it's something I've done in the past, but I'm sorry I can't personally help you with it as I'm not 100% sure about how to do it. I'm sure someone else will help if need be :-)
This isn't related directly to your issue stated above, but it might become an issue as you're working with either POST or GET in webbrowser and as I said most of those "login" sites use GET :-)
Edit: Forgot to say you also need to buid POST/GET data from the form data in the HTML, possibly. I'm sure you know what you're doing in that case though :-)
Re: strange problem with webbrowser control
i understand that point but iam not really into deep google programming.as i explained above clicking first button returns a not connected message (though it actually is).whereas clicking the second button and then third button retuns a connected message(second buttons code + third buttons code = first buttons code)...i donno why this is happening
also i found out that if i use two timers and then use each one of them to fire the two events, it works(with a gap of 4-5 seconds).but that would be too lame dont u think??
Re: strange problem with webbrowser control
Re: strange problem with webbrowser control
I have no idea related directly to your problem. However, I still don't understand what this "connected" and "disconnected" means if you're using webbrowser...webbrowser handles the connections itself, downloads the pages then displays them...there is no "connected" :-P