Hi!
I would like to execute a Script (for example a Script sending E-Mail or like that) when my Mac is shuting down to have an information about the time when my computer starts to be inactive. Does know anyone how is it possible? Thanks in advance?
Alex
There already plenty topics about logout scripts!
Search function is your friend!
I already posted a solution here:
http://bbs.applescript.net/viewtopic.php?id=13520
Other topics:
http://bbs.applescript.net/viewtopic.php?id=12784
http://bbs.applescript.net/viewtopic.php?id=4888
.
Thank you, Vicence!
But, can you put me an example, please? I am new in that!
Thanks a lot!
Alex
¢ Make a new script file with this code:
on run
--this will add this script app to the login-items:
set appPath to POSIX path of (path to me)
tell application "System Events"
if login item (my name) exists then
else
make login item at end with properties {path:appPath, hidden:false}
end if
end tell
end run
on quit
--here come your actions like:
launch application "Safari"
--or:
open ("the:path:to:your:desired:script:file" as alias)
continue quit -- <- this must remain - this is important! Else the app won't quit!
end quit
¢ customize the actions
¢ Save the script as “Application Bundle” with “Stay Open” selected and “Startup Screen” and “Run Only” unselected
If you don’t want your app to appear in the Dock:
¢ Go into the Finder, ctrl-click the created script app and choose “Show Package Contents”
¢ Browse to “YourApp.app/Contents/Info.plist” and open it with “Plist Editor” or whatever you want
¢ add a boolean “LSUIElement” property with value “true” to its “Info.plist”
¢ Save the “Info.plist”
¢ Launch your app
¢ Logout to test, whether it works
(If your action takes to much time to run it might interrupt the logout)
How it works:
Your just created helper app will launch on every login, stay open in the background (using 0.0 CPU ! ) and do the actions when it is quit (and that should happen on logout)
Hope this helps!
Ciao
Vince