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 Search Today's Posts Mark Forums Read

 
Application file id for OmniOutliner Thread Tools Search this Thread Display Modes
Hi all,

I have OmniOutliner Pro installed, but I want to create an applescript that will work on the Pro or non-Pro version. What's the application file id for standard OmniOutliner?

Alternatively, is there a way to address both versions in one fell swoop?

Thanks.

-Tim
 
OO3 Pro is com.omnigroup.OmniOutlinerPro3
OO3 is com.omnigroup.OmniOutliner3

I'm not sure it's the best way to do it, but the following worked for a proof of concept:

Code:
set appID to "com.omnigroup.OmniOutlinerPro3"
set hasOOPro to true

try
	tell application id appID
		activate
	end tell
on error
	set appID to "com.omnigroup.OmniOutliner3"
	set hasOOPro to false
end try

tell application id appID
	if hasOOPro then
		display dialog "User has OmniOutlinerPro"
	else
		display dialog "User has OmniOutliner"
	end if
end tell
 
It turns out that the solution above doesn't work. The only reason it works as written is because there aren't any Omni-specific commands inside that tell. If you try to create a new document, for example, it will fail.

Isn't there any way to efficiently write an AppleScript that will target either OmniOutliner or OmniOutlinerPro (assuming that the script doesn't utilize any Pro-specific commands)?

Perhaps OmniOutliner Pro's scripting system could be written to accept an "OmniOutliner" tell statement and run with the corresponding subset of capabilities. That would make it easier to distribute scripts among end users who might have either version.

-Tim
 
Hmm. I'm able to create documents, but not rows.

I haven't done a full set of experiments as I'm not willing to reboot my computer at the moment, but it looks like if you just use
Code:
tell application "OmniOutliner"
that an attempt to use it with the other app will pop up the script editor to have you point out the location of "OmniOutliner" and after that everything is smooth sailing. This would be a problem if you wanted to distribute a Run-only application, but not so much of one if you're just distributing the source of the script.

You might also ask the support ninjas for their advice on this matter via Help->Send Feedback.
 
I haven't tested this hypothesis (only one version of OO on my system) but I think that both versions share the same "creator code" (OOut) so you should be able to write code like that below,

but the problem remains that the library reference will be resolved too late to retrieve any properties or commands that are specific to OO. Their names will appear to Applescript to simply be variable names ...
(no problem, however, in referring to any classes, like 'document', that are defined in the standard Applescript libraries)

(If you look at the code below it will probably occur to you that it is not impossible to put the whole of your script into a string literal, patching the string with the name of the appropriate application, and then running it with the run script idiom. This approach does indeed give full access to the OO-specific libraries, but you may find it a little messy and hard to maintain ... It also brings a bit of a performance cost)


Code:
--- GET A REFERENCE TO WHICHEVER VERSION OF OO IS RUNNING

property pCreatorCode : "OOut"
property pOmniOutliner : missing value

tell application id "com.apple.systemevents"
	try
		set procOO to first process where creator type is pCreatorCode
	on error
		display dialog "OmniOutliner is not running"
		return
	end try
	set strName to name of procOO
end tell

set strScript to "
script
	on GetAppRef()
		return application " & quote & strName & quote & "
	end GetAppRef
end script
"
set oScript to run script strScript
set pOmniOutliner to GetAppRef() of oScript


--- NOW USE THE VERSION-INDEPENDENT IDIOM:  tell pOmniOutliner

tell pOmniOutliner
	if (count of documents) > 0 then
		tell front document
			display dialog name as string with title "Front OmniOutliner Document"
		end tell
	else
		display dialog "No Documents open in OO"
	end if
end tell
--

Last edited by RobTrew; 2010-07-28 at 02:03 AM..
 
e.g.

Code:
property pCreatorCode : "OOut"

tell application id "com.apple.systemevents"
	try
		set procOO to first process where creator type is pCreatorCode
	on error
		display dialog "OmniOutliner is not running"
		return
	end try
	set strName to name of procOO
end tell

set strScript to "
script
	on CountRows()
		tell application " & quote & strName & quote & "
			if count of documents > 0 then
				tell front document
					set strMsg to \"Number of rows in \" & name as string & \" is \" & (count of rows) as string
					display dialog strMsg
				end tell
			end if
		end tell
	end CountRows
end script
"
set oScript to run script strScript
CountRows() of oScript
 
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
OmniOutliner file displayed as directory? marcussommer@mac.com OmniPresence 9 2013-04-11 10:55 AM
OmniOutliner file locations benmadin OmniOutliner 3 for Mac 6 2013-02-21 04:58 PM
OmniOutliner slow in opening large file dmdmd OmniOutliner for iPad 1 2012-02-08 10:28 AM
Omnioutliner file corrupt after downloading from FTP site. mikecni OmniOutliner 3 for Mac 2 2011-02-23 04:53 AM
OmniOutliner File Attachment Issue Cypher OmniOutliner 3 for Mac 2 2008-01-07 03:47 AM


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


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