-
Dec 13th, 2017, 06:25 AM
#1
Thread Starter
Member
[RESOLVED] InvokeMember("click") works fine but only after code runs to end sub
Hi Guys,
I looked over the forum but couldn't find any help on this one.
Code does everything I need but the click only happens when it hits the end sub.
I want to add more instructions before it ends - any advice how I can force it to execute the click "realtime" , wait a while then do something else.
I know its pretty vague but it works - just not the way I want it to
thanks in advance.
Davie.
Code:
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim UserName As String
Dim Password As String
UserName = "xxx"
Password = "xxxx"
WebBrowser1.Document.GetElementById("splash-login-username").SetAttribute("value", (UserName))
WebBrowser1.Document.GetElementById("splash-login-password").SetAttribute("value", (Password))
WebBrowser1.Document.GetElementById("login").InvokeMember("click")
End Sub ''''''''''''''''''''''''''''' invoke member click happens after the end sub.
-
Dec 13th, 2017, 08:55 AM
#2
Re: InvokeMember("click") works fine but only after code runs to end sub
I guess I would suggest not doing all the code in the Button Click event.
If you have several phases of code execution, I would put those steps in a timer event, and set the interval to how much delay you want between the phases.
In the Button Click event you would just have code that starts the process, i.e. reset a Phase variable to start with the first step, and enable the timer, and probably disable the button.
In each tick of the timer, you would do the code you want to do in that phase, and set the Phase variable to the next phase to be executed.
In the last phase, you would probably stop the timer, and perhaps re-enable the button.
-
Dec 13th, 2017, 10:25 AM
#3
Re: InvokeMember("click") works fine but only after code runs to end sub
Another view along the same line: Most buttons on a web page will cause something to load. Therefore, you might get a DocumentCompleted event as a result of the click. If that's the case, then you can click the button...and do the rest of the work in the DocumentCompleted event. This will take a bit of thought, as there are guaranteed to be several DocumentCompleted events, in this case, so you'd have to decide how to know which was the right one.
Web programming is not as linear as Windows programming usually is. There's a whole lot that happens asynchronously, and this takes a whole different way of thinking about the problem. Some things simply won't happen right away.
My usual boring signature: Nothing
-
Dec 13th, 2017, 11:22 AM
#4
Thread Starter
Member
Re: InvokeMember("click") works fine but only after code runs to end sub
Thanks guys for the advice , I will look at this tomorrow and have a play around with the ideas and pointers you have given.
Appreciate it!
-
Dec 17th, 2017, 08:50 AM
#5
Thread Starter
Member
Re: InvokeMember("click") works fine but only after code runs to end sub
Just for any others - I used an AutoIt script that did it quite easily - much better than VB could for a noob like myself...
-
Dec 17th, 2017, 01:17 PM
#6
Re: [RESOLVED] InvokeMember("click") works fine but only after code runs to end sub
In general it's 10000x easier to use AutoIt than VB for automation tasks that involve clicks or keystrokes. For some reason no one believes that.
This answer is wrong. You should be using TableAdapter and Dictionaries instead.
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
|