AppleScript to toggle screensaver security access
Just as I was leaving the office today, a co-worker of mine provided me with an AppleScript challenge… He had a great idea for a tiny little script that would make his life (and mine, as I suffer from the same annoyance) easier.
Both Cory and I use Apple PowerBooks at work that we take home in the evenings. While at work, it’s nice to have the screensaver require a password to re-activate access to the system. But at home, this requirement quickly becomes burdensome. This feature is controlled by a check box buried in the Security pane of System Preferences, and it’s really a pain to manually toggle this check box twice a day. So Cory said it would be nice to have a script that would effortlessly toggle this check box with a click of a button. Allowing convenient toggling of a significant OS X security measure.
The script below does just that. If you’re interested, I suggest you download the script and save it to /Library/Scripts/ where you will be able to access it easliy from the Mac OS X Script Menu up in the menubar.
This script requires either Mac OS X Panther or Tiger, and also that you enable access for assistive devices in your Accessibility Preference Pane. If you don’t know what that is, don’t worry… the script will guide you through enabling that feature if it’s not turned on already.
tell application "System Preferences"
activate
set current pane to pane "Security"
tell application "System Events"
try
tell application process "System Preferences"
tell window "Security"
click checkbox 1
end tell
end tell
tell application "System Preferences" to close the first window
on error
tell application "System Preferences"
activate
set current pane to pane "com.apple.preference.universalaccess"
display dialog "UI element scripting is not enabled. Check \"Enable access for assistive devices\""
end tell
end try
end tell
end tell
About this entry
You’re currently reading “AppleScript to toggle screensaver security access,” an entry on Todd Ditchendorf’s Blog.
- Published:
- 07.26.05 / 6pm
- Category:
- AppleScript, Mac OS X
Comments are closed
Comments are currently closed on this entry.