Skip to content

Instantly share code, notes, and snippets.

@pjrobertson
Created April 25, 2012 10:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pjrobertson/2488900 to your computer and use it in GitHub Desktop.
Save pjrobertson/2488900 to your computer and use it in GitHub Desktop.
Show Character Palette script for OS X
property querylist : {"CharacterPalette"}
property app_is_up : missing value
set app_is_up to false
set frontapp to getFrontApplication()
repeat with i in querylist
set the_ps to paragraphs of (do shell script "/bin/ps -acx")
tid("/")
repeat with _line in the_ps
if _line is "" then
else
if _line contains i then
set app_is_up to true
set _pid to first word of _line
end if
end if
end repeat
tid("")
end repeat
if app_is_up then
tell application "/System/Library/Input Methods/CharacterPalette.app" to quit
else
tell application "/System/Library/Input Methods/CharacterPalette.app" to activate
end if
tell application frontapp to activate
on tid(s)
set my text item delimiters to s
end tid
on getFrontApplication()
(path to frontmost application) as text
end getFrontApplication
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment