Sign in to follow this  
Followers 0
PeterPE

_IEAction($element, "focus") does not work in IE9

13 posts in this topic

#1 ·  Posted (edited)

I have some issues with setting the cursor in an input field with ie.au3. I tried everything and nothing worked.

Here is an example that fails in IE9:

#include <IE.au3>

; Create a browser window and navigate to hotmail
$oIE = _IECreate("http://mail.yahoo.com")

; get pointers to the login form and username, password and signin fields
Local $o_form = _IEFormGetObjByName($oIE, "login_form")
Local $o_login = _IEFormElementGetObjByName($o_form, "login")
Local $o_password = _IEFormElementGetObjByName($o_form, "passwd")

Local $username = "your username here"
Local $password = "your password here"

; Set field values and submit the form
_IEFormElementSetValue($o_login, $username)
_IEFormElementSetValue($o_password, $password)
_IEAction($o_password, "focus")

The above code works in IE8, but not in IE9. There is no error message either.

So it looks like this is an IE9 bug? Or did the API change in IE9? I couldn't anything about this, though?

Any ideas?

Edited by PeterPE

Share this post


Link to post
Share on other sites



Thanks for your quick response.

Yes, I did - as mentioned above in my post. And it works in IE8 (or IE9 in compatibility mode which emulates IE7/IE8).

My question is how to make it work in IE9. This should be possible, unfortunately I couldn't figure it out (and I usually I am always able to figure it out :-)

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

I edited my OP to include an executable example to make it easier to reproduce this problem.

Edited by PeterPE

Share this post


Link to post
Share on other sites

There is even an easier example in the help file :-)

#include <IE.au3>

$oIE = _IE_Example("form")

$oForm = _IEFormGetObjByName($oIE, "ExampleForm")

Local $oInputFile = _IEFormElementGetObjByName($oForm, "fileExample")

; Assign input focus to the field and then send the text string

_IEAction($oInputFile, "focus")

Send("C:\myfile.txt")

Unfortunately the code fails in IE9 (but not IE8).

Share this post


Link to post
Share on other sites

I would guess that this is the same problem as has been uncovered with .click

trancexx appears to be on the path to fixing this, so I would expect it in a future beta.

Dale


Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Share this post


Link to post
Share on other sites

Yes, indeed same problem. Would you happen to have a link or so :-)

Share this post


Link to post
Share on other sites

Dale, found the link (didn't find anything with the keyword focus, but with click many :-) I guess we have to wait now for a fix

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

Thanks (good job!)

This is not really a workaround for me, the site doesn't work well with IE8 (no box shadow, or rounded corners, some other css3 doesn't work and so on).

Hope the AutoIt devs will be able to fix/adapt the Com Interface soon (the click and focus methods work with everything else. VB and Javascript for example).

Edited by PeterPE

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

In my case, the 'focus' doesn't work even in IE8 compatibility mode for a control (input file), instead the focus is set to the address bar. I'm using the "Focus" and "Send {Space}" trick to open a dialog box.

Edited by Seldon

Share this post


Link to post
Share on other sites

A little update... the control seems to get the focus (it changes its color) , but the "Send {Space}" command is sent to the address bar of IE (actually the address bar is cleaned like if I select it and press the space bar).

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

Did you ever find a full work around on this?

I'm running on a work computer using IE7 (yeah we are a bit behind...) and the focus nor click seems to work.

Thoughts?

edit: correction - it works if it's in a stand alone short script, but doesn't seem to work in my main program.

The only difference between the two is the main program is passing variables to the input box then focusing on submit and hitting space.

In the stand alone script - it's just a static value of '42', then focus, then space, etc.

Again - the stand alone works perfectly fine 100% of the time.

The main program does not.

Edited by xeroTechnologiesLLC

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0