
Mar 18, '03 09:55:00AM • Contributed by: dave2003
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!
-- 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
[robg adds: I haven't tested this one myself...]