Jump to content

Anyone Know how to Run an OSX service in a workflow?


Recommended Posts

Posted

This should do the trick. Kinda. It assumes that the main menu (where the Services menu resides) has the same name as the application. This isn't true for Google Chrome, for example, so the script doesn't work with it.

set theServiceName to "OmniFocus: New Inbox Task per Line"

tell application "System Events"
	set appName to item 1 of (get name of processes whose frontmost is true)
	tell (process 1 where frontmost is true)
		tell menu bar 1
			tell menu bar item appName
				tell menu appName
					tell menu item "Services"
						tell menu "Services"
							click menu item theServiceName
						end tell
					end tell
				end tell
			end tell
		end tell
	end tell
end tell
Posted

deanishe,

 

That's a creative idea, but I was looking for a programmatic way to access the service. Kinda the way in Quicksilver you could enter text and then pass it into any OS X service.

Posted

Err, that is a programmatic way … You mean an actual API? There isn't one, not for AppleScript.

 

Quicksilver can do it because it's a Cocoa application. AppleScript can't. You need to call the Cocoa NSPerformService class, which could possibly be done via AppleScript using Automator Runner, thus.

  • 9 months later...
Posted (edited)

Glad it works for you, but that sounds like an OS bug.

 

Still, Spotlight on German systems recognises the English names of apps, so maybe the bug is that it doesn't work without ever changing the system to English and not that it works in the "wrong" language.

Edited by deanishe
  • 5 years later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...