Applications can be scheduled to launch using Power Manager's built-in Schedule Assistant, but what if you need to schedule an application to quit? In this recipe we will walk through how to ask an application to quit.
There are a handful of ways to quit a running application in Mac OS X. The recommended way is to use AppleScript to ask the application to quit. This is the most polite method because it gives the application the greatest opportunity to clean up before quitting.
The AppleScript needed to quit TextEdit is:
tell application "TextEdit" quit end tell
You can change the
tell application line to match the application you wish to quit. To quit the presentation application Keynote, the following variant would be used:
tell application "Keynote" quit end tell
Well behaved Mac applications will respond to a quit request sent via an AppleScript. Poorly behaving applications, or processes not specifically designed for the Mac, can be quit using a UNIX method involving sending a signal. This method is not covered in this recipe.
Let's look at how to schedule the application PowerPoint to quit at a specific time each day.
Create a Scheduled Quit Event
- Launch Power Manager.
- Click on the Add… button to create a new event.
- Select the Run a script daily task within the Schedule Assistant.
- Click Continue to move to the Script step.
- Copy and paste the following AppleScript into the Script step:
#!/usr/bin/osascript tell application "Microsoft PowerPoint" quit end tell
- Click Continue to move to the When step. On the When step adjust the time of day and days to trigger the quit event.
- Click Continue through until the Why step. On the Why step provide a name and any notes you desire for the event, then click Continue to move to the Confirm step.
- Click Add to create the new quit application event.
The quit application will be scheduled immediately. There is nothing more to do but wait for the trigger time to arrive. Power Manager will automatically wake your Mac if it is sleeping when the trigger time is due.