Toggle Keyboard Viewer in Snow Leopard 10.6

December 10th, 2009 § 2 comments

Ever since upgrading to Snow Leopard, one function I’ve missed is the ability to toggle the Keyboard Viewer on and off with an applescript.
It looks like Apple modified the Keyboard Viewer utility for Mac OS X 10.6 (or a possible tablet, who knows…) and the old applescripts don’t work.

I’ve finally come across a method for getting this to work in Snow Leopard again, although it’s not as easy as it was in Leopard, and it seems to be as slow as hell to open.

Check out Nicholas Riley’s tiny app (only 6 lines of custom code!) that fixes this:
http://github.com/nriley/keyboardViewer (download)

Once that’s downloaded and installed (you need to go into terminal and move it, or just navigate to /usr/local/bin/ and paste it there), you can then use the applescript listed on the App’s homepage to get it working in applescript.

tell application "System Events"
if exists (process "Keyboard Viewer") then
click process "Keyboard Viewer"'s window 1's buttons whose subrole is "AXCloseButton"
else
do shell script "/usr/local/bin/keyboardViewer"
end if
end tell

I have modified this slightly, as the ‘click process’ part of the applescript uses a deprecated method (Apple’s own fault) and could become obsolete at any point. I just used a simple killall command in its place


tell application "System Events"
if exists (process "Keyboard Viewer") then
do shell script "killall KeyboardViewer"
else
do shell script "/usr/local/bin/keyboardViewer"
end if
end tell

And now, my trusty Cmd + Optn + Ctrl + K Quicksilver trigger is back!

Tagged applescript, mac, os x, quicksilver, script, snow leopard

§ 2 Responses to Toggle Keyboard Viewer in Snow Leopard 10.6"

  • peyrviv says:
    August 1, 2010 at 6:21 pm

    Yeah, thanks! But the “toggle off” part doesn’t work for me.Any idea why can that be?

  • Gnarlodious says:
    April 14, 2010 at 4:20 pm

    Thanks! Pretty cool.

    Wonder why you can’t just launch keyboardViewer.app from an Applescript anymore.

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

*

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

What's this?

You are currently reading Toggle Keyboard Viewer in Snow Leopard 10.6 at Web Design.

meta

  • Author: Patrick
  • Comments: 2 Comments
  • Categories: Mac OS X

  • Pages

    • About Patrick Robertson
    • Bits & Bobs
    • Designing the World
    • Tags
    • Websites
  • Categories

    • Apps (5)
    • Holidays (1)
    • Mac OS X (8)
    • SEO (2)
    • Uncategorized (1)
    • Web Design (4)

© Patrick Robertson 2012

Powered by WordPress