[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

IE - simulating ENTER key

Posted on 2006-07-19
7
Medium Priority
?
535 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
[X]
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
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 375 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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
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 technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
Suggested Courses

650 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