cmnetworx Posted June 5, 2010 Share Posted June 5, 2010 I am having some trouble with getting these quotes right, I got it as far as accepting the $script_value, but I cannot figure out how to changeshow_alert to $script_nameHere is my code..$script_name = "show_alert"; $script_value = "value is here"; #include <IE.au3> if Winactive("Window_name") = 0 Then EndIf ;just close if unavailable $v = _IEAttach ("Window_name") $v.document.parentwindow.execscript("show_alert('" & $script_value & "')")I have tried $v.document.parentwindow.execscript($script_name('" & $script_value & "')) and $v.document.parentwindow.execscript('"' & $script_name & '(' & '"' & $script_value & '"' & ')')But the first one throws an error in expression..and the second one says requested action with object failed.I have tried the double quotes, etc and no such luck.I have been messing with this for a few hours now and I am stumped, I know how it would work in php, but not so much in autoit. Link to comment Share on other sites More sharing options...
JohnOne Posted June 5, 2010 Share Posted June 5, 2010 $v.document.parentwindow.execscript('show_alert("' & $script_value & '")') Maybe AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
cmnetworx Posted June 5, 2010 Author Share Posted June 5, 2010 $v.document.parentwindow.execscript('show_alert("' & $script_value & '")')MaybeI can already execute the show_alert with this string$v.document.parentwindow.execscript("show_alert('" & $script_value & "')")I however cannot get it to work when changing show_alert to $script_name a modifiable value Link to comment Share on other sites More sharing options...
MvGulik Posted June 5, 2010 Share Posted June 5, 2010 (edited) whatever Edited February 7, 2011 by MvGulik "Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions.""The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014) "Believing what you know ain't so" ... Knock Knock ... Link to comment Share on other sites More sharing options...
trancexx Posted June 5, 2010 Share Posted June 5, 2010 It should be: .document.parentwindow.execScript($script_name & '("' & $script_value & '")') ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
cmnetworx Posted June 5, 2010 Author Share Posted June 5, 2010 (edited) It should be: .document.parentwindow.execScript($script_name & '("' & $script_value & '")') Thanks trancexx, This is exactly what I couldn't figure out.. Works perfect.. MvGulik, I didn't know that you could change that, I never noticed my code wasn't color coded. As for this piece of code, if Winactive("Window_name") = 0 Then EndIf ;just close if unavailable I just want the script to look for a window, I changed the name to Window_name for simplicity sake, and if it isn't present to simply close the app, otherwise if it is present, it will attach, and execute a javascript within the window.. Its my primate way of finding the internet explorer window that has my scripts on it.. Is that an ok to do that? The end result of what Im trying for in this file is execute.exe show_alert "alert value" Running that command line would find the ie window (predetermined), and execute a javascript:show_alert('alert value'); and it works! Thanks everyone for your help! Edited June 5, 2010 by cmnetworx Link to comment Share on other sites More sharing options...
trancexx Posted June 5, 2010 Share Posted June 5, 2010 show_alert is not built-in javascript function.How can it work without definition?This can work:#include <IE.au3> Global $oError = ObjEvent("AutoIt.Error", "_ErrFunc") Func _ErrFunc() ConsoleWrite("! COM Error ! Number: 0x" & Hex($oError.number, 8) & " ScriptLine: " & $oError.scriptline & " - " & $oError.windescription & @CRLF) Return EndFunc ;==>_ErrFunc $sAlertFunction = "alert" $sText = "Hi there!" _IEErrorNotify(False) $oIE = _IECreate("about:blank", 0, 0) $oIE.document.parentwindow.execScript($sAlertFunction & '("' & $sText & '")') _IEQuit($oIE) ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
cmnetworx Posted June 5, 2010 Author Share Posted June 5, 2010 show_alert is not built-in javascript function.How can it work without definition?show_alert is defined in the ie page that is loaded, Otherwise yeah, it wouldn't do anything but throw a javascript error.., but someone could use alert if they wanted to testFirst the ie page loads, and loads its javascripts, etc. and names the window (so it can easily be found)then later the command line will send something like execute.exe script_name "script value"whereas both of those are variables depending on what I need it to do.. Really its just to pass information back into IE, i can already pass the info out with a frame and some vbscript, but returning info back to the window was where I was running into trouble..I have it working now thoughThanks for your help Link to comment Share on other sites More sharing options...
trancexx Posted June 5, 2010 Share Posted June 5, 2010 Yes, I see. That makes sense. ♡♡♡ . eMyvnE 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