The Omni Group Forums

The Omni Group Forums (http://forums.omnigroup.com/index.php)
-   AppleScripting Omni Apps (http://forums.omnigroup.com/forumdisplay.php?f=46)
-   -   Toggle button to show notes text in Marked (http://forums.omnigroup.com/showthread.php?t=30925)

matt999 2013-10-14 11:42 AM

Toggle button to show notes text in Marked
 
Here's a script that shows the note text from the currently selected row in [URL="http://markedapp.com"]Marked[/URL] (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 [URL="http://www.lawschoolmatt.com/workflows/omnioutliner-show-note-text-in-marked-app"]shown here[/URL]. 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[/CODE]

RobTrew 2013-10-14 12:48 PM

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 [I]id[/I], rather that one of their differing application names:

[CODE]application id "OOut"[/CODE]

instead of :

[CODE]application "OmniOutliner"[/CODE]

RobTrew 2013-10-14 01:51 PM

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 [I]pblnPositionWindows[/I]) tries to position your Marked and OO3 windows side by side, with 50% of the screen each.

(Note that it requires [URL="http://marked2app.com/"]Marked 2[/URL] it uses [I]Preview Clipboard[/I])

[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[/CODE]


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

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