Re: need explanation for trivial Safari script behavior
Re: need explanation for trivial Safari script behavior
- Subject: Re: need explanation for trivial Safari script behavior
- From: Mitchell L Model <email@hidden>
- Date: Tue, 19 Jul 2016 10:16:47 -0400
On Jul 19, 2016, at 9:49 AM, Christopher Stone < email@hidden> wrote:
On Jul 18, 2016, at 13:43, Mitchell L Model <email@hidden> wrote:Good to know — never occurred to me to look for the document of a browser window. …
set winList to windows where its document is not missing value
I spent many hours working with Safari windows and tabs before discovering this solution.
Glad to hear that! I always feel ridiculous spending many hours on something specific that seems like it should be straightforward. It is particularly demoralizing to find that others know how to solve my problem simply :-). Of course I don't take into account that they too may have spent many frustrating hours reaching that solution.
Interestingly — to me anyway — this does NOT work:
repeat with theWindow in the windows if the document of theWindow is missing value then …
For windows without a document I get the error "No result was returned from some part of this _expression_", with "missing value" selected.
In my opinion this is a bug.
That is good to hear too.
------------------------------------------------------------------------------------------- set noDocList to {}
tell application "Safari" repeat with theWindow in the windows set winDoc to document of theWindow try set docName to name of winDoc on error set end of noDocList to name of theWindow end try end repeat end tell
noDocList -------------------------------------------------------------------------------------------
winDoc can be a null-result and (I think) should produce a missing value instead.
What kind of thing is a null result? I can produce one: produces an error with "class" selected, and in SD if I just evaluate my foo() it shows "No Result" as the result. But it isn't something I can type or compare something else with, is it? Interestingly, the result of
returns class!
Appended is a script I originally wrote back in 2004 or 2005 and rewrote several years ago to use only vanilla AppleScript. (It used to rely on the Satimage.osax.)
Their osaxen certainly made life easier.
I spent a lot of time trying to make it work properly and to make it as fast as possible.
|
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden