Solved

IE - simulating ENTER key

Posted on 2006-07-19
7
486 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
Comment Utility
just do your setAttributes, and then call the JavaScript function ... that's the easiest and most straightforward way.
0
 

Author Comment

by:ranadhir
Comment Utility
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
Comment Utility
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 2

Expert Comment

by:Razor2k5
Comment Utility
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
Comment Utility
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
Comment Utility
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…

743 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

15 Experts available now in Live!

Get 1:1 Help Now