View Single Post
Sample code fragments (not stand-alone, but perhaps indicative)

Code:
property pblnUnion : true
property pblnSubtract : false

-- gather a list of shapes in lstShapes
-- ...
-- THEN

tell application id "OGfl"
	set oWin to front window
	set selection of oWin to lstShapes
	activate
	-- PERFORM ANY SHAPE UNIONS
	if pblnUnion then
		tell application id "sevs" to click (my GetMenuItem("OGfl", {"Edit", "Shapes", "Union Shapes"}))
		-- PERFORM ANY SHAPE SUBTRACTIONS
	else if pblnSubtract then
		tell application id "sevs" to click (my GetMenuItem("OGfl", {"Edit", "Shapes", "Subtract Shapes"}))
	else
		assemble lstShapes
	end if
end tell
Code:
-- RETURNS A REFERENCE TO A CLICKABLE MENU ITEM
-- E.G. set mnuZoomFit to GetMenuItem("OGfl", {"View", "Zoom", "Zoom to Selection"})
on GetMenuItem(strAppCode, lstMenu)
	set lngChain to length of lstMenu
	if lngChain < 2 then return missing value
	
	tell application id "sevs"
		set lstApps to every application process where its creator type = strAppCode
		if length of lstApps < 1 then return missing value
		tell first item of lstApps
			-- GET THE TOP LEVEL MENU
			set strMenu to item 1 of lstMenu
			set oMenu to menu strMenu of menu bar item strMenu of menu bar 1
			
			-- TRAVEL DOWN THROUGH ANY SUB-MENUS
			repeat with i from 2 to (lngChain - 1)
				set strMenu to item i of lstMenu
				set oMenu to menu strMenu of menu item strMenu of oMenu
			end repeat
			
			-- AND RETURN THE FINAL MENU ITEM
			return menu item (item -1 of lstMenu) of oMenu
		end tell
	end tell
end GetMenuItem

Last edited by RobTrew; 2012-07-23 at 05:19 AM..