#! /usr/bin/env ruby text = STDIN.gets(nil) # Applescript to check that GUI scripting is turned on start = %Q{ -- get the system version set the hexData to system attribute "sysv" set hexString to {} repeat 4 times set hexString to ((hexData mod 16) as string) & hexString set hexData to hexData div 16 end repeat set the OS_version to the hexString as string if the OS_version is less than "1030" then display dialog "This script requires the installation of Mac OS X 10.3 or higher." buttons {"Cancel"} default button 1 with icon 2 end if -- check to see if assistive devices is enabled tell application "System Events" set UI_enabled to UI elements enabled end tell if UI_enabled is false then tell application "System Preferences" activate set current pane to pane "com.apple.preference.universalaccess" display dialog "This script utilizes the built-in Graphic User Interface Scripting architecture of Mac OS X which is currently disabled." & return & return & "You can activate GUI Scripting by selecting the checkbox \\"Enable access for assistive devices\\" in the Universal Access preference pane." with icon 1 buttons {"Cancel"} default button 1 end tell end if tell application "System Events" } finish = <