Open Recent macro for BBEdit
January 19, 2014 at 11:22 AM by Dr. Drang
One of the things that frustrates me about BBEdit is that the menu item has no keyboard shortcut. This morning, I fixed that with a Keyboard Maestro macro.
BBEdit has its own builtin preference system for assigning keyboard shortcuts to menu items, but the
item isn’t available for assignment.Hence the shift to Keyboard Maestro, which has a macro action for selecting menu items that allows you to either type in the names of the menu and the item or choose it from a cascade of submenus.
Unfortunately, I couldn’t get this to work. Since the point of the macro is to just bring up the
submenu and let me choose from among the files, choosing any one of the files currently in the menu isn’t right. I thought I’d be able to choose the item, which acts as a header for the top several items in the submenu, but that didn’t work—the macro simply did nothing. Then I hit on the idea of using the text entry method to tell Keyboard Maestro just to select the item of the menu. It didn’t fall for that trick, either.So I settled for a brute force technique. Since the menus and menu items are in fixed positions on the screen, I built a macro that clicked in particular spots to bring up the submenu. Here it is:
The .kmmacros
file for this macro can be downloaded from this Gist.
I was surprised to learn that I needed a short pause after clicking to open the
menu; I guess BBEdit needs a little time to build the list of entries in the submenu. A pause of 0.3 seconds works on my 2010 MacBook Air and probably isn’t the minimum necessary, so I’m pretty sure it’ll be sufficient for more recent machines. You may be able to reduce it if the delay bothers you.Although I expect to use the cursor keys to select the file, there may be times when the file I want is so far down the list that it’ll be faster to use the mouse. The second-to-last action in the macro anticipates that by moving the mouse (without clicking) into the submenu. Without that positioning, any initial upward or downward movement of the mouse would deselect
and cause the submenu to disappear.I haven’t tested this on my iMac, but I don’t see any reason it wouldn’t work there. If I’m wrong and need to tweak it to get it to work on more than just my Air, I’ll update the Gist.
By the way, I do know about the
command, but I don’t see it as a replacement for , because I often can’t remember the name I gave a file and need to scan the submenu. As my grandfather used to tell me, it’s hell to get old.Update 1/20/14
Ed Cormany pointed out, via Twitter, a better way to open the submenu. You can, in Keyboard Maestro’s Show Menu action, enter the names of the menu and submenu but leave the menu item blank. That makes the macro shorter and it eliminates the need for the delay.
You’ll note that I’ve kept the Move Mouse action. Without that step, if the mouse happens to be within the rectangle that the
menu will drop into when I run the macro, any vertical movement of the mouse will cause the submenu to disappear.I’ve updated the Gist, although I bet it takes longer to download and install it that it does to just enter the steps directly into Keyboard Maestro.