Applescript for multiple keyboards

I dont know if this is the best place to start for a Script Noobie but here go, I am running Two keyboards one is a English (primary) and the other French both are Bluetoooth so each has its own Device ID what I would like to do is set up a script that sense’s which keyboard is pressed and switches to the appropriate input language as Cmd Space means I have to look up to check the current language and clicking the flag is a pain when shifting for a couple of special French Characters. Is this in the realms of possible.? Im new to scripting but dont mind putting the time in to learn as I suspect it will help me understand how these machines work.

Cheers

Ka

Model: Mac Pro, MBP, iMac
Browser: Firefox 2.0.0.16
Operating System: Mac OS X (10.5)

Welcome. I hope someone will be able to help, but most of us don’t have two keyboards to try this on.

This script will tell you your keyboard layout name:

set myPrefs to POSIX path of (path to preferences folder from user domain as text)
set MAC to primary Ethernet address of (get system info)
set tid to AppleScript's text item delimiters
set AppleScript's text item delimiters to ":"
set MAC to (text items of MAC)
set AppleScript's text item delimiters to tid
set MAC to MAC as text

set L to paragraph -2 of (do shell script "defaults read " & myPrefs & "ByHost/com.apple.HIToolbox." & MAC & " | grep -A 4 AppleCurrentAsciiInputSource")

Hi Ka,

There are two ways that I am familiar with to change the input source. One is with AppleScript, see this post ‘http://bbs.macscripter.net/viewtopic.php?pid=70174’, and the other is with Objective-C.

Either way requires some method to fire the script. The bluetooth API is where you will need to start and since you will need to verse yourself in Obj-C I would suggest using that method as well to change the input.

Regards,

Craig

Thanks both, I am going to pursue this as It struck me as something that could be done.

Ka,

Here is the code I use on Leopard to change the input between English and Hebrew.
If you are on Tiger look up NSInputManager and check out this thread
http://www.cocoabuilder.com/archive/message/cocoa/2007/11/8/192549

Post back once you get it working. I am sure others would like to know how it is
accomplished. :slight_smile:

Good luck!

Craig

Thanks very much going to follow this up…