Press Enter key in text box in webpage

chidambaram

Well-known member
Joined
Dec 27, 2007
Messages
62
Location
Chennai,India
Programming Experience
Beginner
Hi,


I want to enter the text in text box in the web page and press that text box to open the next page. In that web page, to open the next page they written the code in key press event. so how can i press a enter key through code in that text box.

Thanks in advance.
 
Are you sure that is the Enter key detected and not default webform submit? Try:
VB.NET:
wb.Document.Forms(0).InvokeMember("submit")
or send the enter key:
VB.NET:
wb.Select()
Application.DoEvents()
SendKeys.Send("{ENTER}")
 
Sir,

Can u explain briefly?

How can i send the Enter key to the text box?

I used this as

element7.value = "Jerzy"
element7.select()
Application.DoEvents()
SendKeys.Send("{ENTER}")
element7 is a form element.

The program is hanged.

so explain briefly.

Thanks and urgent plz....
 
I notice you haven't used wb.Select() where wb is the webbrowser control. When I tested out SendKeys/WB this code was required for it to work. Remember when you click a Button control outside the browser you are activating a different control, unless your code re-activate the browser control SendKeys will be sending the wrong place.
 
Sir,

I used Internet Explorer object instead of web browser control to view the web page. There is no select funtion in Internet Explorer object.

Is it possible to send the Enter key using Internet Explorer object?
 
Controlling other running applications remotely is quite a different story. There is AppActivate("title or processID"), SendKeys will also work because it just sends to active element of active window. My latest experience in IE remote automation failed, I think they have shut this possibility of security reasons (search ShellWindows InternetExplorer). You might be able to create a BHO COM object to do it too.
 
Sir,


I converted my program by using the web browser control.

But still i cant able to get the correct answer.

This is my code

If (HTMLDoc.forms.length > 0) Then
collection1 = HTMLDoc.getElementsByTagName("input")
element1 = collection1.item(0)
element1.value = "deepthi"
Me.AxWebBrowser1.Select()
Application.DoEvents()
SendKeys.Send("{ENTER}")
End If

Here

HTMLDoc is a mshtml.HTMLDocument,
collection1 is mshtml.IHTMLElementCollection,
element1 is mshtml.IHTMLElement

Let me know what mistake i did here.

Thanks in advanz.....
 
Since this is a Html Forms object you should submit the form, refer post 2. This also means you don't need to transfer input to the webcontrol and send keys.
Since you have changed your forum profile to .Net 1.1 the answers for .Net 2.0 isn't compatible. I could look up compatible ActiveX Webbrowser code later if you don't find it on the web first.
 
Back
Top