Uses for scripting?


#1

Now that Pro, with Applescript available, will become the new Standard version for existing users, I wonder what you are using Applescript to achieve. In Omnifocus, I have a few simple but very convenient scripts, but I don’t really see what Applescript can do for me in Omnioutliner. I’m curious to hear about actual uses for it.


#2

AppleScript can pull in information from other apps, for example pull the urls of all open Safari tabs and place them as links under a ‘References’ row.

I also find it useful to extend OO’s functionality a little: merge rows and their notes, collapse an outline to the level of the currently selected row, tell me where I am in an outline (a ‘breadcrumb’).

SG


omniJS – Style enumeration values can't be compared or tested?
#3

SG, do you have a link to a script that does the Safari URL’s to OO links action? Thanks.


#4

@Skippy

This one works well here…

SG

--gets current Safari urls and creates new links in OO under row named "References"
-- https://discourse.omnigroup.com/t/what-makes-the-text-in-a-topic-a-hyperlink/10179/14
-- any Safari pinned tabs included too, without links
-- see also https://discourse.omnigroup.com/t/can-a-service-capture-a-safari-url-to-an-existing-oo-outline/22499/3

tell application "Safari"
	tell window 1 to set {topics, urls} to {tabs's name, tabs's URL}
end tell

tell application "OmniOutliner"
	try
		tell document 1
			set refRow to row named "References"
			-- delete refRow's children -- if want to start afresh not append
			repeat with i from 1 to count topics
				set newChild to make new row at refRow
				tell newChild
					set topic to topics's item i
					set topic cell's text's style's attribute "link"'s value to urls's item i
				end tell
			end repeat
			set refRow's expanded to true
		end tell
	end try
end tell

#5

everything and anything.

Think of a thing you do in Omnifocus. then add “Automatically” to the beginning of the sentence.

“automatically create tasks to read every chapter in a book”
“Automatically create tasks from templates”
“automatically complete things that have time limits” etc.


#6

I use it to convert my OO outlines into other formats – handouts, slides, lecture notes, fully typeset articles, reports, etc.

Previously I only used OO for outlines and checklists, since converting an OO outline into e.g. a typeset article was so time-consuming. But I’ve written some scripts that let me do most of my writing in OO, and then automatically convert what I’ve written to whatever format I need, formatted to my specifications. This is great, because OO is fantastic for writing/revising complex documents from start to finish (much better than e.g. Ulysses IMO), but not for formatting them for consumption by others.


#7

The centre of gravity here seems to be exports and format conversions generally.

This underscores the need (particularly in the OmniOutliner case) for a method which allows the excellent omniJS to return a value resulting from the evaluation of a submitted script.

TaskPaper’s analogous use of a JS Context provides a good model - a few wrapping lines of JavaScript for Automation or AppleScript:

  1. Submit a JS script text for evaluation (perhaps with some key-value pairs for options)
  2. get a return value back (could be string, list/array, record/dictionary, or number)
  3. do something with that return value, perhaps saving it, for example, to a file.

Why not do it all in AppleScript / JXA ?

Because OmniJS is much faster, has an easier scripting interface, and works on iOS versions of Omni apps too.

Why not do it all in omniJS ?

Because a JS Context, while very fast and wonderfully cross-platform, doesn’t have access to the file-system.