using system events applescript to control OG menu items

John Oram john at oram.com
Thu Jul 22 14:06:30 PDT 2004


Hi everyone-

I've been playing around once more with automating the export of 
multi-page presentations.  I am trying to use apple system events to 
toggle the menus to select all, copy as PDF in order to grab the 
items on the page.

As for export, I figure could manipulate the menu items either paste 
into a new document and then manually print to PDF, or I could 
manipulate command line arguments like pbpaste and piping to files in 
Terminal to create my multipage pdfs.  As far as I can tell there are 
no AppleScript hooks within OG itself that allow me to do these 
things...

Below is the general direction I am headed with the System Events 
applescript.  I have been grabbing what I can from various sample 
applescripts, but the efforts are interesting at best.  I cobbled the 
following from the sample in "Probe Menu Bar" sample that is included 
in the AppleScript folder -- the menu strings are from the output, 
but I am not quite sure what command would actually *activate* the 
menu selection path.  Do?  Activate?

It's typical of my AppleScript efforts -- it looks like it *could* 
work, but doesn't actually do much.  Anyway, any ideas or hints would 
be greatly appreciated.

-john

tell application "System Events"
	get properties
	get every process
	if UI elements enabled then
		tell process "OmniGraffle Professional"
			get every menu bar
			activate menu item "Select All" of menu 
"Edit" of menu bar item "Edit" of menu bar 1 of application process 
"OmniGraffle Professional" of application "System Events"
			activate menu item "PDF" of menu "Copy As" of 
menu item "Copy As" of menu "Edit" of menu bar item "Edit" of menu 
bar 1 of application process "OmniGraffle Professional" of 
application "System Events"
		end tell
	else
		tell application "System Preferences"
			activate
			set current pane to pane 
"com.apple.preference.universalaccess"
			display dialog "UI element scripting is not 
enabled. Check \"Enable access for assistive devices\""
		end tell
	end if
end tell


More information about the OmniGraffle-Users mailing list