Jump to content

Is it possible to get a list of Services from System Preferences?


Recommended Posts

I searched for this online and I think this may be impossible to do but perhaps not.

 

Is it possible to get a list of Services that I have activated in 'Services' in System Preferences here? 

 

YfYEa1H.png 

 

It would be super useful to have a workflow similar to this one for searching menu bar items but for searching active Services actions instead.

 

 

Edited by nikivi
Link to comment

Hi @nikivi, if I understand you clearly, you want the items in the Services Menu (App Menubar -> Services -> Active items there), so those that are active in the menubar based on your context (if you are in a text field or in the Finder...) ? And not a way to edit the "System Preferences->Keyboard->Shortcuts->Services Menu items" ? If so, I also wanted to have access to them and was using the Menu Bar Search workflow, but like the Key Clue workflow, it doesn't filter the list to only the active one and also doesn't always give them all...

 

So, I had a look and found an easy way to get what we want.

Here a workflow that give you a list of the items that are active in the Services Menu and that you can trigger

https://nofile.io/f/TBcsjAai1o1/Services+Menu.alfredworkflow

 

* I think I'll need to make a repository to put my workflows and scripts that I sent to this forum so they are easily found ;)

 

 

I don't think there's another Workflow that gives the active Services Menu Items in context, so for those who want more information about the idea:

 

Basically, when we look in the Services Menu of the menubar programmatically, we get a list of all our Services instead of only those that are active. However, we can look at the attributes of the menu items and those that are not active doesn't have some attributes set like: Position (AXPosition) or Size (AXSize)... Therefore, we just have to filter the menu items so we only get those that have a position/size set.

 

It's quite easy with Applescript and could be just that:

tell application "System Events"
	tell (first process where it is frontmost)
		return name of every menu item of menu of menu item "Services" of menu 1 of menu bar item 2 of menu bar 1 whose item 1 of value of attribute "AXPosition" is not missing value
	end tell
end tell

but I went with JXA in the workflow so it's easier to build the JSON output for Alfred

 

Hope this helps! :)

Edited by GuiB
Link to comment

Hey @GuiB

 

You really should make a GitHub repo. Perhaps have something like this. :) 

 

And that script is pretty awesome although I have this odd thing that nothing shows up in my services across all my apps apart from this : 

598b69319545c_2017-08-09at21_57.png.db102561fd24b7f3a2e9a670c59827ef.png

 

Don't really know how to manipulate what shows up there.

 

Also what I was actually looking for is search across all the services that there exist in that Services tab. I was looking at the plugin Deanishe sent earlier and I think it is certainly possible, just need to understand how to transfer that to Alfred. Also I don't use Quicksilver.

Edited by nikivi
Link to comment

Hi @nikivi, to add services to this menubar item you need to tick those that you want from the list of you first screen capture in your first post. However, the list would then depend on the context of when you want to execute a Service. For example, open TextEdit and don't select anything then look in the Menubar/Services section for the items that are listed. Then, do the same thing, but with text selected in the a text field. Then you should see other Services that relate to text. You should be able to send your selection to another application based on the Service that you activate. It's the same thing when you are in the Finder and you select a file or a folder, the list should change for services that can be run for files/folders...

 

If this doesn't work, then maybe your application doesn't use standard GUI element or something else is not working correctly on your system...

 

However, yes, this would be great to have this kind of Workflow that would always list all the Services and that could be activated at any time. Launchbar has this feature as well. The way it works is that it asks you for the item that the Services need before running, so it asks you for text or file/folder based on what the service want and then active the service with the item.

Link to comment

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...