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 > OmniOutliner > OmniOutliner 3 for Mac
FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
Creating and jumping to bookmarks in OmniOutliner Thread Tools Search this Thread Display Modes
Modified your script to store various small notes in a omniOutliner (even with growl feedback : )

HTML Code:
<code>


-- CREATES BOOKMARKS - USE IN CONJUNCTION WITH GotoBookMk.scpt

property pSection : "Uorganized"
property pVer : ".01"
property pTitle : pSection & tab & pVer


CreateBookMark()
on CreateBookMark()
	
	set my_sel to the clipboard
	set strMark to my_sel
	
	set myPath to "Macintosh HD:Users:Henrik:Documents:To Do.oo3:"
	
	tell application "Finder" to open myPath as alias
	
	tell application id "OOut"
		open myPath
		tell front document
			set refSeln to a reference to selected rows
			if (count of refSeln) < 1 then return
			set strID to id of first item of refSeln
			
			-- GET A NAME FOR THE BOOKMARK
			activate
			
			
			-- FIND/CREATE A BOOKMARKS SECTION
			set refBookmarks to a reference to (rows where its level = 1 and its topic = pSection)
			if (count of refBookmarks) < 1 then
				set rowBookMarks to make new row at beginning of rows with properties {topic:pSection}
			else
				set rowBookMarks to last item of refBookmarks
			end if
			
			-- ADD A BOOKMARK (STORE ID IN NOTE)
			make new row at end of children of rowBookMarks with properties {topic:strMark, note:strID}
		end tell
		delay 0.2
	end tell
	return true
end CreateBookMark

property growlAppName : "Dan’s Scripts"
property allNotifications : {"General", "Error"}
property enabledNotifications : {"General", "Error"}
property iconApplication : "OmniFocus.app"

set my_sel2 to the clipboard
set strMark to my_sel2

tell application "GrowlHelperApp"
	notify with name "General" title "OmniConfirm" application name growlAppName description my_sel2
end tell
</code>
set myPath to set myPath to "Macintosh HD:Users:Henrik:Documents:To Do.oo3:" specifies a particular document

It works in a way that you copy something, then you run the script and the script creates a line in the top of the OO document called "Unorganized" and pastes the clopboard as a child of that category
By placing the it in the top of the document I can still use your bookmark script

Now Im just looking to eliminate the cmd C part so the script will act on highlighted text. Something like

tell application "System Events"
keystroke "c" using command down
 
Included copy from selection
HTML Code:
<code>


-- CREATES BOOKMARKS - USE IN CONJUNCTION WITH GotoBookMk.scpt


property pSection : "Uorg"
property pVer : ".01"
property pTitle : pSection & tab & pVer


CreateBookMark()
on CreateBookMark()
-- New section --------------------------
	tell application "System Events"
		set cur_app to first process whose frontmost is true
		set x to (name of cur_app is "System Events")
		keystroke tab using command down
		repeat while (cur_app is frontmost)
			delay 0.2
		end repeat
		if x then
			set cur_app to first process whose frontmost is true
			keystroke tab using command down
			repeat while (cur_app is frontmost)
				delay 0.2
			end repeat
		end if
		keystroke "c" using command down
		delay 0.2
	end tell
	
	set my_sel to the clipboard
	set strMark to my_sel
	
	
	set myPath to "Macintosh HD:Alt mitt :Henrik:Kontor:To Do:To Do 2012:2012 Høst II.oo3:"
	
	tell application "Finder" to open myPath as alias

	tell application id "OOut"
		
		open myPath
-- end new section --------------------------
		tell front document
			set refSeln to a reference to selected rows
			if (count of refSeln) < 1 then return
			set strID to id of first item of refSeln
			
			-- GET A NAME FOR THE BOOKMARK
			activate
			
			
			-- FIND/CREATE A BOOKMARKS SECTION
			set refBookmarks to a reference to (rows where its level = 1 and its topic = pSection)
			if (count of refBookmarks) < 1 then
-- Changed to beginning
				set rowBookMarks to make new row at beginning of rows with properties {topic:pSection}
			else
				set rowBookMarks to last item of refBookmarks
			end if
			
			-- ADD A BOOKMARK (STORE ID IN NOTE)
			make new row at end of children of rowBookMarks with properties {topic:strMark, note:strID}
		end tell
		delay 0.2
	end tell
	return true
end CreateBookMark

-- Growl feedback 
-- New section --------------------------

property growlAppName : "Dan’s Scripts"
property allNotifications : {"General", "Error"}
property enabledNotifications : {"General", "Error"}
property iconApplication : "OmniFocus.app"

set my_sel2 to the clipboard
set strMark to my_sel2

tell application "GrowlHelperApp"
	notify with name "General" title "OmniConfirm" application name growlAppName description my_sel2
end tell
</code>
 
Quote:
Originally Posted by hmarstra View Post
Would it be difficult to make a version of the second script that would just be a fixed bookmark for a given place in a OO document ?
If you select a row in an OO3 document, and run the code below, it should generate and place in the clipboard a custom bookmark script for jumping back to that particular document and row.

You can then paste the generated code into Applescript Editor.

Code:
property pTitle : "Make OO Bookmark Code"
property pVer : "00.2"

tell application id "OOut"
	set lstDocs to documents
	if length of lstDocs < 1 then return
	tell item 1 of lstDocs
		set lstRows to selected rows
		if length of lstRows < 1 then return
		set strPath to path
		tell first item of lstRows to set {strID, strTopic} to {id, topic}
	end tell
end tell

set the clipboard to "
property pTitle : \"OO3 Bookmark\"
property pVer : \"00.2\"

property pstrTopic : \"" & strTopic & "\"
property pstrDocPath : \"" & strPath & "\"
property pstrID : \"" & strID & "\"

GotoBookMark(pstrDocPath, pstrID, pstrTopic)

on GotoBookMark(strPath, strID, strTopic)
	if FileExists(strPath) then
		tell application id \"OOut\"
			set oDoc to (open (POSIX file strPath as alias))
			my SelectRow(oDoc, strID, strTopic)
		end tell
	else
		display dialog \"File not found at this location\" & return & return & strPath buttons {\"OK\"} ¬
			default button \"OK\" with title pTitle & \"  ver. \" & pVer
		return missing value
	end if
end GotoBookMark

on SelectRow(oDoc, strID, strTopic)
	tell application id \"OOut\"
		tell oDoc
			try
				set oTgt to row id strID
			on error
				activate
				display dialog \"Row id \" & strID &  return & return & \"'\" & strTopic  & \"'\" & return & return & \"not found in \" & name of oDoc ¬
					buttons {\"OK\"} default button \"OK\" with title pTitle & \"  ver. \" & pVer
				return false
			end try
			tell oTgt
				if level > 1 then
					tell last item of ancestors
						set expanded to true
						set expanded of rows to true
					end tell
				end if
				select
				hoist
				
				activate
				tell application id \"sevs\" to click my GetMenuItem(\"OOut\", {\"View\", \"Unhoist\"})
				select
			end tell
			return true
		end tell
	end tell
end SelectRow

on FileExists(strPath)
	(do shell script (\"test -e \" & quoted form of strPath & \"; echo $?\")) = \"0\"
end FileExists

-- 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 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

on GUIEnabled()
	tell application id \"sevs\"
		if UI elements enabled then
			return true
		else
			activate
			display dialog \"This script depends on enabling access for assistive devices in system preferences\" buttons \"OK\" default button \"OK\" with title pTitle & \"   \" & pVer
			tell application id \"sprf\"
				activate
				set current pane to pane id \"com.apple.preference.universalaccess\"
			end tell
			return false
		end if
	end tell
end GUIEnabled
"

display dialog "Bookmark script for \"" & strTopic & "\" now in clipboard." & return & return & ¬
	"Paste into Applescript Editor." buttons {"OK"} default button "OK" with title pTitle & "  ver. " & pVer

Last edited by RobTrew; 2012-11-16 at 07:33 AM.. Reason: Some edits to code → ver 0.002
 
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Jumping to a folder gcrump OmniFocus Extras 3 2008-11-10 11:41 AM
Jumping from Inbox to projects mpw OmniFocus 1 for Mac 8 2008-03-13 01:34 AM
Jumping tabs II daiyi666@yahoo.com OmniWeb Bug Reports 4 2007-02-12 06:00 AM
Jumping tabs? daiyi666@yahoo.com OmniWeb Bug Reports 0 2007-01-26 06:46 AM
Jumping to the top and end of a page synotic OmniWeb General 3 2006-11-03 08:17 AM


All times are GMT -8. The time now is 04:58 AM.


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