mpower Posted August 7, 2013 Share Posted August 7, 2013 (edited) Hi, I'm filling out a form in a hidden IE window which has an onblur="" event for input fields. It works perfectly fine in a non-hidden IE window, however the event fails to fire in a hidden IE window. I've tried the following: _IEAction($field, "focus") _IEAction($field, "blur") But neither of these trigger the event. Can someone please assist? Cheers Edited August 7, 2013 by mpower Link to comment Share on other sites More sharing options...
DaleHohm Posted August 7, 2013 Share Posted August 7, 2013 (edited) Can't think of a reason this would be true for the DOM, but an app can certainly check for attributes of the window so that it can try to prevent you from doing it (like trying to prevent you from automating a game). I'd suggest you create a test htm file that performs a JavaScript alert onblur and test with it to see If the issue is unique to the page you are trying to automate now. Dale Edited August 7, 2013 by DaleHohm 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 Link to comment Share on other sites More sharing options...
mpower Posted August 7, 2013 Author Share Posted August 7, 2013 (edited) Can't think of a reason this would be true for the DOM, but an app can certainly check for attributes of the window so that it can try to prevent you from doing it (like trying to prevent you from automating a game). I'd suggest you create a test htm file that performs a JavaScript alert onblur and test with it to see If the issue is unique to the page you are trying to automate now. Dale Hi Dale, Thanks for your response. I've attached an example HTML file with an "onblur" event which changes input text to CAPS. Below is an example reproducer script which tests 3 different ways of achieving the result in Visible mode and the same methods in Hidden mode: expandcollapse popup#include <IE.au3> ;Visible METHOD 1: Using _IEAction to focus on input, enter "test" using _IEFormElementSetValue and then _IEAction blur to simulate loss of focus to trigger the "onblur" event $oIE = _IECreate(@ScriptDir & "/example.html") $oIE_Form = _IEGetObjByName($oIE, "form") $oIE_Input = _IEFormElementGetObjByName($oIE_Form, "fname") _IEAction($oIE_Input, "focus") _IEFormElementSetValue($oIE_Input, "test") _IEAction($oIE_Input, "blur") ConsoleWrite("Visible mode result 1: "&_IEFormElementGetValue($oIE_Input)&@CRLF) _IEQuit($oIE) Sleep(500) ;Visible METHOD 2: Using _IEAction to focus on input, enter "test" using ControlSend and then _IEAction blur to simulate loss of focus to trigger the "onblur" event $oIE = _IECreate(@ScriptDir & "/example.html") $oIE_Form = _IEGetObjByName($oIE, "form") $oIE_Input = _IEFormElementGetObjByName($oIE_Form, "fname") _IEAction($oIE_Input, "focus") $hIE = _IEPropertyGet($oIE, "hwnd") ControlSend($hIE, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "test") _IEAction($oIE_Input, "blur") ConsoleWrite("Visible mode result 2: "&_IEFormElementGetValue($oIE_Input)&@CRLF) _IEQuit($oIE) Sleep(500) ;Visible METHOD 3: Using _IEAction to focus on input, enter "test" using _IEFormElementSetValue and then ControlSend {TAB} to simulate loss of focus to trigger the "onblur" event $oIE = _IECreate(@ScriptDir & "/example.html") $oIE_Form = _IEGetObjByName($oIE, "form") $oIE_Input = _IEFormElementGetObjByName($oIE_Form, "fname") _IEAction($oIE_Input, "focus") _IEFormElementSetValue($oIE_Input, "test") $hIE = _IEPropertyGet($oIE, "hwnd") ControlSend($hIE, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "{TAB}") ConsoleWrite("Visible mode result 3: "&_IEFormElementGetValue($oIE_Input)&@CRLF) _IEQuit($oIE) Sleep(500) ;Hidden METHOD 1: Using _IEAction to focus on input, enter "test" using _IEFormElementSetValue and then _IEAction blur to simulate loss of focus to trigger the "onblur" event $oIE = _IECreate(@ScriptDir & "/example.html", 0, 0, 1, 0) $oIE_Form = _IEGetObjByName($oIE, "form") $oIE_Input = _IEFormElementGetObjByName($oIE_Form, "fname") _IEAction($oIE_Input, "focus") _IEFormElementSetValue($oIE_Input, "test") _IEAction($oIE_Input, "blur") ConsoleWrite("Hidden mode result 1: "&_IEFormElementGetValue($oIE_Input)&@CRLF) _IEQuit($oIE) Sleep(500) ;Hidden METHOD 2: Using _IEAction to focus on input, enter "test" using ControlSend and then _IEAction blur to simulate loss of focus to trigger the "onblur" event $oIE = _IECreate(@ScriptDir & "/example.html", 0, 0, 1, 0) $oIE_Form = _IEGetObjByName($oIE, "form") $oIE_Input = _IEFormElementGetObjByName($oIE_Form, "fname") _IEAction($oIE_Input, "focus") $hIE = _IEPropertyGet($oIE, "hwnd") ControlSend($hIE, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "test") _IEAction($oIE_Input, "blur") ConsoleWrite("Hidden mode result 2: "&_IEFormElementGetValue($oIE_Input)&@CRLF) _IEQuit($oIE) Sleep(500) ;Hidden METHOD 3: Using _IEAction to focus on input, enter "test" using _IEFormElementSetValue and then ControlSend {TAB} to simulate loss of focus to trigger the "onblur" event $oIE = _IECreate(@ScriptDir & "/example.html", 0, 0, 1, 0) $oIE_Form = _IEGetObjByName($oIE, "form") $oIE_Input = _IEFormElementGetObjByName($oIE_Form, "fname") _IEAction($oIE_Input, "focus") _IEFormElementSetValue($oIE_Input, "test") $hIE = _IEPropertyGet($oIE, "hwnd") ControlSend($hIE, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "{TAB}") ConsoleWrite("Hidden mode result 3: "&_IEFormElementGetValue($oIE_Input)&@CRLF) _IEQuit($oIE) Results look like this in the Console: Visible mode result 1: TEST Visible mode result 2: TEST Visible mode result 3: TEST Hidden mode result 1: test Hidden mode result 2: test Hidden mode result 3: test NOTE: You may need to adjust Internet Explorer settings to allow ActiveX content in local files for JavaScript to work correctly: Source of attachment (in case you are not comfortable downloading the file): <!DOCTYPE html> <html> <head> <script> function myFunction() { var x=document.getElementById("fname"); x.value=x.value.toUpperCase(); } </script> </head> <body> <form name="form"> Enter text: <input type="text" id="fname" onblur="myFunction()"> </form> <p>When you leave the input field, a function is triggered which transforms the input text to upper case.</p> </body> </html> example.html Edited August 7, 2013 by mpower Link to comment Share on other sites More sharing options...
DaleHohm Posted August 7, 2013 Share Posted August 7, 2013 Wow. Someone who actually understands what a reproducer is. How refreshing to be able to focus on solving a problem instead of repeatedly dragging people through the troubleshooting process. Unfortunately, in this case, it just results n me telling you that I have never seen this before and I am surprised at the results that you obtained. What I have done when faced with surprising results like this is 1) rewrite your AutoIt reproducer in VBscript and insure that the behavior is the same and 2) take your VBscript reproducer to the appropriate Microsoft Community forum and ask about it there where the population of DOM experts and Microsoft DOM developers is much higher and 3) come back here and report the results of that investigation. Dale mpower 1 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 Link to comment Share on other sites More sharing options...
mpower Posted August 7, 2013 Author Share Posted August 7, 2013 Thanks Dale, I'll see if I can come up with a VBScript and post it on the Microsoft forums. Will report back if it get's resolved (or doesn't). Link to comment Share on other sites More sharing options...
Bert Posted August 7, 2013 Share Posted August 7, 2013 is a possible workaround (If Dale can't get a solution) is to use greasemonkey for IE and tweak the web page so it will display as you need it first (when it loads) and then send what you need to the web page with AutoIt? The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
mpower Posted August 7, 2013 Author Share Posted August 7, 2013 is a possible workaround (If Dale can't get a solution) is to use greasemonkey for IE and tweak the web page so it will display as you need it first (when it loads) and then send what you need to the web page with AutoIt? Hi YogiBear, whilst that may work for some simple events, in my case the onblur event actually triggers complex calculations based on input values so it may not be a viable solution. I do see however how it could work in some cases. Of course you would need to assume that a user is able to install greasemonkey which may need Administrative rights? Just my 2c. Cheers Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now