Sorting non-ASCII unicode text (from FastScripts)

Fastscripts returns the hotkey combination for any script that has one using the following phrases as an example. The conventional symbols for the modifier keys plus the character used for the key show properly in a dialog (but are only partial at best in the result pane).

tell application "FastScripts"
	set KeyedScript to some item of (get script items where has keyboard shortcut is true)
	set KeyCombo to shortcut string of keyboard shortcut of KeyedScript
	display dialog KeyCombo
end tell
KeyCombo

I’d like to do one of two things: sort on the collection of all KeyCombos including their modifier symbols, or parse those symbols for the normal words used: control, shift, option, command.

Any hints on how to do either of those welcome!

Hi Adam,

AppleScript’s Unicode capabilities are not perfect yet.
The modifier keys are present, but non MacRoman characters are lost in the result window of Script Editor (and also in Script Debugger)

try this to filter the characters

tell application "FastScripts"
	set KeyedScript to some item of (get script items where has keyboard shortcut is true)
	set KeyCombo to shortcut string of keyboard shortcut of KeyedScript
	repeat with i in characters of KeyCombo
		my say_characters(contents of i)
	end repeat
end tell

on say_characters(c)
	if c is «data utxt2303» as Unicode text then
		say "control"
	else if c is «data utxt2318» as Unicode text then
		say "command"
	else if c is «data utxt2325» as Unicode text then
		say "option"
	else if c is «data utxt21E7» as Unicode text then
		say "shift"
	else
		say c
	end if
end say_characters

Wundervoll :slight_smile:

With a few alterations, this does it very nicely. What I was missing was the «data utxtabcd» codes for them. Where are they? I didn’t encounter them while pawing around.

Adam

⌥⌘T (Character Palette) and then with view: Code tables > 00002190 Arrows and 00002300 Miscellaneous Technical

Great. Now if I can tell between the “help” key (which shows up as a question mark) from the question mark itself, and refine the treatment of F-keys so as not to get F, 1, 3 for F13, I’ll be there. A bit more fiddling. :wink: