|
-
Oct 6th, 2010, 09:04 AM
#41
Fanatic Member
Re: using .getElementsByName
Well if thats in the main thread, you will hang your entire app permanently, as you can't sleep the thread and load the webpage asynchronously from the same thread. You'd need to create a new thread for that wait sub.
vb Code:
Dim nT As New Threading.Thread(AddressOf wait) nT.Start() Private Sub wait() While WebBrowser1.ReadyState < 4 Threading.Thread.Sleep(100) End While '//next call after WebBrowser is finished loading End Sub
As for only doing it once, you need to narrow down when the procedure is run on the documentcompleted event. At the moment, whenever the document finishes loading it will run. Either slip in a global boolean that you set by default to true, on the documentcompleted event check if this is true or not, and if so run it and then set the value to false to prevent further execution.
Last edited by J-Deezy; Oct 6th, 2010 at 09:07 AM.
-
Oct 6th, 2010, 10:14 AM
#42
Thread Starter
Lively Member
Re: using .getElementsByName
give me error :
Specified cast is not valid.
on line # 6
if i'm not wrong i cannot refer to form components from the thread's sub , correct ?
-
Oct 6th, 2010, 10:34 AM
#43
Fanatic Member
Re: using .getElementsByName
Oh yeah I forgot that there's always problems with accessing via threads, I've been meaning to have a look at documentation on that for ages.
The only (very messy) suggestion I can make to work-around not being able to access it directly is to create another global variable such as "isWbReady" (boolean) and set it to false, then create a timer with interval of 300-500 or so, and add
Code:
If WebBrowser1.ReadyState < 4 then
isWbReady = False
Else
isWbReady = True
Timer1.Stop()
End If
Then change your sub slightly to this:
Code:
Private Sub Wait()
While (isWbReady = False)
Threading.Thread.Sleep(100)
End While
'//next procedure
End Sub
You might have to turn of the "checkforillegalcrossthreadcalls" property though.
Sorry, it's really messy.
-
Oct 7th, 2010, 06:13 AM
#44
Thread Starter
Lively Member
Re: using .getElementsByName
ok i have this :
Code:
Sub Wait(ByVal wb)
Do
Threading.Thread.Sleep(500)
Label1.Text = "Waiting..."
Me.Refresh()
Loop While wb.ReadyState < 4 Or Me.wb.IsBusy = True
End Sub
How do i make this run in a seperate thread ?
-
Oct 7th, 2010, 06:54 AM
#45
Thread Starter
Lively Member
Re: using .getElementsByName
also i found out "links" property for htmldocument , can some 1 tell me how do i get element id's or inner text of all the links on a page ?
-
Oct 7th, 2010, 08:05 AM
#46
Fanatic Member
Re: using .getElementsByName
 Originally Posted by sk8er_boi
also i found out "links" property for htmldocument , can some 1 tell me how do i get element id's or inner text of all the links on a page ?
What do you mean "links" property? You mean the tagname for links or what? And you need to stop thinking of everything in terms of elementID's as well, elementID is a means to an end...you're looking for the end result, not trying to complicate it by stepping backwards to go forwards.
-
Oct 7th, 2010, 09:23 PM
#47
Thread Starter
Lively Member
Re: using .getElementsByName
@ J-Deezy : i really appreciate ur help (and patience ! ) , i knw i'n getting confused but i'm a rookie with vb .net & it's kinda my hobby, now i really cnt sleep peace fully until i complete this !!!
i mean using this :
http://msdn.microsoft.com/en-us/libr...ent.links.aspx
using this can i save all the links in a array & then send "click" event to the 1 i need
-
Oct 7th, 2010, 09:49 PM
#48
Fanatic Member
Re: using .getElementsByName
Sorry I've never used properties before and so I'm not quite sure how to use that 
I thought you'd already figured out how to find your element and everything?
As for creating a thread for the wait sub, I went through that, in detail a few posts ago.
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
|