Results 1 to 30 of 30

Thread: Web browser ?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 2009
    Posts
    176

    Web browser ?

    Hello.
    It's me again.
    This time I need help or I want answere on this question.
    I have made a form with a button.
    Now I want something to happend on a web browser when I press this button.
    Like for example if I open mozilla and google and press the button the button writes in VBforums and press search.
    Anyone that can help me=
    //Worqy
    Last edited by worqy; Sep 14th, 2009 at 12:28 PM.

  2. #2

    Thread Starter
    Addicted Member
    Join Date
    Sep 2009
    Posts
    176

    Re: Web browser ?

    Hello.
    My computter broke down so I haven't been on this forum for over 1 week.
    Today I saw that nobody have replyed to this post.
    I don't know why but I'll make this more clear and hope that somebody will reply here soon.
    I want to make my own E-mail "reader".
    So I make a two text boxes. One for the username and one for the password.
    And then a button.
    Now when I press the button I want it to go to www.hotmail.com and that the textbox 1 is the email address and the textbox 2 is the password and that it presses "Sign in"
    Anyone?

  3. #3
    Addicted Member ZenDisaster's Avatar
    Join Date
    Dec 2006
    Location
    Bay Area, CA
    Posts
    140

    Re: Web browser ?

    Can do for IE but haven't delved into mozilla api's at all.

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Sep 2009
    Posts
    176

    Re: Web browser ?

    Quote Originally Posted by ZenDisaster View Post
    Can do for IE but haven't delved into mozilla api's at all.
    How do you do it for IE then?

  5. #5
    Frenzied Member wpearsall's Avatar
    Join Date
    Feb 2002
    Location
    England / UK
    Posts
    1,065

    Re: Web browser ?

    http://www.vbforums.com/showthread.php?t=583416

    this guy was doing what you wanna do...

    basically u need to get the field / form names...
    then set them... then on the button... ".click" even makes it go to the login...

    ie@: open ie webbrowser control should b good... - most likely hidden im guessing?....
    then when its completed...

    ie document complete...
    if url = locationurl and url = "whatever you want it to be like" then
    webbrowser1.document.all("name of what you wanna set").value = text1.text
    "" """ """ .all("Password").value = text2.text
    """"""".all("Login Button").click
    end if


    of course this needs doing properly [what its not in code tags]
    but hope that helps?
    Wayne

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Sep 2009
    Posts
    176

    Re: Web browser ?

    Quote Originally Posted by wpearsall View Post
    http://www.vbforums.com/showthread.php?t=583416

    this guy was doing what you wanna do...

    basically u need to get the field / form names...
    then set them... then on the button... ".click" even makes it go to the login...

    ie@: open ie webbrowser control should b good... - most likely hidden im guessing?....
    then when its completed...

    ie document complete...
    if url = locationurl and url = "whatever you want it to be like" then
    webbrowser1.document.all("name of what you wanna set").value = text1.text
    "" """ """ .all("Password").value = text2.text
    """"""".all("Login Button").click
    end if


    of course this needs doing properly [what its not in code tags]
    but hope that helps?
    OK thank you. It helped a bit.
    But Im still wondering a bit how to do it:
    Have can I know what the button has fore name (inte the link you posted it was "con")
    Like lets say. I make this code:
    [HIGHLIGHT="Private Sub Command1_Click() Shell "C:\Program Files\Internet Explorer\IEXPLORE.EXE + text1.text" End Sub"[/HIGHLIGHT]
    and then I want it to write in "Visual Basic" on the google search and press "Search".

  7. #7
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Web browser ?

    i tried to login to hotmail for someone else, but i was unable to do so, as the usual form methods would no work on that site
    Last edited by westconn1; Sep 27th, 2009 at 03:07 AM.
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  8. #8
    Frenzied Member wpearsall's Avatar
    Join Date
    Feb 2002
    Location
    England / UK
    Posts
    1,065

    Re: Web browser ?

    also it would be easier to add reference to the internet explorer
    create one, and then control it directly...

    if you shell an ie, you would need ALOT of api coding to control it... im assuming you want to control this IE for a while, yes?
    Wayne

  9. #9

    Thread Starter
    Addicted Member
    Join Date
    Sep 2009
    Posts
    176

    Re: Web browser ?

    Quote Originally Posted by wpearsall View Post
    also it would be easier to add reference to the internet explorer
    create one, and then control it directly...

    if you shell an ie, you would need ALOT of api coding to control it... im assuming you want to control this IE for a while, yes?
    Yes.
    I did just shell it to show you.
    What would be the easy way?

  10. #10
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Web browser ?

    try like this
    vb Code:
    1. Set wb = CreateObject("internetexplorer.application")
    2. wb.navigate2 "www.hotmail.com"
    3. Do Until wb.readystate = 4
    4. DoEvents
    5. Loop
    6. wb.Visible = True  'optional if you want to see the window
    7. Set ele = wb.document.forms(0)
    8.     ele.all("login").Value = "user@hotmail.com"
    9.     ele.all("passwd").Value = "pass"
    10.     ele.submit
    11. wb.Quit
    12. Set wb = Nothing
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  11. #11

    Thread Starter
    Addicted Member
    Join Date
    Sep 2009
    Posts
    176

    Re: Web browser ?

    Quote Originally Posted by westconn1 View Post
    try like this
    vb Code:
    1. Set wb = CreateObject("internetexplorer.application")
    2. wb.navigate2 "www.hotmail.com"
    3. Do Until wb.readystate = 4
    4. DoEvents
    5. Loop
    6. wb.Visible = True  'optional if you want to see the window
    7. Set ele = wb.document.forms(0)
    8.     ele.all("login").Value = "user@hotmail.com"
    9.     ele.all("passwd").Value = "pass"
    10.     ele.submit
    11. wb.Quit
    12. Set wb = Nothing
    There comes an error on the:
    vb Code:
    1. "Set WB = CreateObject("internetexplorer.application")"
    "Wrong number of argument or invalide property assignment"

  12. #12
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Web browser ?

    if wb is a webbrowser control this line is not required or valid
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  13. #13
    Frenzied Member wpearsall's Avatar
    Join Date
    Feb 2002
    Location
    England / UK
    Posts
    1,065

    Re: Web browser ?

    when u use createobject you dont need to set reference do u~? its only when dim ??? as ???, correct?

    im not sure if i forgot to actually post my last post on here, but it doesnt seem to be here... but i would recommend using the WebBrowser control [in the components list its Microsoft Internet Controls - ieframe.dll]

    it will give u more working easier

    and also...

    Dim WB as Object

    before the set WB =

    that may fix it
    Wayne

  14. #14
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Web browser ?

    when u use createobject you dont need to set reference do u~? its only when dim ??? as ???, correct?
    if you have a reference then you can declare your variable as the correct type, even if you use createobject
    if you want to use latebinding, then do not use reference and declare variable as object

    sometimes easier to add reference while writing code, then remove reference before compiling, to avoid compatibility issues for users

    i was working with an instance of internet explorer, but the op may be using a webbrowser control, most of the code will work fine, but if WB is his webbrowser it will error when trying to assign an instance of internt explorer to the control
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  15. #15

    Thread Starter
    Addicted Member
    Join Date
    Sep 2009
    Posts
    176

    Re: Web browser ?

    Now thats working.
    BUT there comes and error on ele.All("login").Value = "My@e-mail.address"
    Run time error "91"
    Object variable or With block variable not set

  16. #16
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Web browser ?

    you could try replacing
    Set ele = wb.document.forms(0)
    ele.all("login").Value = "user@hotmail.com"
    ele.all("passwd").Value = "pass"
    ele.submit
    with
    vb Code:
    1. With wb.document.forms(0)
    2.     .all("login").Value = "user@hotmail.com"
    3.     .all("passwd").Value = "pass"
    4.     .submit
    5. End With

    if you still get error it would appear that the page has not loaded correctly
    i tested the code here and it was working correctly
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  17. #17

    Thread Starter
    Addicted Member
    Join Date
    Sep 2009
    Posts
    176

    Re: Web browser ?

    Quote Originally Posted by westconn1 View Post
    you could try replacing

    with
    vb Code:
    1. With wb.document.forms(0)
    2.     .all("login").Value = "user@hotmail.com"
    3.     .all("passwd").Value = "pass"
    4.     .submit
    5. End With

    if you still get error it would appear that the page has not loaded correctly
    i tested the code here and it was working correctly
    There comes and error (424) but I think I know why. Because when I press the "Start" button to run the program and its open www.hotmail.com it comes to this site http://login.live.com/login.srf?wa=w...4855&mkt=fi-FI , then finish login site. (Because I live in Finland) so can this be the reason it comes the "error 424 Object required"?

  18. #18
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Web browser ?

    when i go directly to the finnish login page it all works
    wb.Navigate2 "http://mail.live.com/default.aspx&lc=1035&id=64855&mkt=fi-FI"
    Code:
     Olet yrittänyt kirjautua sisään liian monta kertaa käyttämällä virheellistä osoitetta tai salasanaa. 
    
    Kirjaudu sisään käyttämällä toista tiliä
    Määritä uusi salasana
    Kirjaudu sisään uudelleen käyttämällä kuvassa näkyviä merkkejä. Miksi?
    
    Windows Live ID: user@hotmail.com 
      
     
    Salasana: 
    Oletko unohtanut salasanasi? 
     Kuva:   
     
    
    6 merkkiä 
      
     
    Merkit:
    i guess that says invalid username and password
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  19. #19

    Thread Starter
    Addicted Member
    Join Date
    Sep 2009
    Posts
    176

    Re: Web browser ?

    Quote Originally Posted by westconn1 View Post
    when i go directly to the finnish login page it all works
    wb.Navigate2 "http://mail.live.com/default.aspx&lc=1035&id=64855&mkt=fi-FI"
    Code:
     Olet yrittänyt kirjautua sisään liian monta kertaa käyttämällä virheellistä osoitetta tai salasanaa. 
    
    Kirjaudu sisään käyttämällä toista tiliä
    Määritä uusi salasana
    Kirjaudu sisään uudelleen käyttämällä kuvassa näkyviä merkkejä. Miksi?
    
    Windows Live ID: user@hotmail.com 
      
     
    Salasana: 
    Oletko unohtanut salasanasi? 
     Kuva:   
     
    
    6 merkkiä 
      
     
    Merkit:
    i guess that says invalid username and password
    Thats says: You have tryed to many times to login with a wrong Username/Password. Login with a diffrent account.....
    But I was wondering why mine didnt work. Beacuse when I enter www.hotmail.com it jumps to the finnish login page and maby the ("login") and the ("passwd") isn't the same in finnish? Can we please take one more example? Lets say this site: www.gpro.se that site is allways in english. And I have a question more: How do I tell the program form example to press the login button on that page? Isi't like Press ("Login") ???

  20. #20
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Web browser ?

    How do I tell the program form example to press the login button on that page? Isi't like Press ("Login") ???
    if it is input submit button, you can just submit the form, as my example
    most times submit buttons do not have names or ids, so the only way is to loop through the elements to find some property to match then click the element

    when you navigate 2 hotmail the site must redirect, after the browser readystate ha been reached, so the next page has not loaded when your code runs (guessing here)

    vb Code:
    1. Set wb = CreateObject("internetexplorer.application")
    2. wb.Navigate2 "www.gpro.se"
    3. wb.Visible = True
    4. Do Until wb.readystate = 4
    5. DoEvents
    6. Loop
    7.  
    8. Set ele = wb.document.forms("form1")
    9.     ele.all("textlogin").Value = "user@hotmail.com"
    10.     ele.all("textpassword").Value = "pass"
    11.     ele.submit
    on this site the button does have a name and id, but it is not common for input buttons to have name
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  21. #21

    Thread Starter
    Addicted Member
    Join Date
    Sep 2009
    Posts
    176

    Re: Web browser ?

    Quote Originally Posted by westconn1 View Post
    if it is input submit button, you can just submit the form, as my example
    most times submit buttons do not have names or ids, so the only way is to loop through the elements to find some property to match then click the element

    when you navigate 2 hotmail the site must redirect, after the browser readystate ha been reached, so the next page has not loaded when your code runs (guessing here)

    vb Code:
    1. Set wb = CreateObject("internetexplorer.application")
    2. wb.Navigate2 "www.gpro.se"
    3. wb.Visible = True
    4. Do Until wb.readystate = 4
    5. DoEvents
    6. Loop
    7.  
    8. Set ele = wb.document.forms("form1")
    9.     ele.all("textlogin").Value = "user@hotmail.com"
    10.     ele.all("textpassword").Value = "pass"
    11.     ele.submit
    on this site the button does have a name and id, but it is not common for input buttons to have name
    OK but how do I who what the buttons have for name? And for example how did you know that the place where to input the username is "textlogin"?The code doesnet work beacuse I think that you must have the name of the button and not jus Submit

  22. #22
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Web browser ?

    i assure you it works as i tested it, i ran the code exactly as posted, i was redirected to a page the says i must login first, as my username was invalid

    OK but how do I who what the buttons have for name?
    read the page source code
    or loop through all the input elements in debug mode to check out all the properties

    vb Code:
    1. for each ele in wb.document.getelementsbytagname("input")
    2.       if ele.type = "submit" then msgbox ele.name
    3. next
    Last edited by westconn1; Oct 2nd, 2009 at 04:36 AM.
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  23. #23

    Thread Starter
    Addicted Member
    Join Date
    Sep 2009
    Posts
    176

    Re: Web browser ?

    Quote Originally Posted by westconn1 View Post
    i assure you it works as i tested it, i ran the code exactly as posted, i was redirected to a page the says i must login first, as my username was invalid


    read the page source code
    or loop through all the input elements in debug mode to check out all the properties

    vb Code:
    1. for each ele in wb.document.getelementsbytagname("input")
    2.       if ele.type = "submit" then msgbox ele.name
    3. next
    How do I get to see the source code?

  24. #24
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Web browser ?

    open the page in your default browser, right click > view source
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  25. #25

    Thread Starter
    Addicted Member
    Join Date
    Sep 2009
    Posts
    176

    Re: Web browser ?

    ok thank you.
    And one last question:
    what does the "ele.all" mean?

  26. #26
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Web browser ?

    in this case ele was an object for forms(1)
    ele.all is all elements in form1
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  27. #27

    Thread Starter
    Addicted Member
    Join Date
    Sep 2009
    Posts
    176

    Re: Web browser ?

    Quote Originally Posted by westconn1 View Post
    in this case ele was an object for forms(1)
    ele.all is all elements in form1
    Ok thank you. Is there some other commands that I need to know.
    For example how do I getdata from a site. Lets say www.gpro.se
    If I want to print the time on the timer (next race.... in 1day 10h 20min 58sec) into a textbox

  28. #28
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Web browser ?

    you need to find the element that contains the timer, then read the appropriate property, which may be value

    on looking at the source
    Code:
    				<font class="normal11" color="#FFFFFF">Season 16&nbsp;-&nbsp;Race&nbsp;14&nbsp;-&nbsp;<a href="TrackDetails.asp?id=34">Melbourne GP (Australia)</a>:&nbsp;October 6th 2009&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    
    					 </font>
    					 </td><td class="noborder" align="center" valign="middle" nowrap>
    					
    					 <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="https://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="350" height="20" ID="Shockwaveflash1" VIEWASTEXT>
    						<param name="movie" value="/flashstuff/cuenta&#37;20regresiva.swf?serverDay=0&serverHour=0&serverMin=0&serverSec=77519&Group=">
    						<param name="quality" value="high">
    						<embed src="/flashstuff/cuenta%20regresiva.swf?serverDay=0&serverHour=0&serverMin=0&serverSec=77519&Group=" quality="high" pluginspage="https://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="350" height="20"></embed>
    						
    					</object>
    it would appear that the countdown is a movie so i have no idea about haw to display that in your form

    if you can get the start time for the race it would be easier to calculate the difference using a timer
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  29. #29

    Thread Starter
    Addicted Member
    Join Date
    Sep 2009
    Posts
    176

    Re: Web browser ?

    Quote Originally Posted by westconn1 View Post
    you need to find the element that contains the timer, then read the appropriate property, which may be value

    on looking at the source
    Code:
    				<font class="normal11" color="#FFFFFF">Season 16&nbsp;-&nbsp;Race&nbsp;14&nbsp;-&nbsp;<a href="TrackDetails.asp?id=34">Melbourne GP (Australia)</a>:&nbsp;October 6th 2009&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    
    					 </font>
    					 </td><td class="noborder" align="center" valign="middle" nowrap>
    					
    					 <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="https://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="350" height="20" ID="Shockwaveflash1" VIEWASTEXT>
    						<param name="movie" value="/flashstuff/cuenta%20regresiva.swf?serverDay=0&serverHour=0&serverMin=0&serverSec=77519&Group=">
    						<param name="quality" value="high">
    						<embed src="/flashstuff/cuenta%20regresiva.swf?serverDay=0&serverHour=0&serverMin=0&serverSec=77519&Group=" quality="high" pluginspage="https://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="350" height="20"></embed>
    						
    					</object>
    it would appear that the countdown is a movie so i have no idea about haw to display that in your form

    if you can get the start time for the race it would be easier to calculate the difference using a timer
    OK but lets take something else:
    The top 16 Elite standings after race 13 of 17.
    How do I inport that to my form and view it in a textbox of something

  30. #30
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Web browser ?

    try like this
    vb Code:
    1. Set es = wb.document.getelementbyid("table10")
    2. For Each ele In es.getelementsbytagname("tr")
    3.     For Each td In ele.getelementsbytagname("td")
    4.         msg = msg & td.innertext & " "
    5.     Next
    6.     msg = msg & vbNewLine
    7. Next
    8.     MsgBox msg
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

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