• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: AppleScript-Users Digest, Vol 3, Issue 654
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: AppleScript-Users Digest, Vol 3, Issue 654


  • Subject: Re: AppleScript-Users Digest, Vol 3, Issue 654
  • From: Andrew Oliver <email@hidden>
  • Date: Fri, 29 Dec 2006 18:46:56 -0800


On Dec 29, 2006, at 2:17 PM, Craig Hoyt wrote:

Hey, thanks Doug and J. Stewart,

I guess I didn't frame my question correctly or I'm getting behavior that is unfamiliar to AS. I'm doing this (Safari misspelled intentionally to show problem):

try
tell application "Saffari"
activate
end tell
end try

This will produce a dialog asking the user to 'Find' the application 'Saffari'. Is this now a Finder issue? Is there any way to suppress this dialog? try doesn't seem to work here. Am I doing this correctly? Is there a more appropriate way to do this such as actually checking for the existence of the application first? The problem reverts to the fact that a human enters the application name - thus I must allow for typos. I just want it to fail silently.

Sorry for the waste of bandwidth on this... I did try to find an answer to this myself, maybe I didn't search using the correct terms.

This has nothing to do with the Finder... it's all AppleScript.

When you compile the Script, AppleScript needs to extract the target application's dictionary in order to find the correct syntax for the commands and understand how to translate your source into raw Apple Events.

Normally this happens silently - AppleScript just finds the application and goes, but if you've typoed the application name it can't do this, so it prompts the user to locate the application in question.

There are several approaches to deal with this. One of them is to validate the application name before trying to run (which you can only do if you have a list of 'known good' applications). The best approach, though, is to avoid having the user type in an application name in the first place - use 'choose application' instead. Of course, this till displays a dialog but at least the user is expecting it.

To show a list of applications:

set theApp to (choose application name with prompt "Please select the application you wish to use:") as text
tell application theApp to activate


Alternatively you can use 'choose file' to have the user navigate to the app they want to use.

Andrew
:)
_______________________________________________
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/mailman//archives/applescript-users

This email sent to email@hidden
References: 
 >Re: AppleScript-Users Digest, Vol 3, Issue 654 (From: Craig Hoyt <email@hidden>)

  • Prev by Date: Re: AppleScript-Users Digest, Vol 3, Issue 654
  • Previous by thread: Re: AppleScript-Users Digest, Vol 3, Issue 654
  • Index(es):
    • Date
    • Thread