Indeed.
If you have Omnioutliner, and you have previously downloaded Omni’s “Sample Applescripts”, there is a script in there which takes tabbed outlines and converts them to Omnioutliner. But it is rather slow — doing the menubar of Text Edit took over 4 minutes to convert. I think part of the slowness of that script is that it counts tabs by examining every character in every line (suspect the line “repeat with aChar in every character of aLine” is part of the problem?) . That should be something that could be sped up, maybe by just counting tabs and not everything else…. Once it is in Omnioutliner, the script to generate your Applescript GUI scripting line is pretty simple — similar to what I posted above and with a few modifications in the text output. For example, “select” vs “click” depending on the UI element you are activating.
Alas, I do have OmniOutliner — great program, but I consider the $50 I spent on Bill Cheeseman’s “UI Browser” to be money well spent! Just the “show UI element” feature is worth the price of admission - you just click on the element you are interested in and the program generates the AS GUI script you need. No guessing about the elements listed in an outline. https://pfiddlesoft.com/uibrowser/index.html
Attached below is the Omnioutliner import script from their sample scripts.
(* Clipboard to OmniOutline v0.3 2005/05/03
*
* Creates a new OmniOutliner Pro outline from text stored in the clipbard
* - Each line in the clipboard text becomes a new row in the outline
* - Leading tabs in the text are used to control the level/indent of the rows in the outline
*
* TODO: Determine how/if to handle broken indenting in the clipboard text
* TODO: Tune performance - parts of this script can't be fast
*
* Copyright (c) 2005 J. A. Greant (zak@greant.com / http://zak.greant.com)
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*)
tell application "OmniOutliner"
set newDoc to make new document at beginning of documents
repeat with aLine in my FetchClipboardAsList()
my CreateRow(newDoc, my CountAndTrimTabs(aLine))
end repeat
end tell
on FetchClipboardAsList() -- return clipboard contents as list
set myList to {}
repeat with currentLine in every paragraph of (the clipboard as string) -- break into list by carriage returns/newlines
copy currentLine to end of myList
end repeat
return myList
end FetchClipboardAsList
on CountAndTrimTabs(aLine) -- count and remove leading tabs from a string
set tabCount to 0
repeat with aChar in every character of aLine
set aChar to aChar as string -- aChar is a single item list til cast to string
if aChar is equal to tab then
set tabCount to tabCount + 1 -- count leading tab
else if tabCount > 0 then
set aLine to (get text (tabCount + 1) thru (length of aLine) of aLine) -- trim leading tabs
exit repeat
end if
end repeat
return {tabCount:tabCount, content:aLine}
end CountAndTrimTabs
on FetchLastRow(doc) -- return the last row in an OmniOutliner document. If no rows, return the document itself.
tell application "OmniOutliner" -- enter right context to work with OmniOutliner Pro objects
if rows of doc is equal to {} then
return doc
end if
return last row of doc
end tell
end FetchLastRow
on CreateRow(doc, aLine) -- create a new row from a line with indent information
tell application "OmniOutliner" -- enter right context to work with OmniOutliner Pro objects
set parentRow to my FetchLastRow(doc)
if parentRow is doc then
set parentLevel to 0 -- the document has now rows, and thus, no indent
else
set parentLevel to level of parentRow
end if
if tabCount of aLine > parentLevel then -- create a child of the last row
make new row with properties {topic:(content of aLine)} at end of children of parentRow
else -- create a peer or superior of the last row
repeat (parentLevel - (tabCount of aLine)) times -- if needed, work our way back to the right parent
set parentRow to parent of parentRow
end repeat
make new row with properties {topic:(content of aLine)} at end of parentRow
end if
end tell
end CreateRow