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

Monaj

macrumors regular
Original poster
May 24, 2009
193
0
Hi all,

I am trying to make an application using AppleScript which can remind to check my mails, if I forget to check, at shutdown.

I took help from this link:
HTML:
http://discussions.apple.com/thread.jspa?threadID=1375949&tstart=0&messageID=7088687#7088687

In this link they have suggested that I can run a quite application which can be started at login and when I will try to shut down, system will try to close it and desired result will be obtained!

I have tried this script code:

Code:
say "Good morning Miraaj! I will be reminding you to check your mails at shutdown. Have a rocking day!!"
on quit

set the alert_message to "Have you checked your mails?"
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 "Safari"
        open location "www.gmail.com"
    end tell
end if
continue quit
end quit

but it is not working for me!

Can anyone suggest where I may be wrong ??

thanks,

Monaj
 

mysterytramp

macrumors 65816
Jul 17, 2008
1,334
4
Maryland
What's not working? Is the script running? Is it a stay-open script? Where is it saved? Have you saved it to StartupItems?

mt
 

chown33

Moderator
Staff member
Aug 9, 2009
10,751
8,425
A sea of green
It is displaying alert message at launch whereas I want it to show it only during shutdown when system tries to quit it!

You probably haven't saved it as a Stay Open application. It's one of the Options checkboxes.

When the script isn't saved as Stay Open, then it quits after the initial say command finished. That means it runs its Quit handler, which shows the dialog.

This problem has nothing to do with the script itself. The problem lies entirely in how the application is saved. For example, this much simpler script:

Code:
say "Hello."

on quit
	say "Goodbye"
	continue quit
end quit

When saved as Application with Stay Open checked, it stays open after saying hello. When I choose Quit from its Dock menu, it says goodbye and quits.

When saved as Application without Stay Open checked, it says hello, then says goodbye and quits. It does not stay open.
 

Monaj

macrumors regular
Original poster
May 24, 2009
193
0
This problem has nothing to do with the script itself. The problem lies entirely in how the application is saved.
When saved as Application with Stay Open checked, it stays open after saying hello.

Thanks, chown.... it worked :)
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.