4 Replies Latest reply: Mar 31, 2006 9:26 PM by Camelot
darock Level 2 Level 2 (190 points)
How can you Keystroke the degree "º" symbol
this does not work

tell application "TextEdit"
activate
make new document
end tell
tell application "System Events"
tell process "TextEdit"
keystroke "8"
keystroke "0" using option down
end tell
end tell

it is getting the zero from the 10 key pad and not the "0 / )" key

Thanks
darock

PM G4, Mac OS X (10.4.5)
  • 1. Re: Keystroke a degree º Symbol
    Tony D Level 1 Level 1 (55 points)
    You could use:

    keystroke "k" using option down

    It might not be a degree symbol, but it looks close enough for me...

    Dual G5   Mac OS X (10.2.x)  
  • 2. Re: Keystroke a degree º Symbol
    Camelot Level 8 Level 8 (45,790 points)
    Technically, neither option-0 or option-K are the degree symbol (option-o is technically 'masculine ordinal indicator' an option-k is 'ring above, as in å).

    The correct character for the degree symbol is option-shift-8. However, neither 'keystroke "8" using {option down, shift down}', nor 'keystroke "*" using option down' has the desired result.

    The only solution I've found is to use the key code command rather than the keystroke, and this seems to work:

    tell application "TextEdit" to activate
    delay 1
    tell application "System Events"
    tell process "TextEdit"
    keystroke "8"
    key code 28 using {option down, shift down}
    end tell
    end tell


    I can't explain why keystroke "8" using {option down, shift down} doesn't work, though.
  • 3. Re: Keystroke a degree º Symbol
    darock Level 2 Level 2 (190 points)
    Thanks Camelot
    Where or how can I get info on "key codes"

    Thanks again
    darock
  • 4. Re: Keystroke a degree º Symbol
    Camelot Level 8 Level 8 (45,790 points)
    > Where or how can I get info on "key codes"

    Ahh, a fine question.

    I use a little free utility called Key Codes.

    It puts a floating window on your screen that shows you keycodes as you type on the keyboard.