1

I want to add a shortcut to "About" for every software, just like most of them have CMD+, for entering preferences.

But this could as well be a question used for many other things, since I want to do it through either Automator, Script or just System Preferences, if possible.

Any hints on how to do this? Please, no third part solutions.

Oliver Salzburg
  • 87,539
  • 63
  • 263
  • 308
cregox
  • 5,894

1 Answers1

2

tell application "System Events"
    try
        set a to name of process 1 where frontmost is true
        tell process a to click menu bar 1's menu bar item 2's menu 1's menu item 1
    end try
end tell

The same approach also works for Undo* and Redo* in most applications.

How to assign a shortcut for running an Applescript

Lri
  • 41,444
  • Sounds lovely. I'll see if I can use this! :) – cregox Mar 31 '11 at 19:26
  • Lri, about your edit, by chance I've tried the exact steps you described there with Automator, but for some reason that's not working - I can't find the service listed either in Keyboard Services or any Application > Services. I'm trying to find out why. – cregox Mar 31 '11 at 20:08
  • All right, I just redid it once again and took care to paste it in the proper place (the first time I've replaced the on run part). Now the actual script isn't working. It just does nothing. – cregox Mar 31 '11 at 20:13
  • @Cawas Did you try logging out and back in? – Lri Mar 31 '11 at 20:32
  • @Lri I have issues with logging out as I always have a lot of things open... Plus I wouldn't think it would be required in this case! But I'll try that soon enough. Thanks again! – cregox Mar 31 '11 at 20:39
  • @Lri still not working after a reboot. Starting to investigate now... – cregox Apr 01 '11 at 15:02
  • @Cawas Ok, I just fixed a similar issue yesterday with a relogin. (I was trying out ThisService for Can I use a bash script as a Service in OS X without having to set it up trough automator? - Super User). Another way to update services is apparently /System/Library/CoreServices/pbs, but you shouldn't have to do it manually for services in (~)/Library. – Lri Apr 01 '11 at 15:13
  • @Lri the service is up even before the reboot. if I press the shortcut several times I can even see the little notification icon in the icon area on the top saying it's running - several of them, for a brief period. It's just the script isn't working for some reason. – cregox Apr 01 '11 at 15:19
  • @Lri last thing I could realize is it's not getting inside tell application "System Events" / try. I've set automator to display the apple script before running so it's easy to debug - but I just don't know enough apple script to get around this issue easily. Would you know what could be wrong? – cregox Apr 01 '11 at 19:02
  • @Cawas Are you sure you selected Service recieves: [no input]? It works just fine for me. There's a ~1 second delay before running it though, which doesn't occur with eg FastScripts. So do you really have to wrap it as an Automator service? It would be a lot easier (and probably faster) to just run it directly. – Lri Apr 02 '11 at 15:55
  • @Lri yes, I sure selected [no input] and the challenge here is without 3rd parties. But I just tried it on another machine (mine at home), simply by copying the workflow from ~/Library/Services, and it worked! So it's something weird on that other machine at work, which I have not even sudo permissions and thus a lot less crap installed. – cregox Apr 02 '11 at 17:17