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


Click here to return to the 'Toggle Character Palette and Keyboard Viewer on/off' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Toggle Character Palette and Keyboard Viewer on/off
Authored by: joelreid on Nov 11, '10 06:43:34AM
Applescript is slow, so I threw together this (written for bash) one-liner which toggles the Keyboard Viewer and uses applescript only to close the viewer nicely. Note the path in there if you use this... I keep keyboardViewer in ~/bin so tweak to suit.

if [ "$(ps axxo command | grep -c '[K]eyboardViewer')" -gt 0 ]; then osascript -e 'tell application "System Events" to click ((buttons whose subrole is "AXCloseButton") of window 1) of process "Keyboard Viewer"'; else ~/bin/keyboardViewer; fi;

[ Reply to This | # ]