Re: Where is application dialog
Re: Where is application dialog
- Subject: Re: Where is application dialog
- From: Paul Berkowitz <email@hidden>
- Date: Sun, 16 Nov 2008 13:53:54 -0800
- Thread-topic: Where is application dialog
Title: Re: Where is application dialog
Try
tell application "Finder" to get application file id "com.apple.AppleScriptUtility"
or exists instead of get for true/false instead of an error, which might be better.
--
Paul Berkowitz
From: Luther Fuller <email@hidden>
Date: Sun, 16 Nov 2008 14:30:37 -0600
To: AppleScript-Users <email@hidden>
Subject: Where is application dialog
I have a script, written primarily for Leopard, that contains the following code for backward compatibility with Tiger 10.4.11 ...
if sysIsTiger then
try
run script "tell application \"AppleScript Utility\" to activate"
on error
error "The Script menu is not available because the application AppleScriptUtility cannot be found."
end try
activate me
"The \"Show Script menu in menu bar\" box" & return & "must be checked in AppleScript Utility." & return ¬
& "Check it now, if necessary," & return & "then close AppleScript Utility."
tell me to display dialog the result with title shortTitle buttons {"OK"} default button 1
end if
Leopard's AppleScript Utility is scriptable, but Tiger's is not, so my script has to activate it, then instruct the user. If AppleScript Utility is installed somewhere (and it probably is), the script works perfectly.
But, what if AppleScript Utility is not available? 'run script ...' should simply return an error ... but it doesn't !!!! Instead it asks the user to choose any application to be used instead of AppleScript Utility. If the user chooses, for example, "Calculator", then on EVERY subsequent run of this script, Calculator is activated and the user is instructed ...
The "Show Script menu in menu bar" box
must be checked in AppleScript Utility.
Check it now, if necessary,
then close AppleScript Utility.
An AppleScripter will see what is happening, and choose "Cancel" every time.
But my user's (and yours) have probably never heard of AppleScript and will simply be very confused. They will invariably, at some point, choose any old application from the list.
The "Where is ... ?" dialog opens the inner workings of an AppleScript-ed application to permanent damage. In BOTH Tiger and Leopard. It's just that in Leopard, I can avoid the dialog by using 'application id'.
THE "Where is ... ?" DIALOG MUST BE AVOIDED. BETTER YET, IT SHOULD NOT EVEN BE PRESENT IN THE NEXT VERSION OF APPLESCRIPT. IT'S DANGEROUS.
But, how can I avoid the "Where is ... ?" dialog in Tiger? I don't think I can.
(But, perhaps someone knows more about this?)
I will probably have to simply present the dialog ...
If the Script menu is not visible in the menu bar,
launch AppleScript Utility, in the AppleScript folder
in the Applications folder, then check the box
"Show Script menu in menu bar".
Some will read and comply, others will just not get it.
If you want to experiment with this in Leopard, use this ...
try
run script "tell application \"AppleScript Utility\" to activate"
-- replace "AppleScript Utility" with "anynonsense" to test non-existence
-- DO NOT, DO NOT, DO NOT remove the AppleScript Utility application
on error errText number errNr
activate me
tell me to display dialog "Application does not exist." buttons {"OK"} default button 1
return
end try
activate me
tell me to display dialog "Go!"
And READ THE WARNING. I first tried removing AppleScript Utility just to see what would happen. And what happens is that ALL YOUR EDITABLE SCRIPT DOCUMENTS BECOME UN-EDITABLE until AppleScript Utility is restored.
_______________________________________________
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
_______________________________________________
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