Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

Is there a way that, when you switch language inputs for your keyboard, the onscreen keyboard will automatically show up?

share|improve this question
add comment

1 Answer

I asume you want to show an onscreen keyboard when changing your keyboard layout. One obvious approach is to use AppleScript, and that is what I've done here. I think this approach is not error prone, but it works.

At first, in the Systems preferences select the keyboards you want to use, and make sure you tick 'Show Input in menu bar' System Preferences -> Keyboard -> Input Sources

Then check if your languages are available in the 'Input menu' in the top right corner of your menu-bar.

Keyboard input source name

So, now the keyboards are available from the menubar. We can use applescript to invoke with the menubar and start your onscreen keyboard.

(* A function to change the language and activate the keyboard app *)
on changeKeyboardLayout(layoutName)
    (* Close the current language keyboard app *)
    tell application "KeyboardViewer"
        quit
    end tell
    (* Change the keyboard layout *)
    tell application "System Events" to tell process "SystemUIServer"
        tell (menu bar item 1 of menu bar 1 where description is "text input")
            click
            click menu item layoutName of menu 1
        end tell
    end tell
    (* Open the new language keyboard app *)
    tell application "KeyboardViewer"
        activate
    end tell
end changeKeyboardLayout

(* Call the function with the keyboard name as variable *)
changeKeyboardLayout("U.S. Extended")
(* changeKeyboardLayout("Canadian English") *)
(* changeKeyboardLayout("U.S.") *)

You can use Automator to make an Application or a Service of this AppleScript and and even attach a keystroke to it.

share|improve this answer
    
I am not an AppleScript guru, please improve when possible. –  CousinCocaine Sep 9 '13 at 9:17
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.