The macosxhints Forums

The macosxhints Forums (http://hintsforums.macworld.com/index.php)
-   OS X Developer (http://hintsforums.macworld.com/forumdisplay.php?f=27)
-   -   GUI Scripting question (http://hintsforums.macworld.com/showthread.php?t=110252)

earachefl 03-25-2010 06:04 PM

Quote:

Originally Posted by mark hunte (Post 577024)
Just put,


Code:

do JavaScript "document.F1.wirelessStatus[0].checked=true" in document 1
which worked.

But a copy of the page would help to see whats really going on..

Trying to compile this, I get:
Quote:

Syntax Error: Expected end of line, etc. but found identifier.
Trying to post zip of source file but unsuccessful so far...

earachefl 03-25-2010 06:13 PM

1 Attachment(s)
Quote:

Originally Posted by mark hunte (Post 577024)
Just put,

But a copy of the page would help to see whats really going on..

Here tis...

mark hunte 03-26-2010 02:47 AM

You need to enclose it with the tell block.. :)

Code:

tell application "Safari"
        do JavaScript "document.F1.wirelessStatus[1].checked=true" in document 1
end tell

And this works on the page you sent me.

mark hunte 03-26-2010 03:17 PM

A Toggle for the two button Radio button array.

It checks to see if radio button 0 is checked.
If it is, a 1 will be returned. The result 1 will be used to identify the radio button 1 as the radio button that will get checked.

If it is not checked, then a 0 will be returned, The result 0 will be used to identify the radio button 0 as the radio button that will get checked.
This is a simple toggle to check R. Buttons zero or one.

Code:

tell application "Safari"
        set theBool to (((do JavaScript "document.F1.wirelessStatus[0].checked" in document 1) as boolean) as integer)
        do JavaScript "document.F1.wirelessStatus[" & theBool & "].checked=true" in document 1
end tell


earachefl 03-26-2010 05:43 PM

Solved! Syntax error, of course, on my part... I was placing the last quotation mark at the end of the line instead of before "in document 1". Final code is short and sweet:
Code:

activate application "Safari"
tell application "Safari"
        open location ("http://username:password@192.168.1.1")
        delay 1
        do JavaScript "document.F1.wirelessStatus[1].checked = true" in document 1
        do JavaScript "document.F1.submit()" in document 1
end tell

Script Editor does tell me "missing value", though, for what it's worth.
Now I just have to learn how to force Safari to quit after running this...

hayne 03-26-2010 08:42 PM

tell application Safari
quit
end tell

mark hunte 04-03-2010 10:45 AM

Quote:

Originally Posted by earachefl (Post 577447)
Solved! Syntax error, of course, on my part... I was placing the last quotation mark at the end of the line instead of before "in document 1". Final code is short and sweet:
Code:

activate application "Safari"
tell application "Safari"
        open location ("http://username:password@192.168.1.1")
        delay 1
        do JavaScript "document.F1.wirelessStatus[1].checked = true" in document 1
        do JavaScript "document.F1.submit()" in document 1
end tell

Script Editor does tell me "missing value", though, for what it's worth.
Now I just have to learn how to force Safari to quit after running this...

Glad its working, but are you not forgetting something..

earachefl 04-04-2010 11:38 AM

Quote:

Originally Posted by mark hunte (Post 578166)
Glad its working, but are you not forgetting something..

??? A thank you? Thanks to all!

mark hunte 04-04-2010 11:56 AM

Your welcome, :):)

earachefl 04-04-2010 11:59 AM

Quote:

Originally Posted by mark hunte (Post 578228)
Your welcome, :):)

I feel like I've been scolded :(
sorry for my lack of etiquette - and hey, how'd I get upgraded to a Triple-A player?


All times are GMT -5. The time now is 06:09 AM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.