Language: Applescript
Download: http://gist.github.com/111945
Background: Hot corners, or active screen corners, are an option in OS X where you can toss your cursor to a corner to trigger an action, such as Expose, the launch of application, or the screensaver. However, this can take getting used to, and I'm reminded of this every time a visitor uses my notebook. To address this issue, I decided that I needed a one-click toggler to set and unset my four corners. GUI scripting via Applescript seemed to be the way to do it.
-- Hot Corner On Toggler:
-- Toggle all four hot corners on to specified settings
-- (assumes you've set the script to use predefined settings you always use.
-- This is the counterpart to the script that toggles all four hot corners off,
-- for cases when a visitor comes over who isn't used to active screen corners.
-- 2009 May 14. Written for OS X 10.5.x.
-- Gordon Mei, with guidance from Pierre L. from Apple discussions
-- Feel free to use and distribute however you'd like.
tell application "System Preferences" to activate
tell application "System Events"
tell process "System Preferences"
tell menu bar 1
tell menu bar item "View"
delay 0.5
tell menu 1
click menu item "Exposé & Spaces"
end tell
end tell
end tell
tell window "Exposé & Spaces"
tell tab group 1
click radio button "Exposé"
tell group "Active Screen Corners"
tell pop up button 1 -- top left corner
click
tell menu 1
click menu item "Spaces"
end tell
end tell
delay 0.05
-- delay here to prevent error: "can't get menu 1 of pop up button 2 of group...invalid index"
tell pop up button 2 -- bottom left corner
click
tell menu 1
click menu item "All Windows"
end tell
end tell
delay 0.05
tell pop up button 3 -- top right corner
click
tell menu 1
click menu item "Application Windows"
end tell
end tell
delay 0.05
tell pop up button 4 -- bottom right corner
click
tell menu 1
click menu item "Desktop"
end tell
end tell
end tell
end tell
end tell
end tell
delay 0.1
keystroke "w" using command down
end tell
No comments:
Post a Comment