Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

My applescript code won't work

This code will run and it is a shortcut. Obviously I customized three buttons and then gave a conditional statement for each response but while button 1 and 2 work button 3 runs but Safari will not open a new page. What did I do wrong?

set goodForum to "http://hints.macworld.com/article.php?story=20030409015020645"

set googleUrl to "https://www.google.com"

try

display dialog "Go to forum to study hidden files?" with title "SAUCE" buttons {"Go", "Don't go", "Go to google"}

if button returned of result is "Go" then

tell application "Safari" to makenewdocumentwith properties {URL:goodForum}

end if

if button returned of result is "Don't go to this page" then

"Cancel"

end if

if button returned of result is "Go to google" then

tell application "Safari" to makenewdocumentwith properties {URL:googleUrl}

end if

end try

Thanks in advance

MacBook Air

Posted on May 30, 2015 6:50 PM

Reply
Question marked as Best reply

Posted on May 30, 2015 6:57 PM

Try using:


set goodForum to "http://hints.macworld.com/article.php?story=20030409015020645"

set googleUrl to "https://www.google.com"

try

display dialog "Go to forum to study hidden files?" with title "SAUCE" buttons {"Go", "Don't go", "Go to google"}

set the_button to button returned of result

if the_button is "Go" then

tell application "Safari" to make new document with properties {URL:goodForum}

end if

if the_button is "Don't go" then

"Cancel"

end if

if the_button is "Go to google" then

tell application "Safari" to make new document with properties {URL:googleUrl}

end if

end try


(128097)

1 reply
Question marked as Best reply

May 30, 2015 6:57 PM in response to chevydogincode

Try using:


set goodForum to "http://hints.macworld.com/article.php?story=20030409015020645"

set googleUrl to "https://www.google.com"

try

display dialog "Go to forum to study hidden files?" with title "SAUCE" buttons {"Go", "Don't go", "Go to google"}

set the_button to button returned of result

if the_button is "Go" then

tell application "Safari" to make new document with properties {URL:goodForum}

end if

if the_button is "Don't go" then

"Cancel"

end if

if the_button is "Go to google" then

tell application "Safari" to make new document with properties {URL:googleUrl}

end if

end try


(128097)

My applescript code won't work

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.