I frequently use Grab to capture part of the screen. Until now, I've used Youpikey with a key combination to launch Grab and Shift-Commandd-A to activate the selection for capture. I've now managed to reduce this to one Youpikey keystroke combination in which it launches the AppleScript below. This may not be in itself a significant timesaving hint, but the underlying solution has potential for the scripting of other GUI applications which are generally not scriptable.
Now Grab isn't scriptable, but with the beta version of the System Events application, you can now write AppleScripts that can control the GUI of most OS X applications. This includes the automated selection of menu items, such as the Capture Selection menu items of Grab. The script that I've written and shown below uses the UI Scripting System Events Application. To use it, you'll need to download [81KB] and install the UI Scripting beta application. You can read more about it on Apple's GUI Scripting page.
You can also download the UI Element Inspector [319KB]. It's not essential for this particular application, but it is useful because of the UI Scripting explanation and example given in the Read Me.
The UI Scripting beta requires Mac OS X 10.2.3 as a minimum (I'm running mine under 10.2.4), and you will need to check the box marked 'Enable Access for assistive devices' in the Universal Access section of the System Preferences app for it to work. Happy grabbing!
[robg adds: I haven't tested this one myself...]
-- grabselected -- -- activates Grab and causes it to capture screen selection -- requires Dec2002SystemEvents UI Scripting (beta) -- use of UI Element Inspector optional -- David Paul, 2003. Made in Finland. tell application "Grab" activate tell application "System Events" tell process "Grab" tell menu bar 1 click menu item "Selection" of menu "Capture" end tell end tell end tell end tell
Mac OS X Hints