Go Back   The macosxhints Forums > OS X Help Requests > AppleScript



Reply
 
Thread Tools Rate Thread Display Modes
Old 01-29-2013, 12:20 PM   #1
jamesafoster
Prospect
 
Join Date: Jan 2013
Posts: 5
Shortcut to services menu

I'm trying to write a script that will open the <appname>/Services menu and then wait for the user to select an application service. I have an app that clicks on the right Services menu item (I tested it with other items--those are the comments), but then the actual Services menu does not display. How do I get the Services submenu to display?

Here is my script so far, maximally verbose for clarity.

tell application "System Events"
set app_name to the name of the current application
tell application process app_name
tell menu bar 1
tell menu bar item app_name
tell menu app_name
click menu item "Services"
#click menu item ("About " & app_name)
#tell menu item "Services"
# tell menu "Services"
# click menu item "Services Preferences…"
# end tell
#end tell
end tell
end tell
end tell
end tell
end tell
jamesafoster is offline   Reply With Quote
Old 01-29-2013, 05:10 PM   #2
jamesafoster
Prospect
 
Join Date: Jan 2013
Posts: 5
I forgot to say: I'm running Mountain Lion, osx 10.8.2.
jamesafoster is offline   Reply With Quote
Old 01-31-2013, 10:30 AM   #3
jamesafoster
Prospect
 
Join Date: Jan 2013
Posts: 5
Anyone there? Why does the "click menu item \"Services\"" not open the menu with the available Services options?
jamesafoster is offline   Reply With Quote
Old 01-31-2013, 11:10 AM   #4
DeltaMac
League Commissioner
 
Join Date: Jan 2002
Posts: 7,944
Since Lion, the Services menu is contextual. So, often no services are applicable.
Could that be the reason that your script won't show the services menu (because no services apply)?
DeltaMac is online now   Reply With Quote
Old 01-31-2013, 12:12 PM   #5
benwiggy
League Commissioner
 
Join Date: Aug 2006
Posts: 5,039
Quote:
Originally Posted by DeltaMac
Since Lion, the Services menu is contextual. So, often no services are applicable.

Since Snow Leopard, surely?

Can I ask what the end goal of this is? You can assign keyboard shortcuts directly to Services in System Prefs > Keyboard. Most of the time, the relevant services should be available on a right-click (or double-tap etc).

Have you made sure that "Enable access for assistive devices" in turned on in System Prefs > Accessiblity. I think that has to be on for these "follow-my-click" OSAX commands to work.

Have you seen these pages? They might help:
http://hints.macworld.com/article.ph...60921045743404
http://www.macosxautomation.com/appl...ing/index.html
benwiggy is offline   Reply With Quote
Old 02-08-2013, 11:38 AM   #6
jamesafoster
Prospect
 
Join Date: Jan 2013
Posts: 5
There are definitely Services available.

The objective is to get a list of the available services that I can choose from. Shortcuts are problematic if you have too many...and if your memory is as bad as mine.

And, yes I had "Enable for assistive devices" clicked.
jamesafoster is offline   Reply With Quote
Old 02-08-2013, 12:09 PM   #7
DeltaMac
League Commissioner
 
Join Date: Jan 2002
Posts: 7,944
But, you already have "a list of the available services that I can choose from" in your _Services_ menu?

I am (slightly) curious about how some kind of script would be better for you than the services menu itself?
DeltaMac is online now   Reply With Quote
Old 02-08-2013, 12:22 PM   #8
jamesafoster
Prospect
 
Join Date: Jan 2013
Posts: 5
To get to that list, I need to grab the mouse, move the cursor, click on the app menu item, move the mouse down to services...I want to have a keyboard shortcut tied to the script so that I do that one keystroke and get to the same place as above.

I could pull up the contextual menu, which would be a little faster. But I like to keep my hands on the keyboard as much as possible.

I use services a LOT, so a shortcut would be very nice.
jamesafoster is offline   Reply With Quote
Old 02-08-2013, 04:05 PM   #9
NaOH
Hall of Famer
 
Join Date: Dec 2007
Posts: 3,641
Scripting the GUI is always a pain. Maybe it would be better to use Services Manager to assign keyboard shortcuts to the Services you often use. I've used it under 10.7, not 10.8, but there's no reason to think it won't work in Mountain Lion.

As always with custom keyboard shortcuts, avoid using shortcuts already used globally (like Command-C for Copy) or within specific applications (like Command-D in Safari for bookmarking the current page).

http://macosxautomation.com/services/servicesmanager
NaOH is offline   Reply With Quote
Reply

Tags
services

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



All times are GMT -5. The time now is 02:59 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2013, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.