|
Shortcuts 1.1.3 Abracode Website: http://www.abracode.com/free/cmworkshop/ What is it? Shortcuts is a Mac OS X application to assign hot keys to contextual menu items. It works only with menu items added by contextual menu plug-ins. Requirements Mac OS 10.4 or higher. Some useful contextual menu plug-ins highly recommended. Introduction Ever wanted to assign a hot key combination to contextual menu item? "Shortcuts" is the answer. It allows you to assign a hot key combination to chosen menu item so you can select some object (file in Finder or text) and hit keyboard combination to execute the task normally performed by choosing that menu item. Shortcuts works with contextual menu plug-ins only. It does not work with menu items added by the application which shows the menu. For example, when you ctrl-click on Desktop in Finder you have "New Folder" and other items added by Finder. You cannot assign shortcuts to those items. But the same contextual menu also shows some items added by plug-ins — in default Mac OS 10.4 installation it would see Automator and folder actions items which are added by Apple-provided plug-ins — and you can assign shortcuts to those items. Of course you probably need to have some third party contextual menu plug-ins installed to make good use of "Shortcuts". But even if you used it only for one frequently used item it would be worth installing and getting the benefits of much faster execution. Unfortunately not all contextual menu plug-ins will work with "Shortcuts". Only contextual menu items which play by the rules will work. So what are the rules? The rules are: when the context information (selected text of file information) is passed to the contextual menu plug-in, it should advertise available commands by returning the menu item name. It seems obvious but some plug-ins do it in a different way. They do not provide the names of their contextual menu items when asked and they try to add those items to menu later. You will not be able assign shortcuts to those items because in most cases they will not show up at all when "Shortcuts" tries to query all plugins. Another class of problematic plug-ins are those which restrict their visibility to certain applications only — for example some plug-ins may show only in Finder. In such case "Shortcuts" will not see their items. Installation Please copy "Shortcuts" to your "Applications" folder before starting it. If you are upgrading from previous version, make sure you stop "ShortcutObserver", remove it from login items and remove "CocoaTextSelectionHelper". All this can be done from the first panel in "Shortcuts". So it is recommended to start old version of Shortcuts, perform the cleanup, quit and then replace with new version. Components "Shortcuts" solution consists of several components working together. All is wrapped in one application: Shortcuts. But inside we have a background-only application named "ShortcutObserver". This application must be running in order to capture your hot key, load the proper plug-in and execute the command. "Shortcuts" provides an easy way to start and stop "ShortcutsObserver". It also provides a way to add "ShortcutObserver" to login items so the background app can start each time you login. There is also a helper plug-in called "CocoaTextSelectionHelper". This bundle is an Input Manager plugin. It is installed in ~/Library/InputManagers/. It is an optional helper to get text selection from front text view (aka first responder) in Cocoa applications. Finally, there are context providing scripts written with AppleScript described in section below. Context providing scripts AppleScript context providers is a bridge between ShortcutObserver and the front application. You can think of those as plug-ins for ShortcutObserver. Several scripts for popular applications are provided by Abracode. You may add scripts for applications you use (if those applications are scriptable of course). The script name must match the host application name as displayed in the menu bar (top left, next to Apple menu). Why those scripts are needed? In order to understand why they are needed and how they are used, one must get familiar with the way ShortcutObserver works and how it differs from regular contextual menu invocation. Contextual menus, as the name suggests, work with some context information, usually selected text, file, folder or other object. Host application, the one showing the contextual menu, is responsible for passing the context data to the plug-in when asking for advertised services. With ShortcutObserver the situation is slightly different: the host application still needs to provide the context data but it is the ShortcutObserver which loads the plug-in, gets the context data from front application and then passes that data to plug-in and asks it to execute the command. ShortcutObserver is the app which handles everything after it gets invoked with hot key combination. The problem is that ShortcutObserver needs to get the context information from front application so it needs to talk to that application somehow. Finder is the most important application with many contextual menu plug-ins written for it so ShortcutObserver has a built-in protocol to talk to Finder (via AppleEvents) to get currently selected file or folder information. Another built-in plug-in is for obtaining current text selection from Cocoa applications. It is done via optional "CocoaTextSelectionHelper" mentioned earlier. The extra benefit of this approach is that some contextual menu plug-ins which normally don't work in Cocoa applications would get a way to obtain the information about currently selected text. So those two cases are taken care of but for other applications you need special scripts. ![]() There are two types of scripts currently supported. One type is for obtaining text data, the other is for file or folder data. Scripts providing text context should ask the host application to get current selection as Unicode text. File/folder scripts on the other hand should get the alias of currently selected object (or a list of aliases). You may notice scripts under "File/Folder" category which get file information from text editors for example. At first look it may seem that it does not make sense to get file information from application which primarily deals with text. The "context" idea is extended in this case. The file information associated with the front window may be the location of the document you are editing (while the text context would still be the selected text in that window). This gives you an additional benefit: you may perform an operation on front document in some editor as if you control-clicked on its file in Finder. For example: imagine a plug-in which changes privileges of read-only files to read-write — now imagine you opened a read-only file in TextEdit and you realized you cannot modify it — with Shortcuts you may have a keyboard combination to make it writable in a fraction of a second. All this is possible because when you assign hot key in Shortcuts you do it specifically for text, file or folder context and Shortcuts saves this information. When the command is invoked, ShortcutObserver "knows" what is the preferred context type: text or alias and acts accordingly executing the text or alias context provider script. Usage Shortcuts uses a compact interface in four panels. Use first panel to start "ShortcutObserver", add it to login items and install the helper bundle. You can also turn on the bezel window notification. If this option is on and you press the assigned key combination, a transparent window with executed command name will appear for a couple of seconds. ![]() The second panel is for assigning hot keys to contextual menu items. It might seem complicated at first look but when you get an understanding of how it works, you will find it easy to use. Think of this panel as a contextual menu simulator to test what items will show for given context information. There are three sections in this panel for three most popular context data types: text, file and folder. On the left side you can enter example data to feed the contextual menu plug-ins and ask for advertised services. On the right side you have a popup menu which displays items obtained from plug-ins. Depending on the data provided on the left side you will see different menu items on the right side. For example: if you choose a picture file in the second section you may see items which show only for pictures (QuickImageCM is one example of CM plug-in operating on image files). In the screenshot below you can see "Delete Resource Fork" item added by GrimRipperCM. It shows up because the example file contains the resource fork. If the chosen file did not have the resource fork, this item would not show up. Of course it will not show up if you don't have GrimRipperCM installed at all. ![]() The screenshot below illustrates another contextual menu simulation. This time we are looking at items that would show if you control-clicked on text selection. The first submenu is added by ClipMasterCM. Remember that it is a simulation — when you choose a menu item, you will not execute the command but a sheet dialog will be displayed to enter a keyboard shortcut. You probably wonder what the text in red means. Items in red are the ones which have a hot key combination already assigned — these are the "hot" items. ![]() The small sheet dialog to assign hot key combination is shown below. Choose your keyboard combination wisely to avoid conflicts with existing hot keys. Your key combination may conflict with front application hot keys or with global shortcuts set in "System Preferences" -> "Keyboard & Mouse" -> "Keyboard Shortcuts". It may also conflict with other third party hot key observers if you installed any. One rarely used combination is Control+Option+Command+Some Key. It is easy to remember because those are the three neighbor key modifiers and the chance for conflict with most applications is small. ![]() The third panel contains the list
of active shortcuts. You may change the hot key combination or remove
the shortcut entirely. The menu item is displayed as pseudo path with
submenus and menus separated by forward slash: "/". Forward slash at
the beginning indicates the root menu.
![]() Yellow help tags are added to all panels so you can hover the mouse cursor over some control to see a quick hint on usage. Known Problems 1. Not all contextual menu plug-ins work with Shortcuts. In most cases there is not much that can be done about it but ask the author of the plug-in to change the code to work with Shortcuts. 2. There might be conflicts with other hot key combinations assigned by other applications. 3. Sometimes the pressed key combination does not arrive to ShortcutObserver. Usually a second time you press they combination it works. It is a situation which is hard to reproduce and debug but it looks like it is a problem in Mac OS X. Version History 1.1.3 February 20, 2008 - Fixed CocoaTextSelectionHelper plug-in permissions so it can be loaded in Mac OS 10.5 1.1.2 November 3, 2007 - Updated for full Leopard compatibility 1.1.1 April 12, 2007 - Fixed a crash when assigning a hot key 1.1 April 3, 2007 - Fixed a problem with some contextual menu plugins generating dynamic menu items in a specific way. This change makes PicturePopPro 2 items visible in Shortcuts. - Added a checkbox to simulate multiple file or folder selection. This is needed for CM plug-ins which display different menu items when you click on more than one file or folder. One specific example of such plug-in is FileUtilsCM. - Added conflict warnings when you try to assign the same hot key as one of the global hot keys active in "System Preferences" -> "Keyboard & Mouse" -> "Keyboard Shortcuts" or key combinations in "Services" menu. 1.0 May 4, 2006 Initial release |