gsb Posted March 19, 2007 Share Posted March 19, 2007 AutoIt, IE and Javascript Can an AutoIt function "call" a JS function on a IE page? There is not much that I can find on "interfacing" AutoIt with the javascript in an IE browser page. Seems I can add some code etc., but I would like to "interface" with it. That is, when a js-function is called have that call redirected to an AutoIt function perhaps via an event loop or such. As well as simply "call" a javascript function with some arguments. Are these interactions possible? And if so, could someone point me in the correct direction, please. Thanks, gsb "Did you ever stop to think? ...and forget to restart!" Link to comment Share on other sites More sharing options...
DaleHohm Posted March 19, 2007 Share Posted March 19, 2007 See here: Invoke Javascript Of A Loaded Html PageDale 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...
gsb Posted March 19, 2007 Author Share Posted March 19, 2007 Thank you very much Dale. I must have missed that and I am sure others, for I read so many my eyes crossed. LOL That is a great help, but what about the second part of such a communication. Is it possible that a javascript function or some js-event could call/invoke an AutoIt function? I hope this too is possible. Thanks again. gsb "Did you ever stop to think? ...and forget to restart!" Link to comment Share on other sites More sharing options...
DaleHohm Posted March 19, 2007 Share Posted March 19, 2007 That is a great help, but what about the second part of such a communication.Is it possible that a javascript function or some js-event could call/invoke an AutoIt function?Not directly, but you can trigger an event within the browser that you are monitorng in AutoIt and then take desired action. For example, create a <DIV> element in the HTML and induce a change to it in your Javascript... monitor for an onchange event for that DIV in AutoIt and execute appropriate code. You could even experiment with putting the DIV in an invisible iFrame and write data to it that you could read back in AutoIt for a crude data/parameter passing mechanism.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...
gsb Posted March 20, 2007 Author Share Posted March 20, 2007 (edited) Thank you again Dale, but this time you surpass my Goggle'n attempts as well. LOLThis could work for the low volume I would expect but I am unsure as to the way in AutoIt to monitor the DIV's onchange event.I guess I could get the contents of this DIV and compare it to the last such inquiry, but it would seem a "true" event loop would be far more efficient, if still a kludge.Perhaps you could example the code to capture an onchange for a DIV from within AutoIt for I am a bit lost and unable to find such documented elsewhere as yet.EDIT: Perhaps using ObjEvent? ...but I am unfamiliar with using it.Thank you again Dale for your time and help.gsb Edited March 20, 2007 by gsb "Did you ever stop to think? ...and forget to restart!" Link to comment Share on other sites More sharing options...
DaleHohm Posted March 20, 2007 Share Posted March 20, 2007 This is only in my head at this point-I'll work on an example, but it will take me a while. 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...
gsb Posted March 20, 2007 Author Share Posted March 20, 2007 Thank you Dale. "This is only in my head at this point..." is far better than my not quite getting my arms around it yet. An example would be great when you have time. Thank you. gsb "Did you ever stop to think? ...and forget to restart!" Link to comment Share on other sites More sharing options...
lod3n Posted March 21, 2007 Share Posted March 21, 2007 @gsbIs it possible that a javascript function or some js-event could call/invoke an AutoIt function?I've recently put together a script that could do exactly that. You'd just have to the parameters around to suit your needs, and invoke your desired function through the supplied event handler via the Call function. Or something like that.http://www.autoitscript.com/forum/index.php?showtopic=43013 [font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font] Link to comment Share on other sites More sharing options...
gseller Posted March 21, 2007 Share Posted March 21, 2007 Can autoit work directly with javascript instead of opening or creating an html file? I am thinking not. Everything I am reading is showing the creation of a file each time. Link to comment Share on other sites More sharing options...
gsb Posted March 21, 2007 Author Share Posted March 21, 2007 Thanks again lod3n. What I'd really like to do is capture the flash fsCommands events from an HTML page embedded movie instead of using the javascript, ...but. For now I am still using the flash player's communication to a second flashy embedded directly in a control where I can then capture the fsCommand events. Hey, ...but it works. But if there is a better way... gsb "Did you ever stop to think? ...and forget to restart!" Link to comment Share on other sites More sharing options...
lod3n Posted March 21, 2007 Share Posted March 21, 2007 @gesller, try this: $oIE.document.parentwindow.eval("alert('test')") And this is an example of DaleHohm's:$oSC = ObjCreate("ScriptControl") $oSC.language = "Javascript" $s1 = "; / ? : @ & = + $ , #" $s2 = $oSC.eval("encodeURI('" & $s1 & "');") $s3 = $oSC.eval("decodeURI('" & $s2 & "');") ConsoleWrite( _ "Original: " & $s1 & @CR & _ "Encoded: " & $s2 & @CR & _ "Decoded: " & $s3 & @CR ) [font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font] 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