Archive for February 26, 2004

Thursday, February 26, 2004

Enter Search String and Send Now

John Gruber had the bright idea of using a menu script to override Mailsmith’s Send Now command. Send Now has the same keyboard shortcut as Enter Search String in BBEdit, so if he has text selected in the message window, he probably meant to enter the search string rather than send the message. In this circumstance, Gruber’s script asks for confirmation that you want to send the message. Below is a modification of his script. My version sets the search string to the selected text and then doesn’t send the message. In other words, the script guesses the appropriate action and then does it.

on enterSearchString()
    tell application "System Events"
        tell application process "Mailsmith"
            click menu item "Enter Search String" of menu "Search" of menu bar 1
        end tell
    end tell
end

on menuselect()
    tell application "Mailsmith"
        tell message window 1
            if (selection as text) is not "" then
                my enterSearchString()
                return true
            else
                return false
            end if
        end tell
    end tell
end menuselect

One problem is that if the message isn’t sendable (i.e. if no recipients have been entered), then the menu item will be disabled and the menu script can’t be used.