Results 1 to 6 of 6

Thread: Automating web page ...

  1. #1

    Thread Starter
    Junior Member
    Join Date
    May 2005
    Posts
    18

    Automating web page ...

    Hey! I'm sure a few of you programmers have tried web page automation via a program you've made or tried out. The best example would be to log into a site and access data, for example... if you have any new e-mails. Heres my problem!

    HTML Code:
    <input type=hidden name=sponsor value=- by FreeEmails>
    VB Code:
    1. 'Clear sponsor text
    2.     Set hInp = hDoc.getElementById("sponsor")
    3.     hInp.focus
    4.     hInp.Value = "new emails for me!"
    5.     ProgressBar1.Value = 5

    At first glance, it looks rather easy to automate and change the above data but its not lol For username and password input boxes, the input type is Text, the above HTML's input type is Hidden! And if i wanted to change the Value for the above HTML code i cannot use the hInp.focus to gain the focus because the input type is hidden. Hidden objects cannot recieve focus! If anyone could help me with this little problem, or enjoys a challenge then please reply! Thanks for your time! Odhran

  2. #2
    Hyperactive Member
    Join Date
    Jul 2001
    Location
    Chesterfield, Mi
    Posts
    259

    Re: Automating web page ...

    as long as all the fields have a name value set you can address them directly.

    .document.nameoffield.value

    Or you can use forms and cycle through all form elements. I'm sure theres a few more ways as well.

    Just don't make any kind of spamming program

  3. #3

    Thread Starter
    Junior Member
    Join Date
    May 2005
    Posts
    18

    Re: Automating web page ...

    Well thats strange... I tried this:
    HTML Code:
    <input type=hidden name=sponsor value=- by FreeEmails>
    VB Code:
    1. Set hInp = hDoc.getElementById("sponsor")
    2.     MsgBox WebBrowser1.document.Forms(1).elements(0).Value
    3.     WebBrowser1.document.Forms(1).elements(0).Value = "new emails for me!"
    4.     MsgBox WebBrowser1.document.Forms(1).elements(0).Value
    5.     ProgressBar1.Value = 5

    When the 1st message box pops up it display the value of "sponsor" which I know is actually "- by FreeEmails" from the HTML code. But the value of sponsor comes up as "-". Strange!
    Then I change the value of sponsor, view it again and it appears to have changed ... but hasn't lol This is confusing me!

    I have noticed though, sponsor's value ISN't in quotations ... which is odd. And when I extract the value for sponsor it only takes out 1 character. So when viewing/replacing I seem to be replacing just that 1 character. I know, this is quite confusing... but if anyone has any clever ideas it would be so helpful! Please reply! lol Thanks for your time

    Odhran

  4. #4
    Super Moderator RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,713

    Re: Automating web page ...

    Check my code examples in this thread - http://www.vbforums.com/showthread.php?t=330341
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  5. #5

    Thread Starter
    Junior Member
    Join Date
    May 2005
    Posts
    18

    Re: Automating web page ...

    Hey RobDog, checked out that link ... love that thread cus I based most of my work on it lol But I can't seem to find anything to solve this pain in the ass problem! lol Any other ideas would be fantastic!

  6. #6
    Member
    Join Date
    Sep 2004
    Posts
    52

    Re: Automating web page ...

    I always use a dom Inspector... it really simplifies things.

    http://www.ieinspector.com/dominspector/

    You can point it at any web oject and it will return a DOM reference to it. It shows hidden objects too. That software comes free wiith mozilla firefox by the way.

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