Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

There are applications which have script icon in menu like iTunes, NetNewsWire, TaskPaper and it is easy to create script for those apps and assign shortcut (using Keyboard pref pane), but most don't have such icon, submenu and possibility to assign shortcut. Can this be triggered somehow (for example Info.plist) or it is programmed inside app?

I need this to make ⌘W hide window instead of closing and I need this only for certain apps (TaskPaper and Sqlite Pro). I tried to assign ⌘W on hide action, but this way ⌘H stops working (as only one shortcut can be assigned). So, for TaskPaper I created script, which is visible through its script menu and shortcut can be assigned, but Sqlite Pro lacks such menu, and I am looking for solution to assign ⌘W to hide Sqlite Pro without breaking ⌘H doing the same.

share|improve this question

3 Answers 3

up vote 2 down vote accepted

Here's how to do it. Verified it works in Snow Leopard.

  1. Open Automator, create new service
  2. Select in top popups "Service receives no input in TaskPaper" (Find and choose TaskPaper from your second popup)
  3. Paste in the following Applescript: tell application "System Events" to set visible of first application process whose frontmost is true to false
  4. Save Service. "Hide Frontmost"
  5. Open System Preferences, go to Keyboard, double-click the service and set the keyboard shortcut to ⌘W.

Repeat this process for Sqlite Pro. I don't see a way to apply the service to a selection of Applications, seems to be all or one. You could use some applescript to check the name of the application process and check it against some list, hide if in the list, close if not… but i'll leave that as an exercise to the reader. :)

share|improve this answer
    
The only change: I think it's better to run tell application "System Events" to set visible of process named "TaskPaper" to false. About checking using Applescript — it'll be wrong as it'll slow close and some applications close window, others close tabs. And as I need to apply this behavior only to two apps, it's easier to create to services. Thank you for your answer! –  tig May 18 '10 at 11:10
    
Found problem: I created two services, but trying to assign same shortcut on both of them shows warning "Shortcut used by another action" (though I selected context app and they can't interfere), also I can't find place where shortcut is set (I though that it should be in Info.plist as for other services). Ignoring warning makes ⌘W buggy — some applications stoped responding on it (and I hear beep). –  tig May 18 '10 at 12:31

The ones I think you are referring to are stored in /Users/youruser/Library/Scripts.

Otherwise you can use the automator to kick off your scripts.. have a look at http://osxgoodies.wordpress.com/2010/02/24/all-about-applescript/

share|improve this answer
    
Maybe I was not clear enough in my question: I want to assign shortcut to run script while using that application and it is easy with for example iTunes, but I can't find easy way with for Finder, Mail and most other applications –  tig May 15 '10 at 0:42
    
@tig That link will get you on the right track (if you're using OSX 10.6 Snow Leopard). You can use automator to create a Service that executes an applescript. You can assign shortcuts to Service menu items in the System Preferences > Keyboard > Keyboard Shortcuts panel –  ghoppe May 15 '10 at 22:50
    
I added explanation why I need this :) –  tig May 16 '10 at 10:44
    
@tig Again, you can create an automator service can do exactly what you want. I'm not 100% certain it will override the default ⌘W though. –  ghoppe May 16 '10 at 21:18
    
Verified it works. See my answer. –  ghoppe May 16 '10 at 21:42

FastScripts treats scripts in ~/Library/Scripts/Applications/AppName/ as specific to AppName. Application-specific scripts are shown at the top of the menu by default.

fastscripts

share|improve this answer
    
How do you assign keyboard shortcuts to Mac OS X's builtin Scripts menu? –  Daniel Beck Mar 22 '11 at 21:48
    
@Daniel Well, the second part of the title was or how to show per application scripts menu. I edited the answer though. –  ؘؘؘ Mar 22 '11 at 21:51

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.