View Single Post
Here is a variant on your theme which I am using from Keyboard Maestro.

It doesn't close Marked (I tend to keep Marked running), but it does allow you to select several OO rows and concatenate their notes in Marked if you want (for previewing or export to PDF, MS Word, HTML etc).

It also optionally (edit the value of pblnPositionWindows) tries to position your Marked and OO3 windows side by side, with 50% of the screen each.

(Note that it requires Marked 2 it uses Preview Clipboard)

Code:
property pTitle : "View OO3 notes in Marked II"
property pVer : "0.01"

-- VIEW NOTES OF SELECTED ROW(S) IN BRETT TERPSTRA'S MARKED VER 2
property pblnPositionWindows : true -- Set this to false to disable the window positioning at the end of the script

on run
	set lstNote to {}
	tell application id "OOut" to set lstNote to note of selected rows of front document
	if lstNote ≠ {} then
		-- JOIN THE NOTES OF ANY SELECTED ROWS
		set {dlm, my text item delimiters} to {my text item delimiters, linefeed & linefeed}
		set strNote to lstNote as text
		set my text item delimiters to dlm
		
		-- PLACE THEM IN THE CLIPBOARD
		do shell script "echo " & quoted form of strNote & " | pbcopy"
		
		-- USE MARKED 2 PREVIEW > CLIPBOARD PREVIEW
		tell application id "com.brettterpstra.marky"
			activate
			close windows
		end tell
		tell application id "sevs"
			click my GetMenuItem("com.brettterpstra.marky", {"Preview", "Clipboard Preview"})
		end tell
		
		-- OPTIONALLY TRY TO POSITION THE MARKED AND OO3 WINDOWS SIDE BY SIDE
		if pblnPositionWindows then
			set lngWidth to word 3 of (do shell script "defaults read /Library/Preferences/com.apple.windowserver | grep -w Width")
			set lngHeight to word 3 of (do shell script "defaults read /Library/Preferences/com.apple.windowserver | grep -w Height")
			set lngHalf to lngWidth / 2
			set lngHeight to lngHeight - 22
			
			tell application id "sevs"
				set procOutliner to first process where name contains "OmniOutliner"
				tell procOutliner to tell window 1 to set {position, size} to {{lngHalf, 22}, {lngHalf, lngHeight}}
				tell process "Marked" to tell window 1 to set {position, size} to {{0, 22}, {lngHalf, lngHeight}}
			end tell
			tell application id "OOut" to activate
			tell application id "com.brettterpstra.marky" to activate
		end if
	else
		tell application id "OOut"
			activate
			display dialog "No rows selected in OO3..." buttons {"OK"} default button "OK" with title pTitle & "  ver. " & pVer
		end tell
	end if
end run

-- RETURNS A REFERENCE TO A CLICKABLE MENU ITEM
-- E.G. set mnuZoomFit to GetMenuItem("OGfl", {"View", "Zoom", "Zoom to Selection"})
-- 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 application processes where its bundle identifier = 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 (OR MISSING VALUE, IF UNAVAILABLE)
			try
				return menu item (item -1 of lstMenu) of oMenu
			on error
				return missing value
			end try
		end tell
	end tell
end GetMenuItem