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

Toggle Character Palette and Keyboard Viewer on/off Apps
This hint will let you toggle the state of the Character Palette and Keyboard Viewer via AppleScript and a hot key -- activate and hide the panels just by pressing their assigned hot keys. I'll use Proxi for the hot key assignments, but the AppleScripts should work with any such program -- Spark, Keyboard Maestro, Quickeys, Butler, etc. (This hint is similar to this earlier hint, but provides a toggle functionality and works in 10.5.)

Install Proxi, then open the Proxi Editor. Choose Insert Trigger » Hotkey Monitor from the Action menu beneath the Triggers portion of the Proxi Editor window (or drag it in there from the Components window). Replace the selected text (Hotkey Monitor) in the new Trigger with Toggle Character Palette. Click Set in the right half of the Editor window. Press Control-~ (tilde), or the key combination of your choice, to set the trigger's keyboard shortcut.

Choose Insert Task » AppleScript from the Action menu beneath the Tasks portion of the Proxi Editor window. (Double-click AppleScript in the Tasks portion of the window to rename it if you like.) Click Run Custom AppleScript in the right half of the Editor window. Copy and paste the following code into the Run Custom AppleScript text field: Click Check Syntax to be sure the correct script source was pasted. Press the key combination you chose a couple of times to test the functionality. Hide Proxi by holding the Option key and clicking the desktop. Read on for the Keyboard Viewer version.

Follow the same steps as above to create a new Hotkey Monitor trigger in Proxi, name it Toggle Keybaord Viewer, assign a different keyboard shortcut, and set its custom AppleScript code to this: [robg adds: These both worked as described in my testing, using Butler as the vehicle. The original source code for both scripts can be found on the author's site.]
    •    
  • Currently 2.56 / 5
  You rated: 1 / 5 (9 votes cast)
 
[23,027 views]  

Toggle Character Palette and Keyboard Viewer on/off | 17 comments | Create New Account
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: Anonymous on Apr 02, '08 09:31:07AM

What is the advantage over simply sticking the Character Palette and Keyboard Viewer in the menu bar (System Preferences/International/Input Menu)?



[ Reply to This | # ]
Toggle Character Palette and Keyboard Viewer on/off
Authored by: drtofu on Apr 02, '08 10:45:57AM

Because it takes up space. I'd use this script for reference, but my menubar's already cluttered.



[ Reply to This | # ]
Use KeyViewer - MUCH easier & FREE!
Authored by: Ronald Lanham on Apr 02, '08 11:49:14AM
Use KeyViewer
http://www.versiontracker.com/dyn/moreinfo/macosx/23422
It's much easier and free.
Just put it in the Dock or one of your menus so you won't have to clutter up your menubar.

[ Reply to This | # ]
Toggle Character Palette and Keyboard Viewer on/off
Authored by: Stormchild on Apr 02, '08 01:33:22PM

No offense, but this is pretty lame.



[ Reply to This | # ]
Toggle Character Palette and Keyboard Viewer on/off
Authored by: Axlin on Apr 02, '08 02:46:16PM

How is this hint lame? It's awesome. This is handy because:
1. You don't need anything cluttering up your menu bar
2. You can have near-instant access to your character palette and keyboard viewer with a simple, global hotkey
3. Using AppleScript and an trigger app of your choice means no extra wasted sources, such as the KeyViewer program that somebody mentioned that <i>only</i> toggles the keyboard viewer. These apps are much, much more powerful. If you don't make use of them, then that's your loss.

If you guys don't want to utilize this tip, then don't. But don't berate the person that posted it just because you don't understand it.

Great tip, llee.



[ Reply to This | # ]
Or use LaunchBar (or similars)
Authored by: elmimmo on Apr 02, '08 04:07:29PM

You could also add those two items to the custom items list at LaunchBar.

If you are already using a launcher like that, you still accomplish uncluttered desktop + keyboard access.



[ Reply to This | # ]
Or use LaunchBar (or similars)
Authored by: guns on Apr 02, '08 07:58:11PM

Using Quicksilver:

If you've got "Find All Applications" checked in your catalog, Quicksilver already has 'CharPaletteServer.app' and 'KeyboardViewerServer.app' in memory. Just search for those strings + enter.

I love the keyboard viewer especially. Makes learning a new keyboard layout extremely easy.



[ Reply to This | # ]
Toggle Character Palette and Keyboard Viewer on/off
Authored by: Sesquipedalian on Apr 03, '08 06:52:11AM

Quicksilver users can install the Extra Scripts plugin to install, among many other things, two scripts that do this same thing.

Just to save people time and avoid unnecessary duplication.



[ Reply to This | # ]
Toggle Character Palette and Keyboard Viewer on/off
Authored by: guns on Apr 04, '08 02:31:51PM

Unfortunately, the scripts don't work on Leopard (for me). Hence my comment above.



[ Reply to This | # ]
Universal Shortcut is already in 10.5 by default
Authored by: QuarterSwede on Apr 05, '08 08:51:40PM

I'm not sure about the Keyboard Viewer but in at least in 10.5 there is an almost universal keyboard shortcut to view the Character Palette. ⌥⌘T for "Special Characters..."



[ Reply to This | # ]
Toggle Character Palette and Keyboard Viewer on/off
Authored by: encro on Apr 09, '08 08:05:14PM
I wrote these in Cocoa for my own personal use a while back.
They simply launch the relevant app via the bundle identifier and can be run from Spotlight or the Dock.

CharacterPaletteViewer
http://encropowered.com/viewers/CharacterPaletteViewer.zip
5KB

KeyboardViewer
http://encropowered.com/viewers/KeyboardViewer.zip
5KB

There are no icons but if anyone wants to provide some that would be great :)

Steve

---
Steve

[ Reply to This | # ]

Toggle Character Palette and Keyboard Viewer on/off
Authored by: etatoby on Nov 25, '09 03:04:18PM

Here's how to toggle KeyboardViewer in 10.6:

http://github.com/nriley/keyboardViewer



[ Reply to This | # ]
Toggle Character Palette and Keyboard Viewer on/off
Authored by: llee on Jan 28, '10 11:46:45AM
Thanks to etatoby and N. Riley for including a Snow Leopard solution for Keyboard Viewer. Here's a replacement for the Character Palette toggle script that works for Snow Leopard.
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

Edited on Jan 28, '10 11:59:56AM by llee


[ Reply to This | # ]
Toggle Character Palette and Keyboard Viewer on/off
Authored by: llee on Jan 29, '10 09:07:57AM
Well, Rob G. politely enlightened me to the fact that I'm apparently not enough of a desktop publisher to realize that there is a benefit to be derived from making the distinction between dragging those characters in there and clicking the button in Character viewer. I hadn't previously linked the failure of the button to the viewer launching method. I just thought it was a palette scope thing with the app I was using. I actually believe I remember at some point considering whether to submit a bug report that the button in Character viewer doesn't always work. Thanks to Rob for revealing the embarrassing truth.

However, now I'm quite intrigued by the possibility of modifying Nicholas Riley's source for his keyboardViewer executable to make one that provides the same functionality for the Character viewer.

github.com/nriley/keyboardViewer

Maybe Nicholas can be persuaded to release a remedy himself.

[ Reply to This | # ]
Toggle Character Palette and Keyboard Viewer on/off
Authored by: llee on Feb 01, '10 08:30:21AM
What? That didn't work? OK, well here.

[ Reply to This | # ]
Toggle Character Palette and Keyboard Viewer on/off
Authored by: pjrobertson on May 29, '10 02:25:43AM

This works great for me, I've had no problems with it.

It can take a bit of time to load though.

I've set up an applescript that means I can toggle it with a Quicksilver trigger:
Toggle Keyboard Viewer in Snow Leopard with Applescript



[ Reply to This | # ]
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 | # ]