Results 1 to 13 of 13

Thread: [RESOLVED] [2005] Wait+webbrowser

  1. #1

    Thread Starter
    Lively Member smart_phil_dude1's Avatar
    Join Date
    Jun 2005
    Location
    Behind You!
    Posts
    125

    Resolved [RESOLVED] [2005] Wait+webbrowser

    I have a button that does multiple things, but I want it to wait a certain amount of time in between doing different actions. how would I do so?

    the first function is to navigate the webbrowser to a certain page, and the second function can only be done once the webpage is loaded, but the webpage only loads at the end...


    Thnx
    Phil.
    Please Help Us Save Ana or donate now by going to Oneana.com

    Visit my Website at http://www.therealfantasy.com

  2. #2
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: [2005] Wait+webbrowser

    take the call to the second function out of the button click event, and move it to the document complete event. The document complete event fires when the webpage has fully loaded.

    A side note to this is if you visit a page with frames, the DocumentComplete event fires for every frame that is loaded, and then a final time when everything is done. If the page does NOT have frames, DocumentComplete fires simply once when the page is loaded.

  3. #3

    Thread Starter
    Lively Member smart_phil_dude1's Avatar
    Join Date
    Jun 2005
    Location
    Behind You!
    Posts
    125

    Re: [2005] Wait+webbrowser

    oh sweet, how do i write the documentcomplete event?

    but the thing is that each event are in a For...Loop with a variable that is only used in the loop, so I can't move the code into an other function
    Please Help Us Save Ana or donate now by going to Oneana.com

    Visit my Website at http://www.therealfantasy.com

  4. #4
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: [2005] Wait+webbrowser

    Quote Originally Posted by smart_phil_dude1
    oh sweet, how do i write the documentcomplete event?
    The same way you write code for a button click event. The documentcomplete event is just an event the control fires. Just go to the code view of the form, select the webbrowser control from the left combobox at the top of the code window, and select the documentcomplete event from the right dropdown and it will insert the needed prototype and you can code away.

    Quote Originally Posted by smart_phil_dude1
    but the thing is that each event are in a For...Loop with a variable that is only used in the loop, so I can't move the code into an other function
    Then you need to go back and figure out another way to code it

  5. #5

    Thread Starter
    Lively Member smart_phil_dude1's Avatar
    Join Date
    Jun 2005
    Location
    Behind You!
    Posts
    125

    Re: [2005] Wait+webbrowser

    Then you need to go back and figure out another way to code it
    then is there a way to just make it wait a certain amount of time?
    Please Help Us Save Ana or donate now by going to Oneana.com

    Visit my Website at http://www.therealfantasy.com

  6. #6
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: [2005] Wait+webbrowser

    you could try doing

    system.threading.thread.sleep(x)

    where x is the number of milliseconds to make it sleep.

    However this sleeps the entire thread, and it may cause undesirable results.

    You can try it though.

  7. #7

    Thread Starter
    Lively Member smart_phil_dude1's Avatar
    Join Date
    Jun 2005
    Location
    Behind You!
    Posts
    125

    Re: [2005] Wait+webbrowser

    nope, the browser doesn't load.
    Please Help Us Save Ana or donate now by going to Oneana.com

    Visit my Website at http://www.therealfantasy.com

  8. #8
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: [2005] Wait+webbrowser

    that is what I figured.

    I don't know what you are trying to do in this loop of yours, so it is hard to make suggestions

  9. #9

    Thread Starter
    Lively Member smart_phil_dude1's Avatar
    Join Date
    Jun 2005
    Location
    Behind You!
    Posts
    125

    Re: [2005] Wait+webbrowser

    well, what it does is load page number 1 that is in the first line of a textbox, then manipulate things on the webpage, then load page number 2 that is on the second line of the textbox, etc. until it has done each page on each line. and it also visits more than one webpage per line of the textbox, if you get what i mean...

    is there a function that can make it just wait until the page has loaded, and then continue?
    Please Help Us Save Ana or donate now by going to Oneana.com

    Visit my Website at http://www.therealfantasy.com

  10. #10
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: [2005] Wait+webbrowser

    if I were coding it... I would do this:

    when the button is clicked, it navigates the webbrowser to the first line of the textbox.

    when the documentcomplete event of the webbrowser fires, I would do whatever manipulation needs to be done. I would also check the URL of the webbrowser at this point to see if it has visited the last page it needs to for the given line in the textbox. When that happens, I would make a call to read the next line of the textbox and do it all over again until all lines were processed.

    No loop needed, just a counter to keep track of what line in the textbox should get processed next.

  11. #11

    Thread Starter
    Lively Member smart_phil_dude1's Avatar
    Join Date
    Jun 2005
    Location
    Behind You!
    Posts
    125

    Re: [2005] Wait+webbrowser

    ok i get what you mean, but i made it visit more than one page per line, and on each page it does different things... would it be possible of having more than one documentcomplete event, one for each page?
    Please Help Us Save Ana or donate now by going to Oneana.com

    Visit my Website at http://www.therealfantasy.com

  12. #12
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: [2005] Wait+webbrowser

    the documentcomplete event fires whenever a given webpage has finished loading.

    Checking the browsers current URL in the documentcomplete event (you can do this using the event args of the documentcomplete event (e.Url.ToString))

    so by checking the current URL in the document complete event, you can do whatever manipulation needs to be done for the given page.

  13. #13

    Thread Starter
    Lively Member smart_phil_dude1's Avatar
    Join Date
    Jun 2005
    Location
    Behind You!
    Posts
    125

    Re: [2005] Wait+webbrowser

    oh sweet thanks a lot now i know exactly what to do
    Please Help Us Save Ana or donate now by going to Oneana.com

    Visit my Website at http://www.therealfantasy.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width