TyBreaker Posted April 20, 2008 Share Posted April 20, 2008 I have the following HTML that my router has for a Javascript button titled Save and Reboot": <div align="left"><INPUT onclick="ReBoot()" type=button value="Save and Reboot" name=Save and Reboot></div> How can I fire this button event in AutoITv3? The doco seems to point to _IEAction as the only mechanism that will work but I haven't been successful so far with the following code: $button = _IEGetObjByName($ie, "Save and Reboot") _IEAction ($button, "click") Any tips appreciated! Link to comment Share on other sites More sharing options...
Vindicator209 Posted April 20, 2008 Share Posted April 20, 2008 (edited) I could be wrong, but I think that can be done be simply: _IENavigate($ie,"java script:ReBoot();") or something along those lines EDIT: javascript, not java script what the heck it wont let me edit it... java script:ReBoot(); wtf, what ever, just no space Edited April 20, 2008 by VindicatorOmega [center]"When you look at old, classic games like Snake, you often put it off because it's such a simple game, but it's only when you actually try and create your own unique game from scratch, do you finally appreciate those games."[/center][center]Don't ask for answers if you haven't TRIED yet![/center][center]Most answers can be answered in the help file! Use it![/center] Link to comment Share on other sites More sharing options...
DaleHohm Posted April 20, 2008 Share Posted April 20, 2008 VindicatorOmega's method may well work, but if the Reboot script relies on the calling object (represented by the variable "this") it may not. Your $button = _IEGetObjByName($ie, "Save and Reboot") doesn't work because "Save and Reboot" is a value, not a name or ID. There are several ways to approach this... each relies on you getting a reference to the specific button. Here are three approaches: $oForm = _IEFormGetObjByName($oIE, form-name) $oButton = _IEFormElementGetCollection($oForm, a-0-based-index) _IEAction($oButton, "click")oÝ÷ Ù«¢+ØÀÌØí½ ÕÑѽ¸ô}%Q9µÑ ½±±Ñ¥½¸ ÀÌØí½%°ÅÕ½Ðí¥¹ÁÕÐÅÕ½Ðì°´ÀµÍµ¥¹à¤)}%Ñ¥½¸ ÀÌØí½ ÕÑѽ¸°ÅÕ½Ðí±¥¬ÅÕ½Ðì¤oÝ÷ Ù«¢+ØÀÌØí½ ÕÑѽ¹Ìô}%Q9µÑ ½±±Ñ¥½¸ ÀÌØí½%°ÅÕ½Ðí¥¹ÁÕÐÅÕ½Ðì¤)½ÈÀÌØí½ ÕÑѽ¸¥¸ÀÌØí½ ÕÑѽ¹Ì(%MÑÉ¥¹ ÀÌØí½ ÕÑѽ¸¹Ù±Õ¤ôÅÕ½ÐíMÙ¹I½½ÐÅÕ½ÐìQ¡¸(}%Ñ¥½¸ ÀÌØí½ ÕÑѽ¸°ÅÕ½Ðí±¥¬ÅÕ½Ðì¤(á¥Ñ1½½À)9áÐ 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 Link to comment Share on other sites More sharing options...
diikee Posted April 21, 2008 Share Posted April 21, 2008 Dale, Isn't this a similar case to what I was experiencing with oclick = _IEGetObjById($oIE, "buttonh") _IEAction($oclick, "click") $oclick.fireEvent("onclick") hope this will lead to a soloution Link to comment Share on other sites More sharing options...
DaleHohm Posted April 21, 2008 Share Posted April 21, 2008 Perhaps, but directly firing the onclick event has the same potenial limitation as the java script: method mentioned above. I already provided 3 choices of solution. 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 Link to comment Share on other sites More sharing options...
TyBreaker Posted April 23, 2008 Author Share Posted April 23, 2008 Perhaps, but directly firing the onclick event has the same potenial limitation as the java script: method mentioned above.I already provided 3 choices of solution.DaleUnfortunately I haven't had any luck with any solution offered so far. But I think I have a more fundamental problem - if we take your third example as a case study since it seems most attractive to me - I've tried a number of different tag names eg img, td etc and I'm never getting anything successfully returned from the IE function. My For loop is never entered as the function always returns 0. I don't understand why because an earlier IECreate function successfully creates the window so it should have the correct $oIE variable.I've since had issues with other IE functions too eg I'm also wrestling with _IEBodyReadText and actually get @ERROR=4 every time I try and call it despite again successfully creating the IE window.Are there any issues with IE7 under Vista SP1 that might be preventing these functions from working properly for me? Link to comment Share on other sites More sharing options...
DaleHohm Posted April 23, 2008 Share Posted April 23, 2008 Are there any issues with IE7 under Vista SP1 that might be preventing these functions from working properly for me?Yes. New security (the UAC) in Vista causes trouble.There are references to this in the new Beta helpfile and a link in my sig.Easiest work around is to place #RequireAdmin at the top of your script if you can.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 Link to comment Share on other sites More sharing options...
TyBreaker Posted April 23, 2008 Author Share Posted April 23, 2008 Yes. New security (the UAC) in Vista causes trouble.There are references to this in the new Beta helpfile and a link in my sig.Easiest work around is to place #RequireAdmin at the top of your script if you can.DaleFinally worked out what was going on. Wasn't UAC in the end - was another security feature whereby IE opens up a new instance of itself depending on whether you are trying to browse the Internet or your local LAN. I discovered this when I tweaked a parameter to IECreate to make it reveal the IE window instead of being hidden. As soon as I did this I could see a new instance of IE being created for the local router URL I was browsing to. Then I found this line in the doco for IECreate:"When opening a local HyperTextApplication (.hta) file, Internet Explorer will open a new browser process for it that will not be accessible through the object variable returned by _IECreate. To control this new browser you must use _IEAttach with the "embedded" option."So this explains why my functions calls were not working - they were being applied to the wrong instance of IE! Link to comment Share on other sites More sharing options...
DaleHohm Posted April 23, 2008 Share Posted April 23, 2008 Finally worked out what was going on. Wasn't UAC in the end - was another security feature whereby IE opens up a new instance of itself depending on whether you are trying to browse the Internet or your local LAN. I discovered this when I tweaked a parameter to IECreate to make it reveal the IE window instead of being hidden. As soon as I did this I could see a new instance of IE being created for the local router URL I was browsing to. Then I found this line in the doco for IECreate:"When opening a local HyperTextApplication (.hta) file, Internet Explorer will open a new browser process for it that will not be accessible through the object variable returned by _IECreate. To control this new browser you must use _IEAttach with the "embedded" option."So this explains why my functions calls were not working - they were being applied to the wrong instance of IE!In fact it is the UAC that causes this behavior. The issue with HTA files prior to Vista now extends to a browserbeing opened in a different security zone. If you look at the helpfile for the _IE* functions in the AutoIt beta you will see this documented. The easiest solution is still to use #RequireAdmin if you can.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 Link to comment Share on other sites More sharing options...
TyBreaker Posted April 26, 2008 Author Share Posted April 26, 2008 Hmmm, still having problems with the IE routines - well to be accurate I've tested the routines against a normal web site and they work fine. The problem is my router is spitting out lots of javascript and the IE routines are not finding any body text at all. How do you deal with that? Link to comment Share on other sites More sharing options...
DaleHohm Posted April 27, 2008 Share Posted April 27, 2008 Look for Frames and iFrames. Strongly suggest you use DebugBar (see my sig). 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 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