Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

10.6: An Automator Service to enter special characters System 10.6
Snow Leopard only hintHere's how to use Automator-based Snow Leopard Service along with an AppleScript to present a popup window from which you may choose from a list of special character symbols to input. The Service gives you quick access to OS-related (or other) characters for quick entry into documents.

Do these steps:
  • Launch Automator.
  • Select Service as the type of Automator template.
  • Change input to 'none' and 'all applications.'
  • Add a 'run Applescript' action.
  • Paste in the AppleScript code from below, and save the Service. Give it a name you'll remember.
  • Use the Services item in the Keyboard prefpane to set a keyboard shortcut (I used Command+Shift+7).
  • Open a document window, such as a new TextEdit document window.
  • Trigger the Service with your shortcut key.
  • Select a character from the list, and click Insert.
Here is the AppleScript code:
tell application "System Events"
	set frontApp to name of first process whose frontmost is true
end tell

set theCommand to źdata utxt2318╗ as Unicode text
set theControl to źdata utxt2303╗ as Unicode text
set theOption to źdata utxt2325╗ as Unicode text
set theShift to źdata utxt21E7╗ as Unicode text
set theEscape to źdata utxt238B╗ as Unicode text
set theTab to źdata utxt21E5╗ as Unicode text
set theReturn to źdata utxt21A9╗ as Unicode text
set theEnter to źdata utxt2324╗ as Unicode text
set doubleTab to tab & tab

tell application frontApp
	choose from list {theShift & doubleTab & "Shift", theControl & doubleTab & "Control", theOption & doubleTab & "Option", theCommand & doubleTab & "Command", theOption & theCommand & doubleTab & "Option+Command", theEscape & doubleTab & "Escape", theTab & doubleTab & "Tab", theReturn & doubleTab & "Return", theEnter & doubleTab & "Enter"} with prompt "Pick the symbols you want:" OK button name "Insert" with multiple selections allowed
end tell

if result is not equal to false then
	set pickedSymbols to result as string
	set displaySymbols to ""
	if pickedSymbols contains "Shift" then
		set displaySymbols to displaySymbols & theShift
	end if
	
	if pickedSymbols contains "Control" then
		set displaySymbols to displaySymbols & theControl
	end if
	
	if pickedSymbols contains "Option" then
		set displaySymbols to displaySymbols & theOption
	end if
	
	if pickedSymbols contains "Command" then
		set displaySymbols to displaySymbols & theCommand
	end if
	
	if pickedSymbols contains "Escape" then
		set displaySymbols to displaySymbols & theEscape
	end if
	if pickedSymbols contains "Tab" then
		set displaySymbols to displaySymbols & theTab
	end if
	if pickedSymbols contains "Return" then
		set displaySymbols to displaySymbols & theReturn
	end if
	if pickedSymbols contains "Enter" then
		set displaySymbols to displaySymbols & theEnter
	end if
	
	tell application "System Events"
		tell process frontApp
			set the clipboard to displaySymbols
			keystroke "v" using {command down}
		end tell
	end tell
end if

[crarko adds: I tested this, and it works as described. I used BBEdit to test it.]
    •    
  • Currently 3.83 / 5
  You rated: 4 / 5 (6 votes cast)
 
[5,334 views]  

10.6: An Automator Service to enter special characters | 2 comments | Create New Account
Click here to return to the '10.6: An Automator Service to enter special characters' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
10.6: An Automator Service to enter special characters
Authored by: DrFred on Feb 17, '11 08:43:28AM

Wow! I would love to be able to use this. However, after following the instructions as best I could, I am not getting it to work. I'll copy the workflow for anyone who might be able to see what may have gone wrong, here:

tell application "System Events"
set frontApp to name of first process whose frontmost is true
end tell

set theCommand to źdata utxt2318╗ as Unicode text
set theControl to źdata utxt2303╗ as Unicode text
set theOption to źdata utxt2325╗ as Unicode text
set theShift to źdata utxt21E7╗ as Unicode text
set theEscape to źdata utxt238B╗ as Unicode text
set theTab to źdata utxt21E5╗ as Unicode text
set theReturn to źdata utxt21A9╗ as Unicode text
set theEnter to źdata utxt2324╗ as Unicode text
set doubleTab to tab & tab

tell application frontApp
choose from list {theShift & doubleTab & "Shift", theControl & doubleTab & "Control", theOption & doubleTab & "Option", theCommand & doubleTab & "Command", theOption & theCommand & doubleTab & "Option+Command", theEscape & doubleTab & "Escape", theTab & doubleTab & "Tab", theReturn & doubleTab & "Return", theEnter & doubleTab & "Enter"} with prompt "Pick the symbols you want:" OK button name "Insert" with multiple selections allowed
end tell

if result is not equal to false then
set pickedSymbols to result as string
set displaySymbols to ""
if pickedSymbols contains "Shift" then
set displaySymbols to displaySymbols & theShift
end if

if pickedSymbols contains "Control" then
set displaySymbols to displaySymbols & theControl
end if

if pickedSymbols contains "Option" then
set displaySymbols to displaySymbols & theOption
end if

if pickedSymbols contains "Command" then
set displaySymbols to displaySymbols & theCommand
end if

if pickedSymbols contains "Escape" then
set displaySymbols to displaySymbols & theEscape
end if
if pickedSymbols contains "Tab" then
set displaySymbols to displaySymbols & theTab
end if
if pickedSymbols contains "Return" then
set displaySymbols to displaySymbols & theReturn
end if
if pickedSymbols contains "Enter" then
set displaySymbols to displaySymbols & theEnter
end if

tell application "System Events"
tell process frontApp
set the clipboard to displaySymbols
keystroke "v" using {command down}
end tell
end tell
end if

As for the addition in the keyboard/services area, I'm pretty certain I did that right. Any help would be appreciated ...

Fred Weiner



[ Reply to This | # ]
10.6: An Automator Service to enter special characters
Authored by: llee on Feb 17, '11 01:23:54PM
Just wanted to add that the script uses the clipboard.
Also, the hint also provides a quick reference to the symbols and their meanings.
Here's a more complete list.
Edited on Feb 17, '11 01:48:24PM by llee


[ Reply to This | # ]