How to Display a Message After a Long Task
Power Manager is frequently used to start long running tasks. While any event is running, Power Manager's menu bar changes to show a small cog. Sometimes this small indicator is not enough.
Power Manager is frequently used to start long running tasks. While any event is running, Power Manager’s menu bar changes to show a small cog. Sometimes this small indicator is not enough.
Being able to tell the user that the task has finished can be useful. Let’s look at how to use AppleScript to present a dialog to the active user.
We are going to start by extending an existing event. Our event performs a back up of the Mac’s hard drive to an external drive. The back up can take a few minutes and we want to to be told when it has finished.
Show a Message Using AppleScript
Launch System Preferences and select Power Manager.
Open the event to edit in the event editor; hold down the Option and double-click on your event.
Add a new action; select Add an action > Run Script > AppleScript.
Edit the new action; select the Action’s Action cog > Edit.
Copy and paste the following AppleScript into the Script field:
#!/usr/bin/osascript tell application "Finder" to display dialog "Your back up has finished."
Click Apply to save the changes to the new action.
Click Save to save the changes to the event.
With your event modified, take the time to test it works as expected. Try triggering your event and waiting for the new message to appear.
Does the message appear too soon? Check to see if the action before your Run Script action has an option called Continue set to Immediately. You can change this behaviour to On Exit. This setting tells Power Manager to wait for the earlier action to finish completely, before running the next action.