Mailsmith



Saturday, 7 May 2005

Mailsmiths are Mailsmithing Profession Assets that can be acquired as necessary components for completion of Mailsmithing tasks from Forgotten Profession Level 14 and above, and/or as optional components in Rare tasks that will reduce the completion time for their armor pieces. Install Location: Mailsmith Support/Action Scripts/ Last Modified: 2019-10-02 Description. You can use this script instead of Mailsmith’s built-in support for SpamSieve, if you want additional flexibility. First, uncheck Use SpamSieve in the Spam Handling preferences.

The new Dictionary app is one of my favorite new features in Mac OS X10.4. Dictionary’s primary advantage over online dictionaries —including Sherlock’s — is that its database is stored on yourcomputer, and thus is always available; online dictionaries areuseless to an offline laptop. Plus, I like the presentation, and Ilike the definitions. As a writer, Dictionary is pretty much exactlywhat I want.

But, since I do the vast majority of my writing in BBEdit andMailsmith, I was faced with a problem. To be truly useful as a writingaid, you need to be able to invoke your dictionary easily from the appin which you’re writing. What I want to do is select a word in BBEdit(or Mailsmith or TextWrangler) and tell Dictionary to look up thatword in one quick action. But:

  • Dictionary’s “Look Up in Dictionary” contextual menu itemcurrently only appears in Cocoa NSTextView and WebView controlfields. Thus it doesn’t appear in BBEdit, TextWrangler, orMailsmith.

  • Dictionary’s system-wide keyboard shortcut — Command-Control-Dby default, but configurable in the Keyboard & Mouse panel inSystem Preferences — also only works in Cocoa NSTextView andWebView fields.

    Update, 12 May 2005: BBEdit 8.2.1 now supports theCommand-Control-D shortcut and inline Dictionary panel. Very, verycool. I’m fairly certain Bare Bones is now the first third-partydeveloper to add support for these hooks.

  • Dictionary does not have an AppleScript dictionary. (Technically,it does have a scripting dictionary, but it’s just a defaultCocoa dictionary, and offers no scripting features for performingdefinition look-ups, which means it’s effectively useless.)

  • Dictionary ostensibly allows you to perform look-ups via thedict:// URL scheme, but, as I’ve documented on my Tiger Detailsreport, this feature is half-baked at best, and for some usersdoesn’t seem to work at all.

That leaves two options, both of which I’ve found to work very well.

Mailsmith

‘Look Up in Dictionary’ Service

Dictionary’s menu command in the Services menu works just fine fromBBEdit/TextWrangler/Mailsmith. The only downside is that it doesn’thave a keyboard shortcut, and mousing into the Services sub-menu istoo inconvenient.

However, you can easily add a custom shortcut to the “Look Up inDictionary” Services menu item:

Mailsmith
  1. Open the Keyboard & Mouse panel in System Preferences, then click onthe Keyboard Shortcuts tab.

  2. Click the “+” button to add a new shortcut.

  3. In the configuration sheet, you can either choose “All Applications”or just pick a single application. Even though it seems as thoughthere’s just one system-wide Services menu, the truth is that eachapp creates its own instance of the Services menu. So if you want,you can customize a Service menu item shortcut for just one particularapp. For consistency, though, I think it’s better to choose “AllApplications” and use the same shortcut everywhere.

  4. Type “Look Up in Dictionary” in the Menu Title field. This must matchexactly.

  5. Type your new shortcut in the Keyboard Shortcut field. You can prettymuch type whatever shortcut you want here, and it’s important to notethat the system does not perform any conflict checking, so you can use a shortcut that’s already used by other menu items (includinganother command in the Services menu itself).

  6. You’ll need to quit and relaunch any apps that are currentlyrunning to use this new shortcut.

Mailsmith

Scripting the Dictionary App via GUI Scripting

I’m so lazy that I don’t even want to have to select a word beforedoing a look-up on it. If I don’t have a selection, I’d like mylook-up command to use whatever word the insertion point is touching.This means the Services menu command is out, because it’s only enabledwhen there’s a range of selected text.

We can use AppleScript to get the “current word” adjacent to theinsertion point (cf. “‘Select Word’ Script for BBEdit”,published here back in 2003), but what can we do with it if Dictionaryisn’t scriptable and its support for dict:// URLs is broken? Weresort to GUI Scripting.

Here’s the script. (To use it with Mailsmith or TextWrangler, all youneed to do is change the tell application 'BBEdit' line.)

The first part of the script sets dict_query to the text of thecurrent selection. If there is no text selection, then it tries to getthe “current word” adjacent to the insertion point. If that fails(e.g. if the insertion point is currently on a blank line), it uses adialog box to prompt for a word to look up.

The GUI scripting part has two key steps (after making sure thedict_query variable isn’t empty and activating the Dictionary app):

  1. Set the tell target to the search field in Dictionary’s mainwindow’s toolbar.

  2. Simulate keystrokes to enter the dict_query string in the field.

  3. Simulate a “return” keystroke.

The script uses the GUI scripting keystroke command instead ofsetting the value of the search field and then simulating a click onthe magnifying glass search button; in my experience this worksbetter. Also, the script first sets the value of the search textfield to the empty string; without this step, the new query issometimes appended to the existing query instead of replacing it.

Save the script in your BBEdit (or Mailsmith or TextWrangler) scriptsfolder, then use the Scripts palette to assign a keyboard shortcut,and you’re set. (I’ve got mine bound to Control-D, which is super-easyto type.)

Remember that to use GUI Scripting, you need to turn it on; it’s offby default. On Mac OS X 10.4, the easiest way to turn it on is to usethe new AppleScript Utility app (in the “AppleScript” folder insidethe top-level “Applications” folder). If you try running this scriptwith GUI Scripting turned off, you’ll get strange“NSReceiverEvaluationScriptError” error messages.

A Brief Plug for PreFab UI Browser

The GUI scripting part of the script looks fairly simple, but how didI know that the name of the magnifying-glass icon button was “search”?You need to know this, because simply setting the value of the textfield doesn’t initiate a look-up. For that matter, how did I know howto string together the chain of objects to address the search textfield in the first place — the “text field 1 of group 1 of tool bar1” bit?

Apple’s solution is the painfully stark UI Element Inspector app.

But the only good way to determine the syntax for addressing interfaceelements via GUI scripting is to use PreFab UI Browser, an excellentutility that puts Apple’s UI Element Inspector to shame. It costs$55, but has a lenient and generous demo period during which you cantry it for free.

Trying to accomplish something with GUI scripting without using UIBrowser is like trying to walk around blindfolded. If not for UIBrowser, I seriously doubt I would have even attempted this script.

It’s a completely valid gripe that Dictionary ought to provide aproper AppleScript command for performing look-ups, and I hope thisgets addressed in a future update. But in the meantime, GUI scriptinggets the job done today.

Mail.smithbucklin.com

Previous:The Tiger Details List
Next:I Suppose It Has to Be OK