Page 3 of 14 FirstFirst 12345613 ... LastLast
Results 81 to 120 of 531

Thread: Manipulate/Change/Form Fill data in webpages using the Webbrowser control

  1. #81
    New Member
    Join Date
    May 2007
    Posts
    4

    Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control

    I want to be able to do this from within an ASP.NET application.

    Now I'm down to just wondering if I should have the web app start off an exe webform app and communicate with it somehow... probably not worth it.

    Is there no other way besides these WebBrowser objects to deal with executing javascript that does whatever and eventually takes me to another page? Without writing a javascript interpreter or something, hah.

  2. #82
    New Member
    Join Date
    May 2007
    Posts
    4

    Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control

    Nice, I can do .Navigate and have the URL string just be the javascript in the link instead (with the .NET System.Windows.Forms.WebBrowser wrapper).

    Now to get this to work with buttons... some pages have onclick javascript that goes off, then expect the normal button's form submit on click to happen afterwards it seems.

    Edit: well, that works with some javascript and even some I make up to .click() something in the DOM, but hangs with other js like described above.
    Last edited by ArmchairAthlete; May 18th, 2007 at 08:38 AM.

  3. #83
    New Member
    Join Date
    Jun 2007
    Posts
    7

    Thumbs up Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control

    Quote Originally Posted by kleinma
    What code did you try?
    I am a newbie to VB.Net, I have spent many hours researching the internet for info in reference to auto logon. This thread is the best thread I have seen yet. But your attitude towards inquiries is out standing. You are constantly offering to write code on behalf of the inquirer. It show that you are a person of great character. I AM AMAZED. I am using 2005 VB Express, unfortunately I am unable to get your webpage manipulation code to work. Has 21 errors when opening. I would love to see it in action. Any recommendations apart from purchasing VS 2005. Thanks in advance...

  4. #84

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

    Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control

    You should NOT need a pay version of Visual Studio to get the code to work. However perhaps if you can list (some) of the errors, I could point you in the right direction to get it fixed.

  5. #85
    New Member
    Join Date
    Jun 2007
    Posts
    7

    Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control

    as requested:
    All I can debug is that my Vb 2005 Express does not know "mshtml"
    Looking fwd to your reply
    Thanks //Gibbo

    Discription Line Column
    Error 1 Type 'mshtml.HTMLDocument' is not defined. 85 22
    Error 2 Type 'mshtml.IHTMLTxtRange' is not defined. 86 24
    Error 3 Type 'mshtml.IHTMLTxtRange' is not defined. 87 61
    Error 4 Type 'mshtml.HTMLDocument' is not defined. 99 44
    Error 5 Type 'mshtml.HTMLDocument' is not defined. 101 44
    Error 6 Type 'mshtml.HTMLFormElement' is not defined. 110 45
    Error 7 Type 'mshtml.HTMLFormElement' is not defined. 113 67
    Error 8 Type 'mshtml.HTMLInputElement' is not defined. 129 54
    Error 9 Type 'mshtml.HTMLInputElement' is not defined. 133 85
    Error 10 Type 'mshtml.HTMLTextAreaElement' is not defined. 138 55
    Error 11 Type 'mshtml.HTMLTextAreaElement' is not defined.142 86
    Error 12 Type 'mshtml.HTMLOptionButtonElement' is not defined 148 67
    Error 13 Type 'mshtml.HTMLOptionButtonElement' is not defined. 150 67
    Error 14 Type 'mshtml.HTMLButtonElement' is not defined. 156 61
    Error 15 Type 'mshtml.HTMLButtonElement' is not defined. 162 62
    Error 16 Type 'mshtml.HTMLAnchorElement' is not defined. 176 28
    Error 17 Type 'mshtml.HTMLDivElement' is not defined. 186 22
    Error 18 Type 'mshtml.HTMLImg' is not defined. 225 28
    Error 19 Type 'mshtml.HTMLImg' is not defined. 229 73
    Error 20 Type 'mshtml.HTMLSelectElement' is not defined. 242 28
    Error 21 Type 'mshtml.HTMLInputElement' is not defined. 250 31
    Warning 22 The referenced component 'Microsoft.mshtml' could not be found.

  6. #86

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

    Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control

    looks like the only problem is you don't have the needed microsoft.mshtml.dll file which is the parsing engine.

    On my PC it is located at
    C:\program files\microsoft.net\primary interop assemblies\Microsoft.mshtml.dll

    Search your PC and see if you have it. If you find it, add a reference to it in the "Add Reference" dialog, and the errors will go away.

    Let me know if you don't have it and I could probably upload it.

  7. #87
    New Member
    Join Date
    Jun 2007
    Posts
    7

    Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control

    You hit the nail on the head. The file is missing, no where to be found on C:drive... you can e-mail to cgibbons@bigpond.com.au....thxs

  8. #88

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

    Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control

    microsoft.mshtml.dll

    Here you go. I will leave it available on that server for a little while until I know you have gotten it.
    Last edited by kleinma; Sep 10th, 2008 at 09:07 AM.

  9. #89
    New Member
    Join Date
    Jun 2007
    Posts
    7

    Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control

    Thxs, I have download the file, file has been copied into the same location as yours. Problem persist. I have attempted to enter path in the "add reference" dialog as you have recommended. But it is not allowing me to enter the value. Any suggestions…sorry for the inconvenience

  10. #90
    New Member
    Join Date
    Jun 2007
    Posts
    7

    Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control

    sorry found the problem thxs. please ignore my last message

  11. #91

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

    Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control

    Glad to hear you got it working.

  12. #92
    New Member
    Join Date
    Jun 2007
    Posts
    7

    Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control

    I need to ask the biggest favour ever. I have been researching the web for the last 14 days for a specific script. It appears that you seem to know what your are talking about, thus you may have the answer I seek. Therefore I need your advice and/or direction.

    Objective
    1. Open a http and/or https website
    2. Wait until the page has completely finish downloading (e.g. done) before keystrokes "username" then "TAB" then "password" then "TAB" then "Click".

    Please note:
    1 The problem is that I move about and thus am connected to varying internet speeds. "Wait" and "sleep" commands are unstable.
    2. Other sessions of browsers are already open. Thus the keystroke must be directed to the specific browser window.
    3. Plus the individual characters in the "username" or "password" are echoing. Which brings me to the next problem but is related. Slow down the keystrokes, such that the next keystroke will not occur until the script receives a reply from server acknowledges the previous keystroke. Again “wait” and “sleep” are unstable.
    4. Please note that use of cookies is not an option as the website that I access issue new cookies every time I log on.

    In summary
    I need to slow the script down between WebPages and keystrokes. The script steps thru as it receives acknowledgements from server

    Thankyou
    //Gibbo

    P.S. your programme is great

  13. #93

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

    Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control

    well are you planning on making a windows forms app in VB.NET that will host a webbrowser control? If so then this sounds easy to do. If you are actually trying to automate an external instance of internet explorer, then that will be more difficult. I know you used to be able to create external instances of IE and automate them, but I think support for that has dropped.

    Anyway, so if you wanted to make a windows app that hosts the browser control (which is what my example code does) then here are a few key points to keep in mind:

    When you navigate to a page, you need to wait for the DocumentCompleted event to fire. This event fires when the page has been fully loaded in the browser. Unlike the navigated event which fires as soon as a navigation has started.

    You don't need to send tabs and keystrokes to the webpage when you use the methods shown in my example code. You simply access the pages DOM (document object model) and fill in the needed fields, and click the needed buttons/links.

    The only one of your points I am not sure of is number 3? What do you mean by echoing? Does the page post back to the server on every keystroke entered? Is that why you need the wait?

  14. #94
    New Member
    Join Date
    Jun 2007
    Posts
    7

    Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control

    I have created a form with buttons to activate individual scripts. Simply I have to log onto many different secure websites at the same time in order to perform different task as part of my employment. Remembering all my usernames and passwords, plus constantly logging on and off website is frustrating. Hence the Form I am creating. Eventually as my experience and knowledge improves. I would like to auto fill the from on these websites from a database, as a lot of my work is repetitive.

    The echoing. The script only has "a" as a keystroke followed by a wait of 500ms before the next keystroke. But the username field may display multiple "a". But this problem does not seem to occur when I am connect to a high speed broadband.

    If you are able to provide a basic code to which I can model from and/or improve it would be much appreciated

    It is now 0200hrs here in Aussie, Thus I must get some shut eye

    Thanks
    //Gibbo

  15. #95
    New Member
    Join Date
    Jun 2007
    Posts
    8

    Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control

    Hi guys. I've read throught this whole thread and I'm hoping you can help me. What I'm trying to do is automate a batch load process we have for our case tracking system. Basicily we have a website internal to our company that we go to and input the filename. You then click submit and it's done.

    So I downloaded the OP's webmanipulate program and got it work well. But when I tried to use the code into my project, it didn't seem to work. It kept getting a repeating error of sorts. So I tried other methods mentioned on this page. The only method I got to somewhat work is:

    Browser.Document.Forms(0).GetElementsByTagName("Input").Item(0).SetAttribute("Value", "test1")

    The result of this is that it puts "test1" is put into a text box, but not the right one. I tried adjusting the Item number but it didn't work. I could only get it to put the text in the top text box (which is a search bar thats a standard part of our company's intranet).

    So here's the html code for the page which I got permission to post with some editions:
    Code:
     
    
    
    <html>
        <head>
            <title>Merckury Batch Load Upload Page</title>
            <script type="text/javascript">			
            var portallastmod='3 Mar 2005'
            var portalcontact='xxxxx@xxxxx.com'
    </script>
    	
            <meta name="Language" content="English language" />
            <meta name="Sensitivity_class" content="Business confidential" />
    	
            <script src="/scripts/wrapperadd.js" type="text/javascript"></script>
            <script src="/scripts/portaldefaults.js" type="text/javascript"></script>
    
            <link href="/merckury/styles/batchload.css" rel="stylesheet" type="text/css">
        </head>
     
        <body>
    
            <!-- This is the include for the header -->
            <script type="text/javascript">portalInsertHeader()</script>
    		<!-- Begin Breadcrumb Strip -->
    		<div class="portalbreadcrumb">
    			<a href="http://my.merck.com/index.jsp?epi-content=myMerckRedirectType&amp;epi-process=home_redirect.jsp">myMerck home</a> &gt; 
    			batch load cases
    		</div>
    		<!-- End Breadcrumb Strip -->
            <div id="pagecontent">
    
                <br/>
                <br/>
    
                <form name="fileUploadForm" method="post" action="/merckury/batchFileUploadRequest" ENCTYPE="multipart/form-data" >
                <table width='600' border='0' cellpadding="1" cellspacing="1" align="center" bgcolor="#666666">
    				<tr>
    					<th>
    						Merckury Batch Load Upload Page    
    					</th>
    				</tr>
                    <tr>
                        <td>
                            <table width="100%" cellpadding="5" cellspacing="0" border="0" bgcolor="white">
                                <tr>
                                    <td>
                                    
                                        <br/>
                                        File Name: <input type="file" name="file1" size="80" />
                                        <br/>
                                        <br/>
                
                                        <div align="center">
    										<input type="submit" name="submitButton" value="Submit"/>
    									</div>
    
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                    
                                        <a href="BatchLoad.xls">Get the batch load spreadsheet</a>
    
                                    </td>
                                </tr>
    						</table>
                        </td>
                    </tr>
                </table>
                </form>
                <table width='600' border='0' cellpadding="1" cellspacing="1" align="center" bgcolor="#666666">
    				<tr>
    					<th>
    						Look up ID Values    
    					</th>
    				</tr>
                    <tr>
                        <td>
                            <table width="100%" cellpadding="5" cellspacing="0" border="0" bgcolor="white">
    							<tr>
    								<td>
    								&nbsp;&nbsp;<a href="/merckury/batchIdLookup?lookuptype=0">Product IDs</a><br>
    								&nbsp;&nbsp;<a href="/merckury/batchIdLookup?lookuptype=1">Category / Specialty Type / Detail IDs</a><br>
    								&nbsp;&nbsp;<a href="/merckury/batchIdLookup?lookuptype=4">Provider Group IDs</a><br>
    								&nbsp;&nbsp;<a href="/merckury/batchIdLookup?lookuptype=5">Attribute IDs</a><br>
    								<br>
    
    								</td>
                                </tr>
    
    						</table>
                        </td>
                    </tr>
                </table>
    
    
    
            </div>
            <script type="text/javascript">portalInsertFooter()</script>
    
        </body>
    </html>
    As I said before I'm justing trying to input the filename (which is standard) and then click submit. My project has a browser in it called "browser" that navigates to the website when the form is loaded"

    Also, for future refrence - is there a way to program a scan function to scan a website and display what the item numbers are? So basiclly after going to a website I would hit a "scan" button and it would look at the website and tell me the text boxes and gives me there form and item number. Would be helpful.

    Any suggestions?

    UPDATE: I've went back and modified the browser to use the testpage that came with OP program to see if it can populate any box after the first using the : Browser.Document.Forms(0).GetElementsByTagName("Input").Item(0).SetAttribute("Value", "test1")
    method and ran into the same problem. Even though I added more lines with higher Item number, it just populated the first box (txtbox in this case). Hope someone can help.
    Last edited by roiegat; Jun 27th, 2007 at 09:02 AM.

  16. #96

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

    Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control

    It is a security limitation of the IE DOM.

    Imagine you went to some webpage, and the webpage had a file upload input element on it, that was prefilled with some sensitive file from your computer, and when the page loads, javascript has the page automatically submit, and some personal file from your computer is uploaded to someones server....

    For that reason, the Document Object Model does not expose the value property of <input type=file> elements. That means you can not set those via code.

  17. #97
    New Member
    Join Date
    Jun 2007
    Posts
    8

    Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control

    Quote Originally Posted by kleinma
    It is a security limitation of the IE DOM.

    Imagine you went to some webpage, and the webpage had a file upload input element on it, that was prefilled with some sensitive file from your computer, and when the page loads, javascript has the page automatically submit, and some personal file from your computer is uploaded to someones server....

    For that reason, the Document Object Model does not expose the value property of <input type=file> elements. That means you can not set those via code.
    Guess I set them wrong...just figured out a way. I wrote this handy little sub:

    Private Sub update_text(ByVal field As String, ByVal input_text As String)
    Browser.Document.All(field).Focus()
    SendKeys.Send(input_text)

    End Sub

    So I just send that I want to update "file1" and the text. It sets the focus on the box and then used sendkeys to type in the file name.

    Thanks for the info!

  18. #98

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

    Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control

    yeah, using sendkeys could work because sendkeys mimics user input. Since javascript doesn't have access to sendkeys, there is no direct browser security risk there.

    Just make sure you do extensive testing with sendkeys, as it sends keystrokes to the active window, so you shoudl always make sure the desired window has focus before calling sendkeys

  19. #99
    New Member
    Join Date
    Jun 2007
    Posts
    8

    Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control

    Quote Originally Posted by kleinma
    yeah, using sendkeys could work because sendkeys mimics user input. Since javascript doesn't have access to sendkeys, there is no direct browser security risk there.

    Just make sure you do extensive testing with sendkeys, as it sends keystrokes to the active window, so you shoudl always make sure the desired window has focus before calling sendkeys
    That correct. I learned this the hard way when I was trying to debug the code and the program would hang on me. So I have to put a breakpoint after the sendkey command.

  20. #100
    New Member
    Join Date
    Jun 2007
    Posts
    6

    Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control

    Hi,
    I am a newbie on VB, using VS2005.
    How do I use InvokeMember if the button does not have a name?

    html - <input id="uploadButton" type="submit" value="Upload Video">

    code - wb.Document.Forms("uploadVideoFileForm").InvokeMember("submit") - nothing happens
    wb.Document.Forms("uploadVideoFileForm").InvokeMember(????)


    what do i do? or is there a basic way to go around with this.
    Thanks in Advance!

  21. #101

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

    Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control

    instead of using the form specifically, try Invoking a click on the submit button using its ID of "uploadButton"

  22. #102
    New Member
    Join Date
    Jun 2007
    Posts
    6

    Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control

    Quote Originally Posted by kleinma
    instead of using the form specifically, try Invoking a click on the submit button using its ID of "uploadButton"
    It worked!
    but you know what somewhere in my tests im sure i did that, ive been working with it for 4 hours and its almost 2am, now, how do I get rid of ghosts inside this program, hmmm... lesser errors to go! weeeeeeee

    anyways BIG BIG thanks again,
    knds

  23. #103

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

    Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control

    no problem

  24. #104
    New Member
    Join Date
    Jun 2007
    Posts
    2

    Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control

    I'm attempting to
    1) click a single checkbox on the loaded page (which should redirect the page in the process)
    2) click a URL on the next page

    Apparrently the checkbox is beyond my scope because I can't seem to get it to work. There are 5 forms on the page, and the check box is in the 4th (index 3?). Also in that form is a hidden value which is specified before the checkbox name. Here is some code I'm working with:

    Code:
    Public Class frmMain
    
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Dim tmpStr As String = "http://localhost/CASE_NUMBER=" & CStr(TextBox1.Text)
            wb.Url = New System.Uri(tmpStr)
        End Sub
    
        Private Function GetCurrentWebDoc() As MSHTML.HTMLDocument
            Try
                Return DirectCast(wb.Document, mshtml.HTMLDocument)
            Catch ex As Exception
                Return Nothing
            End Try
        End Function
    
        Private Function GetCurrentWebForm() As MSHTML.HTMLFormElement
            Try
                If GetCurrentWebDoc.forms.length > 0 Then
                    Return DirectCast(GetCurrentWebDoc.forms.item(3), MSHTML.HTMLFormElement)
                Else
                    Return Nothing
                End If
            Catch ex As Exception
                Return Nothing
            End Try
        End Function
    
        Private Sub ClickCheckBox()
            Dim MyInputElement As MSHTML.HTMLInputElement = DirectCast(GetCurrentWebForm.item("checkBoxName", 3), MSHTML.HTMLInputElement)
            MyInputElement.checked = True
        End Sub
    
        Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
            ClickCheckBox()
        End Sub
    
    End Class
    Unfortunately I can't really post the HTML I'm working with, but I could cut and past relevant portions if I knew what would help.

    Thanks for any suggestions!

  25. #105

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

    Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control

    Is the checkbox actually called "checkBoxName" in the HTML code?

  26. #106
    New Member
    Join Date
    Jun 2007
    Posts
    2

    Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control

    no, but I changed it to protect the innocent... I'll PM you the form code itself.

  27. #107

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

    Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control

    it works fine. I PMed you with the code that works.

  28. #108
    New Member
    Join Date
    Jun 2007
    Posts
    6

    Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control

    Hi, me again,

    Can InvokeMember be used to click a dynamic button? If not is there a way around this for my auto login to work?

    html code:
    <a onclick="signInSubmit( document.signInForm.login.value, document.signInForm.password.value, document.signInForm.rememberLogin.checked, 'signInForm_err', document.signInForm.source.value )" class="dynaBtn" title="Sign In"><span>Sign In</span></a>&nbsp;

    Im Using VB on VS2005

    Thanks,
    knds

  29. #109

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

    Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control

    if you look at my example project you will see an example of calling javascript that is in the HTML page from VB code. You could use that example to call the signInSubmit javascript function from VB code, passing the given values that it expects. That should do it.

  30. #110
    New Member
    Join Date
    Jun 2007
    Posts
    6

    Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control

    Quote Originally Posted by kleinma
    if you look at my example project you will see an example of calling javascript that is in the HTML page from VB code. You could use that example to call the signInSubmit javascript function from VB code, passing the given values that it expects. That should do it.
    I followed the script on your sample application, would there be reasons why my javascript function wont execute? Nothing is happening, I am now trying to click a link with a js function to turn off a flash part on the site so that I could write on the text box

    vb code:
    GetCurrentWebDoc.parentWindow.execScript("switch_non_flash_uploader()", "javascript")

    html code:
    <p> <a> onclick="switch_non_flash_uploader()" href="#"> Click Here </a> if you are having problem with the uploader


    Thanks
    knds

  31. #111

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

    Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control

    I am not sure why it would not execute. It would be hard for me to guess without being able to see the actual page you are trying to manipulate. Is it a public URL so I can look at it?

  32. #112
    New Member
    Join Date
    Jun 2007
    Posts
    6

    Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control

    Quote Originally Posted by knds
    I followed the script on your sample application, would there be reasons why my javascript function wont execute? Nothing is happening, I am now trying to click a link with a js function to turn off a flash part on the site so that I could write on the text box

    vb code:
    GetCurrentWebDoc.parentWindow.execScript("switch_non_flash_uploader()", "javascript")

    html code:
    <p> <a> onclick="switch_non_flash_uploader()" href="#"> Click Here </a> if you are having problem with the uploader


    Thanks
    knds
    Im not sure why my code doesn't fire the jv function but a friend of mine did this:
    wb.Navigate("javascript:switch_non_flash_uploader();")

    it worked... im a newbie on this and I didn't inquired further. well i just wanted to share so others may consider this...

    thanks to kleinma, for your time... on answering my questions...

  33. #113
    New Member
    Join Date
    Jun 2007
    Posts
    6

    Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control

    I searched on this thread re: frames, does anyone had a success filling up values on a frame?

    knds

  34. #114
    Just Married shakti5385's Avatar
    Join Date
    Mar 2006
    Location
    Udaipur,Rajasthan(INDIA)
    Posts
    3,747

    Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control

    Sir guide me
    My Problem I want to open vbforums.com but login using the windows application.

    I just open the your link but how to set the value of user name and the password in that website!!

    I am not getting please guide me

    Thanks!!

  35. #115

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

    Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control

    if you are using my sample code, then you could use the GetCurrentWebDoc to get the current webpage document, and then grab whatever form you want by name or by its index in the collection

    Code:
    Dim MyForm As mshtml.HTMLFormElement = DirectCast(GetCurrentWebDoc.forms.item("form name here"), mshtml.HTMLFormElement)

  36. #116

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

    Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control

    yes in the getcurrentwebform method in my example code, you will see it is specifically grabbing form at index 0. Just change that 0 to whatever number index you want to grab. You could also change the function to allow you to pass in an integer as a parameter, and use that to indicate which form you actually want to retrieve from the webpage document.

  37. #117

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

    Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control

    No problem.

    Check back soon, I will be releasing source for an extended WB control that uses the .NET 2.0 built in webbrowser control instead of the COM based one, but has all the features that the 2 provide.

  38. #118

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

    Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control

    when you run into this type of situation, try to figure out what action you are trying to simulate versus the result you want (sometimes the opposite is true). In this case, you want to simulate clicking on an image. It just so happens that the result is submitting the form.

    Try this code to simulate clicking the image, which in turn should fire any code attached to that image.

    Code:
    DirectCast(GetCurrentWebDoc.images.item("ctl00$Main$postComment$postcommentImageButton"), mshtml.HTMLImg).click()
    if that name value doesn't work, try the ID instead ("ctl00_Main_postComment_postcommentImageButton")


    I do hope you are making some sort of "utility", and not anything that could be used maliciously to spam comments all over myspace.

  39. #119

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

    Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control

    Sorry, I misread it as just an image (as in <img> tag) and not an input element of type image.

    For some reason, I can't seem to access the specific element when its type image via the forms item collection. However this code seems to work:

    Code:
            Dim MyImageElement As mshtml.HTMLInputElement = DirectCast(GetCurrentWebDoc.all.item("ctl00_Main_postComment_postcommentImageButton"), mshtml.HTMLInputElement)
            MyImageElement.click()

  40. #120
    Addicted Member
    Join Date
    Jan 2007
    Posts
    143

    Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control

    It told me "Unable to cast object of type 'System.Windows.Forms.HtmlDocument' to type 'mshtml.HTMLDocument'." for the following line of code

    Code:
    Return DirectCast(WebBrowser1.Document, mshtml.HTMLDocument)
    in the GetCurrentWebDoc function.


    It is causing null errors when I try to set a value. (I took out the exception stuff to figure out where the null value was comming from).

    I think it is because I am trying to use it with a .dll page... but it is written in HTML. Is there a way I can use this same method for a .dll page?

    I'm creating a program that you can enter info into and it will use that info to fill out the eBay Sell an item page, because I like to enter everything in when I'm in the car on my laptop, then when I have an internet connection, I can just plug it in and use it to list the items.
    Last edited by rbxslvr; Jul 15th, 2007 at 09:35 PM.

Page 3 of 14 FirstFirst 12345613 ... LastLast

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