• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 540
  • Last Modified:

IE - simulating ENTER key

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
ranadhir
Asked:
ranadhir
  • 2
  • 2
  • 2
1 Solution
 
Infinity08Commented:
just do your setAttributes, and then call the JavaScript function ... that's the easiest and most straightforward way.
0
 
ranadhirAuthor Commented:
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
 
Infinity08Commented:
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
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
Razor2k5Commented:
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
 
ranadhirAuthor Commented:
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
 
Razor2k5Commented:
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

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

  • 2
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now