Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

IE - simulating ENTER key

Posted on 2006-07-19
7
512 Views
Last Modified: 2008-03-06
Is there any way to simulate the press of 'ENTER' key on IE.We have a password field,which invokes a javascript function to log the user in,on press of ENTER.
We need to reproduce this action automatically - ie after filling the userid and password,we need to invoke the ENTER key.
We fill up the userid/password fields by  elem->setAttribute(..,..,0),where pelem is the IHTMLElement interface.
But we are not able to simulate the press of ENTER.
Any help will be appreciated.
thanks.
0
Comment
Question by:ranadhir
  • 2
  • 2
  • 2
7 Comments
 
LVL 53

Expert Comment

by:Infinity08
ID: 17136520
just do your setAttributes, and then call the JavaScript function ... that's the easiest and most straightforward way.
0
 

Author Comment

by:ranadhir
ID: 17136814
The problem being that the web-site and hence javascript function and is a third-party application.Hence we are not guaranateed consistency in future versions.
The safest approach si to actually simulate pressing the ENTER key after entering values in teh text
0
 
LVL 53

Expert Comment

by:Infinity08
ID: 17137132
Isn't there a function to simulate clicking the submit button then (or just simply to call the action associated with the form if there's no submit button) ? Something like form.submit() ? What library are you using to manipulate the form fields ?
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
LVL 2

Expert Comment

by:Razor2k5
ID: 17144130
Hi,

you could get the handler of the IE window and play with it.

WindowHandle = FindWindow(NULL,"IE name"); //play a bit with spy++ and you'll see what I'm talking about

then

SendMessage(WindowHandle, WM_KEYDOWN,  VK_RETURN ,   NULL); //this will send the message to the window as you virtual press ENTER key
0
 

Author Comment

by:ranadhir
ID: 17151554
That would handle a click on the IE window;But in our case we need to press the ENTER key on a particular field on that window.
0
 
LVL 2

Accepted Solution

by:
Razor2k5 earned 125 total points
ID: 17152074
If you need to press a key on a particular field do like this:

- get the hWnd of that field (anything in Windows is based on windows, so each field is a window with a different implementation - class extension with different properties) with FindWindowLike or other functions.

- then you can play with each window as you wish.

as an example take a look here: http://support.microsoft.com/kb/147659/
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question