Jump to content
alfredclough

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

Recommended Posts

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

Share this post


Link to post

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.

Share this post


Link to post

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

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...