Solved

IE - simulating ENTER key

Posted on 2006-07-19
7
496 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
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.

910 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now