Tuesday, February 1, 2011

Applescripting notes

I wish i had more time to learn about Applescript as there are a bunch of things i'd like to do with it...  One thing i've done is create this small script to unmount volumes and put my MacBook Pro to sleep:
tell application "Finder"
    eject (every disk whose ejectable is true)
end tell
I have a Hendge dock for it (http://www.hengedocks.com/) to save all the plugging and unplugging, but at the end of the day, i wanted something to unmount and sleep.
So, run the AppleScript Editor and develop or paste what you want.  Click "Compile".  Do a "Save As" and save it to your home directory's Library/Scripts directory with a name such as "Eject and Sleep".
Then, you can also map a key to it: System Preferences, Keyboard, Keyboard Shortcuts.  Choose Application Shortcuts, click '+'.  Choose All Applications, Menu Title: Eject and Sleep, or whatever you typed before, and end the key combination you'd like...
Another thing one can map are "Services" on object such as directories.  So, if you can left click on a folder and there is something listed under Services, you can create a keyboard shortcut for it.  Here are two images demonstrating that.

No comments: