Shoutbox

VB auto click - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Skype & Technology (/forumdisplay.php?fid=9)
+---- Forum: Tech Talk (/forumdisplay.php?fid=17)
+----- Thread: VB auto click (/showthread.php?tid=44271)

VB auto click by DJeX on 05-06-2005 at 11:37 PM

Hi I'm making a program that will automaticly navigate a website. It's for a friend of mine. I just can't figure out how to click on things in the IE web browser control in VB. Any one have any ideas?


RE: VB auto click by Dempsey on 05-06-2005 at 11:43 PM

code:
Web1.Document.All("username").Value = txtEmail.text
Web1.Document.All("password").Value = txtPass.text
Web1.Document.All("null").Click

I don't know if that helps but thats how I login into my Google Adsense account through VB.

I'm not sure if it works for links.
RE: VB auto click by DJeX on 05-06-2005 at 11:55 PM

That code does not work for me. I get a "Object varible or With block not set" error.


RE: VB auto click by Dempsey on 05-07-2005 at 12:00 AM

did you make sure the page was fully loaded before you used it?  And did you modify the code or do it on a page that has text fields called 'username' and 'password' ?


RE: VB auto click by DJeX on 05-07-2005 at 12:19 AM

this code works better:

code:
Private Sub Command1_Click()
Do Until wb.ReadyState = READYSTATE_COMPLETE


    DoEvents
    Loop
    On Error Resume Next
    wb.Document.Forms(0).email.Value = "username"
    wb.Document.Forms(0).passwd.Value = "password"
    wb.Document.Forms(0).submit
End Sub

Private Sub Form_Load()
wb.Navigate "https://www.google.com/accounts/ServiceLogin?
service=mail&passive=true&continue=http%3A%2F%2Fgmail.google.com
%2Fgmail%3Fui%3Dhtml%26zy%3Dl"
End Sub

Does any one know how to click on links?
RE: VB auto click by Dempsey on 05-07-2005 at 12:27 AM

code:
Sub ReplaceElementAttributes()
    Dim objDoc As FPHTMLDocument
    Dim objElement As IHTMLElement
    Dim strTempText As String

    Const CHARACTER_LENGTH As Integer = 7
    Const STRING_FOUND As Integer = 1
    Const TAG_NAME As String = "a"
    Const ATTRIBUTE_NAME As String = "href"
    Const TARGET_STRING As String = "http://"

    Set objDoc = ActiveDocument

    ' Remove "http://" from the href attribute of all
    ' A elements in the document.
    For Each objElement In objDoc.all.tags(tagName:=TAG_NAME)
        strTempText = objElement.getAttribute _
            (strAttributeName:=ATTRIBUTE_NAME)
        ' Remove "http://" only if it appears at the beginning
        ' of the href attribute's value.
        If InStr(strTempText, TARGET_STRING) = STRING_FOUND Then
            strTempText = Right(strTempText, _
                Len(strTempText) - CHARACTER_LENGTH)
        End If
    Next objElement
End Sub
I found that on msdn here

you could use that and the link url is in 'strTempText' then u could do like
code:
wb.navigate strTempText

RE: VB auto click by DJeX on 05-07-2005 at 01:38 AM

Interesting, do you know where I could find all the opetions for the web browser control. Like I never knew there was a .Document thing that you can use to control the web page. I want to know more about that.


RE: VB auto click by Dempsey on 05-07-2005 at 08:46 AM

Reference for Visual Basic Developers (Internet Explorer - WebBrowser)