none
How to activate a textbox in the webbrowser control RRS feed

  • Question

  •  

    hello how do i activate a textbox in the webbrowser control? I have this code to navigate to the webpage but it does send the keys since the textbox in the webbrowser is not activated:

    Code Snippet

    Private Sub ToolStripButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton1.Click

    WebBrowser1.Navigate("http://www.live.com/?searchonly=true&mkt=en-AU")

    SendKeys.Send(ToolStripComboBox1.Text)

    SendKeys.Send("{Enter}")

    End Sub

     

    Everytime i click the toolstripbutton1 it just navigates to the page and then i have to manually click the textbox and click the toolstripbutton1 button again to make it search.

    Is there a way i could fix this?

     

    Thanks.

    Sunday, March 23, 2008 12:10 AM

Answers

  • Hi Travy,

    Based on my understanding, you load Live Search site into Webbrowser control, then you want to use SendKeys.Send method to input data in TextBox and click Button on web page, in order to implement programmatically automatic search feature.

    But the SendKeys.Send method is not reliable and stable in you scenario, because current focus is easily to changed and not easily to control. When you click ToolStripButton1, the default focus on Search textbox will move to ToolStripButton1 itself, thus SendKeys.Send(ToolStripComboBox1.Text) will not be sent to Search textbox.

    1. To avoid current focus moving off Search textbox, here is a workaround:
    Add a switch variable and place related code into WebBrowser1_DocumentCompleted event.

    Public Class Form1  
     
        Dim newSearch As Boolean = True 
     
        Private Sub Button1_Click(ByVal sender As System.ObjectByVal e As System.EventArgs) Handles Button1.Click  
            WebBrowser1.Navigate("http://www.live.com/?searchonly=true&mkt=en-AU")  
            newSearch = True 
        End Sub 
     
        Private Sub WebBrowser1_DocumentCompleted(ByVal sender As System.ObjectByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted  
            If newSearch = True Then 'If not new search,it doen't need repeatly execute the WebBrowser1_DocumentCompleted event  
                SendKeys.Send(TextBox1.Text)'At begin,the focus is on Search TextBox   
                SendKeys.Send("{Tab}"'Move focus to Search button  
                SendKeys.Send("{Enter}")  
                newSearch = False 
            End If 
        End Sub 
     
    End Class 


    2. Alternatively, here is one reliable and stable idea:
    Use WebBrowser to locate the
    Search textbox and input data, and locate Search button and click it.

    Basic principle:

    Firstly load web page on WebBrowser object, then use GetElementsByTagName or GetElementsByID function to locate webpage elements in WebBrowser.Document and automate them (e.g. retrieve page text, login website, search, click button or hyperlink).

     

    Beforehand, we need to find out web elements’ source html code via viewing source (Right-click on web page -> "View Source" menu item).

    Example: Automatically login in one website (input uername/password in TextBox and click Login button)
    By Viewing html code of the Live Search page, you can find the two elements:
    The Search TextBox:
    <input value="" id="q" name="q" class="q" title="Search for"/>
    The Search Button:
    <input type="submit" value="Search" tabindex="0" name="go" class="go" />

    Code sample:

    Public Class Form1  
     
        Private Sub Form1_Load(ByVal sender As System.ObjectByVal e As System.EventArgs) Handles MyBase.Load  
            ' Load homepage in Form_Load event  
            WebBrowser1.Navigate("http://www.live.com/?searchonly=true&mkt=en-AU")  
        End Sub 
     
        Private Sub ToolStripButton1_Click(ByVal sender As System.ObjectByVal e As System.EventArgs) Handles ToolStripButton1.Click  
            ' Locate the Search TextBox and automatically input username  
            '<input value="" id="q" name="q" class="q" title="Search for"/>  
            Dim theElementCollection As HtmlElementCollection = WebBrowser1.Document.GetElementsByTagName("Input")  
            For Each curElement As HtmlElement In theElementCollection  
                Dim controlName As String = curElement.GetAttribute("Name").ToString  
                If controlName = "q" Then 
                    curElement.SetAttribute("Value", ToolStripComboBox1.Text)  
                End If 
            Next 
     
            ' Locate the Search Button and automatically click it  
            '<input type="submit" value="Search" tabindex="0" name="go" class="go"/>  
            Dim theWElementCollection As HtmlElementCollection = WebBrowser1.Document.GetElementsByTagName("Input")  
            For Each curElement As HtmlElement In theWElementCollection  
                If curElement.GetAttribute("value").Equals("Search"Then 
                    curElement.InvokeMember("click")  
                    'Javascript has a click method for we need to invoke on the current submit button element.  
                End If 
            Next 
        End Sub 
     
    End Class 


    Glad to help you.
    If you still have any doubt and concern about this issue, please let me know.



    Best regards,
    Martin Xie

    Wednesday, March 26, 2008 9:08 AM
  • Alright thankyou for all your help!

     

    I found the solution, here it is:

     

    Code Snippet

    Private Sub WebBrowser1_DocumentCompleted(ByVal sender As Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted

    If AddressBar.Text = "http://www.google.com.au/" Then

    ' Locate the Search TextBox and automatically input username

    ' <input maxlength=2048 name=q size=55 title="Google Search" value="">

    Dim theElementCollection As HtmlElementCollection = WebBrowser1.Document.GetElementsByTagName("Input")

    For Each curElement As HtmlElement In theElementCollection

    Dim controlName As String = curElement.GetAttribute("maxlength").ToString

    If controlName = "2048" Then

    curElement.SetAttribute("value", SearchBar.Text)

    End If

    Next

    ' Locate the Search Button and automatically click it

    '<input name=btnG type=submit value="Google Search">

    Dim theWElementCollection As HtmlElementCollection = WebBrowser1.Document.GetElementsByTagName("Input")

    For Each curElement As HtmlElement In theWElementCollection

    Dim controlName1 As String = curElement.GetAttribute("name").ToString

    If controlName1 = "btnG" Then

    curElement.InvokeMember("click")

    End If

    Next

    End If

    End Sub

     

    So by putting the code in the DocumentCompleted sub and using the If.... Then Statement i figured it out.

     

    Also i changed the code abit when i was playing around with it Stick out tongue

     

    Regards,

                 Travis.

     

    Monday, April 7, 2008 8:01 AM

All replies

  • Hi Travy,

    Based on my understanding, you load Live Search site into Webbrowser control, then you want to use SendKeys.Send method to input data in TextBox and click Button on web page, in order to implement programmatically automatic search feature.

    But the SendKeys.Send method is not reliable and stable in you scenario, because current focus is easily to changed and not easily to control. When you click ToolStripButton1, the default focus on Search textbox will move to ToolStripButton1 itself, thus SendKeys.Send(ToolStripComboBox1.Text) will not be sent to Search textbox.

    1. To avoid current focus moving off Search textbox, here is a workaround:
    Add a switch variable and place related code into WebBrowser1_DocumentCompleted event.

    Public Class Form1  
     
        Dim newSearch As Boolean = True 
     
        Private Sub Button1_Click(ByVal sender As System.ObjectByVal e As System.EventArgs) Handles Button1.Click  
            WebBrowser1.Navigate("http://www.live.com/?searchonly=true&mkt=en-AU")  
            newSearch = True 
        End Sub 
     
        Private Sub WebBrowser1_DocumentCompleted(ByVal sender As System.ObjectByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted  
            If newSearch = True Then 'If not new search,it doen't need repeatly execute the WebBrowser1_DocumentCompleted event  
                SendKeys.Send(TextBox1.Text)'At begin,the focus is on Search TextBox   
                SendKeys.Send("{Tab}"'Move focus to Search button  
                SendKeys.Send("{Enter}")  
                newSearch = False 
            End If 
        End Sub 
     
    End Class 


    2. Alternatively, here is one reliable and stable idea:
    Use WebBrowser to locate the
    Search textbox and input data, and locate Search button and click it.

    Basic principle:

    Firstly load web page on WebBrowser object, then use GetElementsByTagName or GetElementsByID function to locate webpage elements in WebBrowser.Document and automate them (e.g. retrieve page text, login website, search, click button or hyperlink).

     

    Beforehand, we need to find out web elements’ source html code via viewing source (Right-click on web page -> "View Source" menu item).

    Example: Automatically login in one website (input uername/password in TextBox and click Login button)
    By Viewing html code of the Live Search page, you can find the two elements:
    The Search TextBox:
    <input value="" id="q" name="q" class="q" title="Search for"/>
    The Search Button:
    <input type="submit" value="Search" tabindex="0" name="go" class="go" />

    Code sample:

    Public Class Form1  
     
        Private Sub Form1_Load(ByVal sender As System.ObjectByVal e As System.EventArgs) Handles MyBase.Load  
            ' Load homepage in Form_Load event  
            WebBrowser1.Navigate("http://www.live.com/?searchonly=true&mkt=en-AU")  
        End Sub 
     
        Private Sub ToolStripButton1_Click(ByVal sender As System.ObjectByVal e As System.EventArgs) Handles ToolStripButton1.Click  
            ' Locate the Search TextBox and automatically input username  
            '<input value="" id="q" name="q" class="q" title="Search for"/>  
            Dim theElementCollection As HtmlElementCollection = WebBrowser1.Document.GetElementsByTagName("Input")  
            For Each curElement As HtmlElement In theElementCollection  
                Dim controlName As String = curElement.GetAttribute("Name").ToString  
                If controlName = "q" Then 
                    curElement.SetAttribute("Value", ToolStripComboBox1.Text)  
                End If 
            Next 
     
            ' Locate the Search Button and automatically click it  
            '<input type="submit" value="Search" tabindex="0" name="go" class="go"/>  
            Dim theWElementCollection As HtmlElementCollection = WebBrowser1.Document.GetElementsByTagName("Input")  
            For Each curElement As HtmlElement In theWElementCollection  
                If curElement.GetAttribute("value").Equals("Search"Then 
                    curElement.InvokeMember("click")  
                    'Javascript has a click method for we need to invoke on the current submit button element.  
                End If 
            Next 
        End Sub 
     
    End Class 


    Glad to help you.
    If you still have any doubt and concern about this issue, please let me know.



    Best regards,
    Martin Xie

    Wednesday, March 26, 2008 9:08 AM
  • Thankyou for this! Could you please get the code to activate the google textbox (from the homepage www.google.com)?

    Because i don't know how to read Javascript in View>Source.

     

    Thankyou.

     

    Sunday, April 6, 2008 11:59 AM
  •  Travy92 wrote:

    Thankyou for this! Could you please get the code to activate the google textbox (from the homepage www.google.com)?

     

    Hi Travy,

     

    By Viewing html code of google homepage http://www.google.com, you can find the two elements:

     

    The Search TextBox:

    <input maxlength=2048 name=q size=55 title="Google Search" value="">

    The Search Button:

    <input name=btnG type=submit value="Google Search">

     

    Then the following code sample will work perfect as you expect:

    Prerequisites: ToolStrip1 (containing ToolStripButton1 and ToolStripComboBox1) and WebBrowser1 on Form1

    Code Snippet

    Public Class Form1

     

        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

            ' Load homepage in Form_Load event

            WebBrowser1.Navigate("http://www.google.com")

        End Sub

     

        Private Sub ToolStripButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton1.Click

            ' Locate the Search TextBox and automatically input username

            ' <input maxlength=2048 name=q size=55 title="Google Search" value="">

            Dim theElementCollection As HtmlElementCollection = WebBrowser1.Document.GetElementsByTagName("Input")

            For Each curElement As HtmlElement In theElementCollection

                Dim controlName As String = curElement.GetAttribute("Name").ToString

                If controlName = "q" Then

                    curElement.SetAttribute("Value", ToolStripComboBox1.Text)

                End If

            Next

     

            ' Locate the Search Button and automatically click it

            '<input name=btnG type=submit value="Google Search">

            Dim theWElementCollection As HtmlElementCollection = WebBrowser1.Document.GetElementsByTagName("Input")

            For Each curElement As HtmlElement In theWElementCollection

                If curElement.GetAttribute("value").Equals("Google Search") Then

                    curElement.InvokeMember("click")

                End If

            Next

        End Sub

     

    End Class

     

     

    Monday, April 7, 2008 4:09 AM
  • For some reason it's still not working!

    The WebBrowser jsut loads and does nothing. But one thing it does do is give focus to hte google textbox.

     

    Any Help Tongue Tied

     

    Monday, April 7, 2008 7:22 AM
  • Hi Travis,

     

    The process is this:

    When Form1 opens, google homepage will be loaded on WebBrowser1. Then you need to input text or select text in ToolStripComboBox1 used for search words, finally clicking ToolStripButton1 will perform Google search simulately.

    Please take it a try.

    Monday, April 7, 2008 7:37 AM
  • Yep i tried it again and only after clicking the "Search" button (ToolStripButton1) like 20 times the words apear in the google textbox. And it doesn't even click the button.

     

    Sad

     

    Monday, April 7, 2008 7:41 AM
  • Alright thankyou for all your help!

     

    I found the solution, here it is:

     

    Code Snippet

    Private Sub WebBrowser1_DocumentCompleted(ByVal sender As Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted

    If AddressBar.Text = "http://www.google.com.au/" Then

    ' Locate the Search TextBox and automatically input username

    ' <input maxlength=2048 name=q size=55 title="Google Search" value="">

    Dim theElementCollection As HtmlElementCollection = WebBrowser1.Document.GetElementsByTagName("Input")

    For Each curElement As HtmlElement In theElementCollection

    Dim controlName As String = curElement.GetAttribute("maxlength").ToString

    If controlName = "2048" Then

    curElement.SetAttribute("value", SearchBar.Text)

    End If

    Next

    ' Locate the Search Button and automatically click it

    '<input name=btnG type=submit value="Google Search">

    Dim theWElementCollection As HtmlElementCollection = WebBrowser1.Document.GetElementsByTagName("Input")

    For Each curElement As HtmlElement In theWElementCollection

    Dim controlName1 As String = curElement.GetAttribute("name").ToString

    If controlName1 = "btnG" Then

    curElement.InvokeMember("click")

    End If

    Next

    End If

    End Sub

     

    So by putting the code in the DocumentCompleted sub and using the If.... Then Statement i figured it out.

     

    Also i changed the code abit when i was playing around with it Stick out tongue

     

    Regards,

                 Travis.

     

    Monday, April 7, 2008 8:01 AM
  • That's great! Congratulations!
    Monday, April 7, 2008 8:31 AM
  • Hey i was wondering if you could also get the name of the TextBox in rapidshare?
    its http://rapidshare.com.

     

    And i can't find the code for the textbox, it jsut goes from teh radio buttons straight to the "Browse" button!

     

    I need it for an add-on for my IE. Thanks

     

    Sunday, April 13, 2008 12:21 PM
  •  Travy92 wrote:

    Hey i was wondering if you could also get the name of the TextBox in rapidshare?
    its
    http://rapidshare.com.

    And i can't find the code for the textbox, it jsut goes from teh radio buttons straight to the "Browse" button!

     

    Hi Travis,

     

    Please note that: The TextBox and Browse button combination is a special individual element as below:

    <input type="file" size="64" name="filecontent">

     

    However, generally setting value for this field programmatically is considered a security risk and is not supported.

     

    Please check this KB article for detail.

    http://support.microsoft.com/kb/266087

    Cannot Use Script to Manipulate INPUT TYPE=File Value

    Code Block

    SYMPTOMS

    If you use an INPUT TYPE=File element in an HTML FORM element, you cannot set a file name programmatically, regardless if you use script or set the VALUE property of the INPUT element to a default value.

    CAUSE

    Because INPUT TYPE=File allows arbitrary files to be uploaded from a user's computer to a remote server, setting this field programmatically is considered a security risk and is not supported.

    RESOLUTION

    Uploading content from a user's computer without his or her knowledge is contrary to the security paradigms of Web development. The user should be informed whenever content is going to be transferred off their computer, and the user should be given every opportunity to control or cancel the operation.

    If you require such functionality in your Web-based application, use an ActiveX control that is marked unsafe for scripting and/or unsafe for initialization. (The author of the control is responsible for telling users that the control is unsafe because, by definition, uploading files are unsafe. You can sign the control to ask users to trust your control.)

     

    Similar issues:

    http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2489516&SiteID=1

    http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2678032&SiteID=1

    Populate File type input field with text field value

     

     

    Regards,

    Martin

    • Proposed as answer by Kewl v Thursday, July 9, 2009 2:05 AM
    Monday, April 14, 2008 2:33 AM
  • Not work =[
    Thursday, July 9, 2009 1:54 AM
  • Hi Travy,

    Based on my understanding, you load Live Search site into Webbrowser control, then you want to use SendKeys.Send method to input data in TextBox and click Button on web page, in order to implement programmatically automatic search feature.

    But the SendKeys.Send method is not reliable and stable in you scenario, because current focus is easily to changed and not easily to control. When you click ToolStripButton1, the default focus on Search textbox will move to ToolStripButton1 itself, thus SendKeys.Send(ToolStripComboBox1.Text) will not be sent to Search textbox.

    1. To avoid current focus moving off Search textbox, here is a workaround:
    Add a switch variable and place related code into WebBrowser1_DocumentCompleted event.

    Public Class Form1  
     
        Dim newSearch As Boolean = True 
     
        Private Sub Button1_Click(ByVal sender As System.ObjectByVal e As System.EventArgs) Handles Button1.Click  
            WebBrowser1.Navigate("http://www.live.com/?searchonly=true&mkt=en-AU")  
            newSearch = True 
        End Sub 
     
        Private Sub WebBrowser1_DocumentCompleted(ByVal sender As System.ObjectByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted  
            If newSearch = True Then 'If not new search,it doen't need repeatly execute the WebBrowser1_DocumentCompleted event  
                SendKeys.Send(TextBox1.Text)'At begin,the focus is on Search TextBox   
                SendKeys.Send("{Tab}"'Move focus to Search button  
                SendKeys.Send("{Enter}")  
                newSearch = False 
            End If 
        End Sub 
     
    End Class 


    2. Alternatively, here is one reliable and stable idea:
    Use WebBrowser to locate the
    Search textbox and input data, and locate Search button and click it.

    Basic principle:

    Firstly load web page on WebBrowser object, then use GetElementsByTagName or GetElementsByID function to locate webpage elements in WebBrowser.Document and automate them (e.g. retrieve page text, login website, search, click button or hyperlink).

     

    Beforehand, we need to find out web elements’ source html code via viewing source (Right-click on web page -> "View Source" menu item).

    Example:

     

    Automatically login in one website (input uername/password in TextBox and click Login button)
    By Viewing html code of the Live Search page, you can find the two elements:
    The Search TextBox:
    <input value="" id="q" name="q" class="q" title="Search for"/>
    The Search Button:
    <input type="submit" value="Search" tabindex="0" name="go" class="go" />

    Code sample:

    Public Class Form1  
     
        Private Sub Form1_Load(ByVal sender As System.ObjectByVal e As System.EventArgs) Handles MyBase.Load  
            ' Load homepage in Form_Load event  
            WebBrowser1.Navigate("http://www.live.com/?searchonly=true&mkt=en-AU")  
        End Sub 
     
        Private Sub ToolStripButton1_Click(ByVal sender As System.ObjectByVal e As System.EventArgs) Handles ToolStripButton1.Click  
            ' Locate the Search TextBox and automatically input username  
            '<input value="" id="q" name="q" class="q" title="Search for"/>  
            Dim theElementCollection As HtmlElementCollection = WebBrowser1.Document.GetElementsByTagName("Input")  
            For Each curElement As HtmlElement In theElementCollection  
                Dim controlName As String = curElement.GetAttribute("Name").ToString  
                If controlName = "q" Then 
                    curElement.SetAttribute("Value", ToolStripComboBox1.Text)  
                End If 
            Next 
     
            ' Locate the Search Button and automatically click it  
            '<input type="submit" value="Search" tabindex="0" name="go" class="go"/>  
            Dim theWElementCollection As HtmlElementCollection = WebBrowser1.Document.GetElementsByTagName("Input")  
            For Each curElement As HtmlElement In theWElementCollection  
                If curElement.GetAttribute("value").Equals("Search"Then 
                    curElement.InvokeMember("click")  
                    'Javascript has a click method for we need to invoke on the current submit button element.  
                End If 
            Next 
        End Sub 
     
    End Class 


    Glad to help you.
    If you still have any doubt and concern about this issue, please let me know.



    Best regards,
    Martin Xie










    I would like to automate the following page: https://post.craigslist.org/atl/S/msg/none/x but I noticed when I click "View Source" on IE, that Craigslist has made some of the elements hidden or not visible.

    This code isn't clicking the button:

    theElementCollection = WebBrowser1.Document.GetElementsByTagName(

    "input")
    For Each curElement As HtmlElement In theElementCollection
    If curElement.GetAttribute("value").Equals("Continue") Then
    curElement.InvokeMember("click")
    End If
    Next



    I figured out how to automate everything on this page except the button click. I tried all the methods that I seen within the forums, but I still can't get the "Continue Button" on the bottom of this page to click and go to the next page. Any input would be appreciated.
    Monday, August 3, 2009 4:01 AM
  • Hi Inforequester123,

    1. No matter whether some elements are hidden from page UI, we usually can locate them based on element attributes and automate them.
    FAQ: How do I automate a web page (e.g. retrieve page text, login website, search, click button or hyperlink) via WebBrowser
    http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/23dfc3f9-3274-4929-8dc5-9ba543f4911d


    2. Please double check the page HTML code and the "Continue" button's HTML code is as below:

            <button tabindex="1" type="submit" name="U2FsdGVkX18xNTM0NDE1MyrfgTOsvyQELh:vRUZTG-gO8x8oD7PQ.-4ruvlg6b9avo" value="Continue">Continue</button>

     

    Please note: Its TagName is "button" not "input".

    Correct code sample

            Dim theElementCollection As HtmlElementCollection

            theElementCollection = WebBrowser1.Document.GetElementsByTagName("button")

            For Each curElement As HtmlElement In theElementCollection

                If curElement.GetAttribute("value").Equals("Continue") Then

                    curElement.InvokeMember("click")

                End If

            Next




    Best regards,
    Martin Xie


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback on our support, please contact msdnmg@microsoft.com
    Wednesday, August 5, 2009 11:51 AM
  • Hi Inforequester123,

    1. No matter whether some elements are hidden from page UI, we usually can locate them based on element attributes and automate them.
    FAQ: How do I automate a web page (e.g. retrieve page text, login website, search, click button or hyperlink) via WebBrowser
    http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/23dfc3f9-3274-4929-8dc5-9ba543f4911d


    2. Please double check the page HTML code and the "Continue" button's HTML code is as below:

            <button tabindex="1" type="submit" name="U2FsdGVkX18xNTM0NDE1MyrfgTOsvyQELh:vRUZTG-gO8x8oD7PQ.-4ruvlg6b9avo" value="Continue">Continue</button>

     

    Please note: Its TagName is "button" not "input".

    Correct code sample

            Dim theElementCollection As HtmlElementCollection

            theElementCollection = WebBrowser1.Document.GetElementsByTagName("button")

            For Each curElement As HtmlElement In theElementCollection

                If curElement.GetAttribute("value").Equals("Continue") Then

                    curElement.InvokeMember("click")

                End If

            Next




    Best regards,
    Martin Xie


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback on our support, please contact msdnmg@microsoft.com

    Love you Martin !!! You're AWESOME !!! Thanks again old pal !!! Haven't heard from you in awhile, but I hope you've been doing ok! Here's another point for you!!!
    Thursday, August 6, 2009 3:38 AM
  • Dear Inforequester,
    You're welcome! Glad to hear that you figured it out :) Cheers!

    Thursday, August 6, 2009 4:09 AM
  • Hello Sir, i am creating a software that is similar to RoboForms. I have completed the module of reading from database. And now i want to read from some other software, for example :  if someone had filled the registration for(win app) , i want to get that data and enter it in the website that is browsed thru the webBrowser in my software.

    Please help me out.
    Friday, February 12, 2010 6:27 PM
  • Sir,

              Using the same Webbroser control I want to navigate to another pages. Is it possible?

    Thanks & Regards,

    Sony

     

     

    Friday, August 6, 2010 7:52 AM
  • Sir,

              Using the same Webbroser control I want to navigate to another pages. Is it possible?

    Thanks & Regards,

    Sony

     

     


    Could you give more details? I know it's a stupid question, Why this?
    • Proposed as answer by Dennisngkh Tuesday, October 19, 2010 3:24 AM
    Friday, September 10, 2010 12:57 AM
  • hi, i tried to auto log in my webmail but i fail to input id and password. appreciate if any expert can advice me here. my code: 

     

    Public Class Form1
    
    
    
      Private Sub WebBrowser1_DocumentCompleted(ByVal sender As Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
        ' Part 2: Automatically input username and password
        Dim theElementCollection As HtmlElementCollection = WebBrowser1.Document.GetElementsByTagName("input")
    
        For Each curElement As HtmlElement In theElementCollection
    
          Dim controlName As String = curElement.GetAttribute("name").ToString
    
          If controlName = "gui.frm_login.tabs.tab1.inp_usermain" Then
    
            ' curElement.GetAttribute("Value")
    
            curElement.SetAttribute("Value", "")
    
          ElseIf controlName = "gui.frm_login.tabs.tab1.inp_passmain" Then
    
            curElement.SetAttribute("Value", "")
    
          End If
    
        Next
    
        ' Part 3: Automatically click the Login button
        Dim theWElementCollection As HtmlElementCollection = WebBrowser1.Document.GetElementsByTagName("input")
        For Each curElement As HtmlElement In theWElementCollection
          If curElement.GetAttribute("value").Equals("Login") Then
            curElement.InvokeMember("click")
            ' javascript has a click method for we need to invoke on the current submit button element.
          End If
        Next
      End Sub
    
      Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        WebBrowser1.Navigate("http://120.50.39.206:32000/webmail/")
      End Sub
    End Class
    


    Tuesday, October 19, 2010 3:29 AM
  • Dear Martin,

     

    can you help me? i have a question on this link? about harvesting google SERP and put it in richtextbox...

     

    http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/6dfdd0f9-fb33-46e4-b2e6-a6d653869572/

     

    i hope you can help me.... really need help...

     

    thanks


    http://www.plasma-hd.com

    http://www.findurlove.info

    Sunday, October 24, 2010 5:25 AM
  • Hello Travy92,

     

    Considering that many developers in this forum ask how to automate a web page via WebBrowser, rotate or flip images, my team has created a code sample for this frequently asked programming task in Microsoft All-In-One Code Framework. You can download the code samples at:

     

    VBWebBrowserAutomation

     

    http://bit.ly/VBWebBrowserAutomation

     

    CSWebBrowserAutomation

     

    http://bit.ly/CSWebBrowserAutomation

     

    With these code samples, we hope to reduce developers’ efforts in solving the frequently asked

    programming tasks. If you have any feedback or suggestions for the code samples, please email us: onecode@microsoft.com.

    ------------

    The Microsoft All-In-One Code Framework (http://1code.codeplex.com) is a free, centralized code sample library driven by developers' needs. Our goal is to provide typical code samples for all Microsoft development technologies, and reduce developers' efforts in solving typical programming tasks.

    Our team listens to developers’ pains in MSDN forums, social media and various developer communities. We write code samples based on developers’ frequently asked programming tasks, and allow developers to download them with a short code sample publishing cycle. Additionally, our team offers a free code sample request service. This service is a proactive way for our developer community to obtain code samples for certain programming tasks directly from Microsoft.

    Thanks

    Microsoft All-In-One Code Framework

    Thursday, March 24, 2011 10:23 AM
  • Hi,

    How can i click this button ?

    <img src=​"image/​btn/​odemeTransferFaturaTakip.gif" align=​"absmiddle" border=​"1" height=​"18" style=​"margin-bottom:​ 0px;​ border-top-color:​ rgb(247, 243, 238)​;​ border-right-color:​ rgb(247, 243, 238)​;​ border-bottom-color:​ rgb(247, 243, 238)​;​ border-left-color:​ rgb(247, 243, 238)​;​ " name=​"menuImg" id=​"odemeTransferFaturaTakip">​

    <a type=​"button" href=​"?b=_odemeTransferFaturaTakip" onmouseover=​"renkliYap('odemeTransferFaturaTakip')​" onmouseout=​"griYap('odemeTransferFaturaTakip')​" class=​"menubuton">​Fatura Tahsilatı​</a>​

    i tried many different ways but i cant.

    im trying with this code:

     

    theElementCollection = WebBrowser1.Document.GetElementsByTagName("button")
        For Each curElement As HtmlElement In theElementCollection
          If curElement.GetAttribute(" href=").Equals("?b=_odemeTransferFaturaTakip") Then
            curElement.InvokeMember("click")
            ' javascript has a click method for you need to invoke on button and hyperlink elements.
    
          End If
    


     

     

     

    Friday, December 2, 2011 11:07 AM
  • Hi Martin Xie - MSFT,

    I know you are well programmer expert of Visual Studio. Last few days i saw your threads and now i am one of the fans of yours. I know you can able to give me the solution of my thread, please reply there, I love your style of reply because you always show the full code and that's why i personally invite you. link: http://social.msdn.microsoft.com/Forums/en-US/vsmantest/thread/ee944a0e-f460-4665-a12a-d92c4d5fbb29/

    Thread Details:

    I am very new at this stage but i want to make myself as a Visual Studio Expert. I trying to make a automated software via Visual Studio 2012. I want, it will auto "sign in" in my 5 twitter accounts and follow a user one by one and after that it will auto log out. For Example, I will input in the box usernames and passwords like this ------  username1:password

                                                                       username2:password

                                                                       username3:password and continue

    And into other box i will input the username which need followers.

    I need after i click my button, it will start auto sign in into my twitter accounts and follow my preferred user and then it sign out and again it start and complete all 5 accounts.

    A radio button is also available there.

    Please help me as soon as possible, i have no any dishonest reason, i just want to learn it. I know many expert and helpful are available here.

    Thanks and waiting for your reply.

    My created code: Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            If RadioButton1.Checked = True Then
                WebBrowser1.Navigate("https://mobile.twitter.com/session/new")
                ?????????????? (I don't know what i do here)
            End If

    Monday, April 15, 2013 3:07 AM