Jump to content
Sign in to follow this  
cmnetworx

Can't get the quotes right

Recommended Posts

cmnetworx

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 change

show_alert to $script_name

Here 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.

Share this post


Link to post
Share on other sites
cmnetworx

$v.document.parentwindow.execscript('show_alert("' & $script_value & '")')

Maybe

I 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

Share this post


Link to post
Share on other sites
MvGulik
whatever Edited 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 ...
 

Share this post


Link to post
Share on other sites
trancexx

It should be:

.document.parentwindow.execScript($script_name & '("' & $script_value & '")')

♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites
cmnetworx

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 by cmnetworx

Share this post


Link to post
Share on other sites
trancexx

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

Share this post


Link to post
Share on other sites
cmnetworx

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 test

First 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 though

Thanks for your help

Share this post


Link to post
Share on other sites
trancexx

Yes, I see.

That makes sense.


♡♡♡

.

eMyvnE

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  

×