dcsimg
Results 1 to 6 of 6

Thread: [RESOLVED] InvokeMember("click") works fine but only after code runs to end sub

  1. #1

    Thread Starter
    Member
    Join Date
    Sep 2013
    Posts
    59

    Resolved [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.

  2. #2
    Sinecure devotee
    Join Date
    Aug 2013
    Location
    Southern Tier NY
    Posts
    4,582

    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.

  3. #3
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    32,369

    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

  4. #4

    Thread Starter
    Member
    Join Date
    Sep 2013
    Posts
    59

    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!

  5. #5

    Thread Starter
    Member
    Join Date
    Sep 2013
    Posts
    59

    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...

  6. #6
    You don't want to know.
    Join Date
    Aug 2010
    Posts
    4,580

    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
  •  



Featured


Click Here to Expand Forum to Full Width