The Omni Group
These forums are now read-only. Please visit our new forums to participate in discussion. A new account will be required to post in the new forums. For more info on the switch, see this post. Thank you!

Go Back   The Omni Group Forums > Developer > AppleScripting Omni Apps
FAQ Members List Calendar Today's Posts

 
Toggle button to show notes text in Marked Thread Tools Search this Thread Display Modes
Here's a script that shows the note text from the currently selected row in Marked (version 1). I made it use the standard version of the application, but it should probably work with Professional as well. I have it set up as a toggle button on my toolbar as shown here. If Marked is open, clicking the button causes it to quit. Otherwise it pops up and floats with the text of the notes for the selected row.

Code:
if application "Marked" is not running then 
	tell application "OmniOutliner"
		set xNote to note of selected row of front document as text
	end tell
	do shell script "echo " & quoted form of xNote & "> /Users/YourUsername/some_file.txt"
	do shell script "open -a \"Marked.app\" $HOME/some_file.txt"
	tell application "Marked" --This part keeps Marked on top
		activate
		tell application "System Events"
			key down command
			key down shift
			key down "F"
			delay 0.5
			key up command
			key up shift
			key up "F"
		end tell
	end tell
else
	tell application "Marked"
		quit
	end tell
end if
 
Good idea :-)

(OmniOutliner needs a way of working with MarkDown)

To make a version which will work with both Pro and Standard Omnioutliner, edit the application reference to use their shared Creator Code preceded by id, rather that one of their differing application names:

Code:
application id "OOut"
instead of :

Code:
application "OmniOutliner"
 
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
 
 





All times are GMT -8. The time now is 03:03 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.