Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Barden95

macrumors newbie
Original poster
Oct 25, 2018
3
0
Hi All,

I'm trying to make an app that will display a prompt upon shutdown asking if the user has logged their hours via our online system 'timely'. The idea is that the reminder appears 'Have you logged your timely hours?' with the options 'yes' or 'no'. 'Yes' allowing the machine to shut down and 'No' opening Google Chrome on the Timely website.

So far using the following script the alert is popping up, but when I select 'No' the machine is still shutting down. Can anyone help?

say "Aye up! I'll be reminding you to log your hours on timely when you shut down. "

on quit


set the alert_message to "Have you logged your hours on Timely?"

display dialog the alert_message buttons {"Yes", "No"} default button 1

set the my_choice to the button returned of the result

if my_choice is "Yes" then

tell application "Finder"

shut down

end tell

else

tell application "Google Chrome"

open location "app.timelyapp.com"

end tell

end if

continue quit

end quit
 

Barden95

macrumors newbie
Original poster
Oct 25, 2018
3
0
The continue quit statement is what is, well, continuing the quit. If you move that to your "Yes" block the application won't quit.
Thanks so much for the answer! But, as is probably obvious i'm a complete stranger to this stuff, where should I move it to?
 

Red Menace

macrumors 6502a
May 29, 2011
583
230
Colorado, USA
Not sure about the race between shutting down and quitting, but it would be something like:

Code:
on quit
    set the alert_message to "Have you logged your hours on Timely?"
    display dialog the alert_message buttons {"Yes", "No"} default button 1
    set my_choice to the button returned of the result
    if my_choice is "Yes" then
        tell application "Finder" to shut down
        continue quit
    else
        tell application "Google Chrome"
            open location "app.timelyapp.com"
        end tell
    end if
end quit

See the (legacy) AppleScript Language Guide.
 

Barden95

macrumors newbie
Original poster
Oct 25, 2018
3
0
Not sure about the race between shutting down and quitting, but it would be something like:

Code:
on quit
    set the alert_message to "Have you logged your hours on Timely?"
    display dialog the alert_message buttons {"Yes", "No"} default button 1
    set my_choice to the button returned of the result
    if my_choice is "Yes" then
        tell application "Finder" to shut down
        continue quit
    else
        tell application "Google Chrome"
            open location "app.timelyapp.com"
        end tell
    end if
end quit

See the (legacy) AppleScript Language Guide.
Amazing, this has worked perfectly. Thanks so much!
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.