MacOS – Keyboard Viewer via keyboard shortcut wont actually quit after closing it

activity-monitorapplicationskeyboardmacos

I managed to add a shortcut for keyboard viewer via BetterTouchTool. However, once I run Keyboard Viewer and close via the red X button, I cannot re-open it again via a shortcut. So I checked activity monitor and realised that it is actually still there, although I quit the application !

I tried displaying the keyboard viewer via the language selection button on the menu bar and then pressing Show Keyboard Viewer, the keyboard viewer opens every time. Also, I can re-open the application after closing it via a keyboard shortcut ONLY WHEN I open the viewer via the menu button or settings.

  • Why does the application not quit properly when assigned to a keyboard shortcut ?

  • Is there a way to force a specific app to force quit after some idle time ?

rMBP Mountain Lion OSX 10.8

Best Answer

open -a and launch seem to keep it open as well. But if you show the keyboard viewer from the input menu and close the window, the process is quit immediately. So one workaround might be to emulate clicking the menu item:

tell application "System Events" to tell process "SystemUIServer"
    tell (menu bar item 1 where description is "text input") of menu bar 1
        click
        click menu item "Show Keyboard Viewer" of menu 1
    end tell
end tell

Also, I can re-open the application after closing it via a keyboard shortcut ONLY WHEN I open the viewer via the menu button or settings.

If all windows have been closed, activate doesn't usually open a new default window. reopen would do that, but it doesn't seem to work with KeyboardViewer.