AppleScript to insert formatted character

Discussion in 'Mac Programming' started by MyCatTom, Feb 1, 2010.

  1. MyCatTom macrumors newbie

    MyCatTom

    Joined:
    Nov 28, 2008
    Location:
    Washington, DC
    #1
    Hello,

    I am trying to replace the Macros I used to use in Word to insert music characters into a document.

    The characters I need to insert are the sharp, flat, and natural symbols. In Apple Symbols they are Unicode 266F for the sharp, 266D for the flat, and 266E for the natural. I would like them in 12 point. And, if possible, I would like to trigger the script with a key combination. I had been using Ctrl-S for the sharp, Ctrl-N for the natural, and Ctrl-F for the flat.

    After the character is inserted I need to return to my default font (currently Adobe Caslon Pro, but Times New Roman would be fine too).

    If anyone can help me I would be very, very appreciative!

    Thanks,
    Leigh
     
  2. mysterytramp macrumors 65816

    mysterytramp

    Joined:
    Jul 17, 2008
    Location:
    Maryland
    #2
    Rather than use macros, could you use Word's built-in keyboard customization commands? You might find that more productive than an AppleScript.

    You might even be able to do it with Autocorrect.

    ## -> ♯

    ∫∫ -> ♭(option b, option b)

    ˜˜-> ♮(option n, option n)

    (If you know the following, this will be tedious. Sorries in advance ...)

    If you have trouble entering the sharp, flat or natural signs, go to

    System Preferences -> Language & Text -> Input Sources tab

    Then select the "On" checkmark next to "Keyboard & Character Viewer"

    You should get a new icon in your menubar. (It's hard to describe what it's supposed to look like. A box with an asterisk might be the best I can do.)

    Select "Character Viewer" and a floating window should appear. A menu to the left will include "Musical Symbols." You'll find the characters there. Put your cursor where you want the character to appear, select the character from the window, then hit Insert.

    This should work regardless of the font you're using, so this shouldn't need to return you to the font you were working on.

    mt

    P.S. I have Word on my XP laptop at work, but not on my Mac at home. Sorry if this doesn't work.
     
  3. MyCatTom thread starter macrumors newbie

    MyCatTom

    Joined:
    Nov 28, 2008
    Location:
    Washington, DC
    #3
    Hi MT,

    Thanks for the reply. I had tried to get it working with AutoCorrect before but wasn't able to do so. I think it was because I was determined to keep my former keystrokes of Ctrl-f, Ctrl-n, and Ctrl-s. Word wouldn't let me enter those in the "Replace" box. Your suggestion was just what I needed to remind me that I could use different keystrokes to trigger the replacement.

    Using your ## as a starting point, I set that up for the sharp, then figured since a natural is lower than a sharp, why not use @@ for natural, and since a flat is lower than a natural, how about !! for flat. Seems to be working, and seems to be returning to my usual font after inserting the music character.

    Thanks again - I can't tell you how much time I had spent on this by myself!

    Leigh
     

Share This Page