Ok, I’ve got a guy who can’t remember what program to run to do certain tasks. So i want to create a script for him that asks him what he wants to do. All I’ve got so far is the basic steps for the code:
display dialogue “What would you like to do?”
Give the user 3 buttons to choose from
If button1 is clicked, tell application1 activate
If button2 is clicked, tell application2 activate
If button3 is clicked, tell application3 activate
Model: 2008 Macbook Pro 2.6 GHz
Browser: Internet Explorer 6.0
Operating System: Mac OS X (10.5)
Wow, that is a lot simpler than what I was trying to make it. While playing with script after I posted, I found this would work (because he doesn’t remember the names of the programs and what they do):
display dialog "What is the task?" buttons ["Music", "Pictures", "Mail"]
if button returned of result is "Music" then
tell application "iTunes" to activate
end tell
else if button returned of result is "Pictures" then
tell application "iPhoto" to activate
end tell
else
tell application "Mail" to activate
end tell
end if
Are the “tell application…” lines correct? Do the app names need to quotes?
you must remove the end tell lines.
With keywords like activate, quit, launch the application can be used as a direct argument e.g.
activate application "iPhoto"
A better syntax of your script is
set b to button returned of (display dialog "What is the task?" buttons {"Music", "Pictures", "Mail"})
if b is "Music" then
activate application "iTunes"
else if b is "Pictures" then
activate application "iPhoto"
else
activate application "Mail"
end if