Hi,
If you have installed "Xcode", here's the solution :
Create a plain text file with this code:
-----------------------------------------
#import <Foundation/Foundation.h>
#import <Carbon/Carbon.h>
int main (int argc, const char *argv[]) {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
BOOL b = NO;
NSString *inputID;
NSMutableString *thisID;
TISInputSourceRef inputSource = NULL;
if (argc < 2) b = YES; else inputID = [NSString stringWithUTF8String:argv[1]];
CFArrayRef availableInputs = TISCreateInputSourceList(NULL, false);
NSUInteger count = CFArrayGetCount(availableInputs);
for (int i = 0; i < count; i++) {
inputSource = (TISInputSourceRef)CFArrayGetValueAtIndex(availableInputs, i);
CFStringRef type = TISGetInputSourceProperty(inputSource, kTISPropertyInputSourceCategory);
if (!CFStringCompare(type, kTISCategoryKeyboardInputSource, 0)) {
thisID = TISGetInputSourceProperty(inputSource, kTISPropertyInputSourceID);
if (b) {
printf("%s\n", [thisID UTF8String]);
} else if ([thisID isEqualToString:inputID]) {
b = YES;
OSStatus err = TISSelectInputSource(inputSource);
if (err) printf("Error %i\n", (int)err);
break;
}
}
}
CFRelease(availableInputs);
if (!b) printf("%s not available\n", thisID);
[pool release];
return 0;
}
-----------------------------------------
Save it in the Desktop with this name "changeInputSource.m" , use the encoding "Unicode (UTF-8)".
In the Terminal copy/paste this text :
cd ~/Desktop; gcc "changeInputSource.m" -o "changeInputSource" -l objc -framework foundation -framework carbon
Press the Return Key.
Move the executable file "changeInputSource" in the Applications folder or a folder of your choice.
This executable uses the Input Source identifier instead of the name.
script AppleScript examples :
To get these identifier.
-----------------------------------------
-- get all available Keyboard input source ID
set executablePath to quoted form of "/Applications/changeInputSource"
do shell scriptexecutablePath
-----------------------------------------
Change the Keyboard Input Source to "US"
-----------------------------------------
set executablePath to quoted form of "/Applications/changeInputSource"
set inputSourceID to "com.apple.keylayout.US"
do shell scriptexecutablePath&" "&inputSourceID
-----------------------------------------
Change the Keyboard Input Source to "Wubi Xing"
-----------------------------------------
set executablePath to quoted form of "/Applications/changeInputSource"
set inputSourceID to "com.apple.inputmethod.SCIM.WBX"
do shell scriptexecutablePath&" "&inputSourceID
-----------------------------------------
If you don't have Xcode, I can give you the link to download this executable.