Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Action buttons applescript functions

I am trying to make an AppleScript which creates a notification when I receive a specific email.

Rules are set up, and I have a script which launches an app with the following code:

display notification "A newBuild is now available!" with title "New Build"
tell application "Safari"
    activate
    tell window 1
        set current tab to (make new tab with properties URL:"https://latestSuccessful")
    end tell
    tell application "System Events"
        set visible of process "Safari" to true
    end tell
end tell

This launches safari and take to the the web page as soon as the notification is displayed.

Ideally I would display the notification as an Alert, with an action on the 'Show' button which then takes me to the web page. The 'Close button' naturally closes the alert.

Is this possible? Thanks in advance for any pointers.

like image 609
timetobuildit Avatar asked Mar 15 '23 03:03

timetobuildit


1 Answers

Do you mean something like this?

set alertReply to display alert "New Build" message "A new build is now available!" buttons ["Cancel", "Show"] default button 2 giving up after 5
if button returned of alertReply is equal to "Show" then
    tell application "Safari"
        activate
        tell window 1
            set current tab to make new tab with properties {URL:"http://www.google.com"}
        end tell
    end tell
end if
like image 160
turingtested Avatar answered Apr 08 '23 15:04

turingtested