Wednesday, December 12, 2018

#1 2009-11-04 03:44:06 am

guychi
Member
Registered: 2007-08-09
Posts: 14

How to change the input language text input menu on Snow Leopard ?

hello
I can't seem to find a working solution for changing the input language on snow leopard.
Any suggestions how we can switch between e.g. English and Hebrew using AppleScript?
Thanks!

Offline

 

#2 2009-11-04 08:53:40 am

Craig Williams
Administrator
From:: Ft. Smith, AR
Registered: 2006-12-07
Posts: 888

Re: How to change the input language text input menu on Snow Leopard ?

Check out this post. I wrote it awhile back when I was attempting to learn Hebrew.

Let me know if you need a compiled version.

Craig

Offline

 

#3 2009-11-04 09:01:52 am

StefanK
Member
From:: St. Gallen, Switzerland
Registered: 2006-10-21
Posts: 11526
Website

Re: How to change the input language text input menu on Snow Leopard ?

An AppleScript solution, which works at least in Leopard

Applescript:


changeInputLanguage("Hebrew")
changeInputLanguage("U.S.")

on changeInputLanguage(L)
   tell application "System Events" to tell process "SystemUIServer"
       tell (1st menu bar item of menu bar 1 whose value of attribute "AXDescription" is "text input")
           return {its value, click, click menu 1's menu item L}
       end tell
   end tell
end changeInputLanguage


regards

Stefan


Filed under: System

Offline

 

#4 2009-11-04 09:21:50 am

Craig Williams
Administrator
From:: Ft. Smith, AR
Registered: 2006-12-07
Posts: 888

Re: How to change the input language text input menu on Snow Leopard ?

Thanks Stefan,

I updated my post to reflect this option as well.

Craig

Offline

 

#5 2009-11-04 10:34:17 am

StefanK
Member
From:: St. Gallen, Switzerland
Registered: 2006-10-21
Posts: 11526
Website

Re: How to change the input language text input menu on Snow Leopard ?

Thanks, Craig, but the Obj-C version is indeed more sophisticated wink


regards

Stefan

Offline

 

#6 2009-11-04 04:04:03 pm

Oliver M
Member
Registered: 2009-06-25
Posts: 11

Re: How to change the input language text input menu on Snow Leopard ?

Craig Williams wrote:

Check out this post. I wrote it awhile back when I was attempting to learn Hebrew.

Let me know if you need a compiled version.


I'd like a compiled version and/or steps on how to compile it myself, please. I use german and english as languages.

Offline

 

#7 2009-11-04 11:03:56 pm

Craig Williams
Administrator
From:: Ft. Smith, AR
Registered: 2006-12-07
Posts: 888

Re: How to change the input language text input menu on Snow Leopard ?

Hi Oliver,

I have updated my post to show the Terminal command required to compile the utility. I have also added a version, contributed by Stefan, that changes the input based on name. This is very useful if you want to check to see if an input is available or if you have several languages to switch between. Many thanks to Stefan for his contribution!

Regards,

Craig

Offline

 

#8 2009-11-05 02:21:51 am

Oliver M
Member
Registered: 2009-06-25
Posts: 11

Re: How to change the input language text input menu on Snow Leopard ?

Thanks but this is not working at all, the explanation is a little confusing, too.
You wrote:

Make a folder on your desktop and name it ‘input.’


Shouldn't it be 'input' without a dot?
Then I tried to use Stefan's alternative but where does this go:

USE:
    changeInput languageName

Example:
    changeInput U.S.
    changeInput Hebrew


???

When I type the terminal command i get a "-bash: gcc: command not found".
Thanks anyway.

Offline

 

#9 2009-11-05 02:42:56 am

StefanK
Member
From:: St. Gallen, Switzerland
Registered: 2006-10-21
Posts: 11526
Website

Re: How to change the input language text input menu on Snow Leopard ?

You can download a compiled version here (minimum requirement 10.5)

put the executable anywhere and use it in Terminal app
[code]/path/to/changeInput U.S.[/code]
or in AppleScript

Applescript:


do shell script "/path/to/changeInput U.S."

/path/to/changeInput is the full path to the executable. If there are space characters in the path, quote it or escape the spaces


regards

Stefan

Offline

 

#10 2009-11-05 02:50:48 am

Oliver M
Member
Registered: 2009-06-25
Posts: 11

Re: How to change the input language text input menu on Snow Leopard ?

You rock Stefan, works flawlessly. Thanks a ton! :-)


Oliver

Offline

 

#11 2009-11-05 03:46:53 am

Oliver M
Member
Registered: 2009-06-25
Posts: 11

Re: How to change the input language text input menu on Snow Leopard ?

If I'd like to toggle two languages, say "German" and "U.S.", how would the AppleScript part look like?

E.G. if current language is "German" then do shell script "/path/to/changeInput U.S.",
if language is "U.S." do shell script "/path/to/changeInput German",
else do nothing.

Offline

 

#12 2009-11-05 06:12:36 am

StefanK
Member
From:: St. Gallen, Switzerland
Registered: 2006-10-21
Posts: 11526
Website

Re: How to change the input language text input menu on Snow Leopard ?

Here is an extended version.
the syntax

Applescript:

do shell script "/path/to/changeInput toggle U.S. German"

toggles between the two arguments


regards

Stefan

Offline

 

#13 2009-11-05 06:30:59 am

Oliver M
Member
Registered: 2009-06-25
Posts: 11

Re: How to change the input language text input menu on Snow Leopard ?

Great Stefan, thx again. ;-)

Offline

 

#14 2009-11-05 09:26:09 am

Craig Williams
Administrator
From:: Ft. Smith, AR
Registered: 2006-12-07
Posts: 888

Re: How to change the input language text input menu on Snow Leopard ?

Oliver M wrote:

Thanks but this is not working at all, the explanation is a little confusing, too.
You wrote:

Make a folder on your desktop and name it ‘input.’


Shouldn't it be 'input' without a dot?


No, the dot should not be in the name of the folder. That is the correct way to end a
sentence in English though. I will take it out on the post since it does cause confusion.

Offline

 

#15 2009-11-05 09:50:48 am

Oliver M
Member
Registered: 2009-06-25
Posts: 11

Re: How to change the input language text input menu on Snow Leopard ?

Craig,

it is not like I haven't tested it both ways but due to the lack of my knowledge I couldn't get it to work anyway. Sorry if I came across a little harsh, it wasn't my intention.

BTW, even though English isn't my native tongue I was under the impression that a sentence always ends with a dot instead of a quotation mark. We always learn as it seems. ;-)

Offline

 

#16 2009-11-05 10:05:04 am

Craig Williams
Administrator
From:: Ft. Smith, AR
Registered: 2006-12-07
Posts: 888

Re: How to change the input language text input menu on Snow Leopard ?

Hi Oliver,

I didn't take your post as harsh at all. If what I wrote does not make sense, I benefit from knowing that. smile
I apologize if I come across harsh in my post. That was not my intention.

I have never been that good with English so you are probably correct. Either way, it is confusing
when it comes to code so I will leave that off from now on. Also, Stefan has provided me with his
latest improvements so I am updating the post with it. His is a very nice and user friendly solution.

I will also post a binary for downloading and rewrite the terminal command to try and make it more
clear on what it is doing. A little more explanation should help.

Thank you for your input!

Cheers,

Craig

Offline

 

#17 2009-11-05 11:12:01 am

Oliver M
Member
Registered: 2009-06-25
Posts: 11

Re: How to change the input language text input menu on Snow Leopard ?

Hi Craig,

no worries. I owe you both. ;-)


Oliver

Offline

 

#18 2010-03-23 05:33:38 pm

lv217m
Member
Registered: 2010-03-23
Posts: 1

Re: How to change the input language text input menu on Snow Leopard ?

I need to change the input to Chinese but all the input names have two words for example "Pinyin - Simplified", "Wubi Xing", "Wubi Hua". How can I get this to work?

SOLVED: Ok, nevermind. This was a PHP thing. I needed to run Apache as a "User" (not WWW) to allow PHP run the shell command. This did the trick: system('/changeInput "Pinyin - Simplified"');

Last edited by lv217m (2010-03-23 06:39:56 pm)

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)