Sunday, March 25, 2007

How To Get a List of Keyborad Layouts using F-Script

Inject F-Script into System Preferences with F-Script Anywhere. Switch to International ->Input Menu. From FSA menu create a new workspace and then from that workspace open a browser for the list of layouts (that is an object of the NoSelectionTableView class) and name that object and its data source (IntlKeyboardDataSource). In the script below I use the 'tview' and dsrc' names correspondingly.

> str := NSString new.
> 0 to: ((tview numberOfRows) - 1) do:
[ :i | |name|
((dsrc isInputMethodForRow: i) | (dsrc isKeyboardRow: i))
ifTrue:
[ name := dsrc resNameForRow: i.
name ~~ nil ifTrue: [ str := str ++ name ++ '\n' ]]]
>str writeToFile: '/Users/sasha/tmp/Layouts' atomically: false.

No comments: