Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Programmatically switch an input method on Mavericks

Hello,



I'm having a problem creating a program that switches an input method to a specified one. I have been doing some research for a while and have found this answer on the support community, but it doesn't seem to work on Mavericks: https://discussions.apple.com/thread/4032238?answerId=18719398022#18719398022. The indicator switches normally but it doesn't enable the IM (adding TISEnableInputMethod doesn't help). The IM gets enabled only when I switch out of the document and then back in.



The question on stackoverflow doesn't get any answers too: http://stackoverflow.com/questions/22885767/how-to-programmatically-switch-an-in put-method-on-os-x



Did I hit a bug in the OS or is it something that I'm missing?

OS X Mavericks (10.9.2)

Posted on Apr 18, 2014 10:07 PM

Reply
5 replies

Apr 19, 2014 3:22 AM in response to Hiroto

Hello, Hiroto,


Thank you for your answer.



1. I am currently using the Applescript method, but it's quite slow compared to the native one.

2. The code in the latter discussion doesn't work in Mavericks (it does switch, but the IM doesn't fire up).


What I basically want to achieve is this:


1. I am using primarily English and Russian languages in my day-to-day work.

2. I am learning Japanese and want to use Hiragana and Katakana easily so I made Applescripts to switch to these methods and assigned keyboard shortcuts to run them.

3. Then I created a shortcut to switch back to the English/Russian scheme and it's way faster because I don't need to fire up any menus in process.

4. So I generally want to achieve the switch to Japanese in the native way 🙂

Apr 19, 2014 3:38 AM in response to riarheos

Hello


In order to select "Hiragana" text input source in "Kotoeri" module, you'd need to first enable Kotoeri and then select Hiragana. Something like this (provided the textinputsource executable is in the current direcory):


#!/bin/bash
./textinputsource -e "Kotoeri" -s "Hiragana"


Similarly, in order to select "Pinyin - Simplified" text input source in "Chinese - Simplified" module, use the utility like this:


#!/bin/bash
./textinputsource -e "Chinese - Simplified" -s "Pinyin - Simplified"


For those text input sources which are not nested in module, you may simply select it like this:


#!/bin/bash
./textinputsource  -s "Dvorak"


Tested under 10.6.8. Don't know about 10.9.


Good luck,

H

Programmatically switch an input method on Mavericks

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.