Re: I'm lost (as usual)
Re: I'm lost (as usual)
- Subject: Re: I'm lost (as usual)
- From: Nigel Garvey <email@hidden>
- Date: Sun, 13 Nov 2016 10:52:55 +0000
Robert Poland wrote on Fri, 11 Nov 2016 18:03:47 -0700:
>That works. Don't understand why the variable doesn't work for close
window.
Hi Robert.
Two things. Firstly, in the script you posted, you have the variable
name in quotes, so you're effectively trying to close a window named
"UniversalScriptsFldr", not one named "Universal Scripts". Secondly, the
value of the variable is an alias to the folder, so it doesn't identify
the window anyway, even without the quotes.
It's theoretically possible for two or more Finder windows to have the
same name, so it would be better to refer to the folder's 'container
window', so you know you're dealing with the right one:
set UniversalScriptsFldr to (path to library folder as text) & "Scripts:Universal Scripts" as alias
tell application "Finder"
activate
if (container window of UniversalScriptsFldr exists) then
-- If the folder's 'container window' is open, close it.
close container window of UniversalScriptsFldr
else
-- Otherwise open the folder.
open UniversalScriptsFldr
end if
end tell
Actually, 'path to' knows about the Scripts folders, so you could (if
you liked) use …
(path to scripts folder from local domain as text) & "Universal Scripts"
… instead of …
(path to library folder as text) & "Scripts:Universal Scripts"
I don't think it makes any difference though. The default domain for
'path to library folder' is the local domain, whereas that for 'path to
scripts folder' is the user domain. So to get the same folder with 'path
to scripts folder', the local domain has to be specified explicitly.
NG
>"local Domain" is sort of confusing. But I don't know what else too call
>it. I'll take a trip to Google when I get time.
>
>
>> On Nov 11, 2016, at 5:14:PM, Stockly, Ed <email@hidden>
wrote:
>>
>> You can specify which domain for the path to command.
>>
>> set UniversalScriptsFldr to (((path to library folder from system
domain
>> as alias) as text) & "Scripts:") as alias
>>
>> --Classic domain
>> --local domain
>> --network domain
>> --system domain
>> --user domain
>>
>>
>> How about something like this:
>>
>> set UniversalScriptsFldr to ((path to library folder as text from user
>> domain) & "Scripts:Universal Scripts:") as alias
>>
>>
>> tell application "Finder"
>> activate
>> set windowList to name of every window
>> delay # one second
>> choose from list windowList
>> if windowList contains "Universal Scripts:" then
>> tell application "Finder" to close window "Universal Scripts:"
>> else
>> open (folder UniversalScriptsFldr)
>> end if
>> end tell
>>
>> On 11/11/16, 3:50 PM, "Robert Poland" <email@hidden> wrote:
>>
>>> I thought that would get the wrong Library.
>>>
>>> The script below will open the folder, but not close it??? errors.
"can't
>>> get window" ?
>>>
>>> set UniversalScriptsFldr to (path to library folder as text) &
>>> "Scripts:Universal Scripts" as alias
>>>
>>> tell application "Finder"
>>> activate
>>> set windowList to name of Finder windows as text
>>> delay # one second
>>> display dialog windowList & return & UniversalScriptsFldr
>>> if windowList contains "Universal" then
>>> tell application "Finder" to close window "UniversalScriptsFldr"
>>> else
>>> open (folder UniversalScriptsFldr)
>>> end if
>>> end tell
>>>
>>>
>>>> On Nov 11, 2016, at 4:37:PM, Stockly, Ed <email@hidden>
wrote:
>>>>
>>>> This is how I'd do it:
>>>>
>>>> set UniversalScriptsFldr to ((path to library folder as text) &
>>>> "Scripts:Universal Scripts") as alias
>>>>
>>>> On 11/11/16, 3:27 PM,
>>>> "applescript-users-bounces+ed.stockly=email@hidden on
>>>> behalf of Robert Poland"
>>>> <applescript-users-bounces+ed.stockly=email@hidden on
>>>> behalf of email@hidden> wrote:
>>>>
>>>>> Hi,
>>>>>
>>>>> How do I script the following;
>>>>>
>>>>> set UniversalScriptsFldr to ((path to) folder "/Library" as text)
&
>>>>> "Scripts:Universal Scripts" as alias
>>>>>
>>>>> TIA,
>>>>>
>>>>> Robert Poland
>>>>> Fort Collins, CO
>>>
>>> Robert Poland
>>> Fort Collins, CO
>>>
>>
>
>Robert Poland
>Fort Collins, CO
_______________________________________________
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