Hey Folks,
Okay, our discussion a while back prompted Shane Stanley to add language-input-switching to his BridgePlus ASObjC-library.
It's now out of beta:
BridgePlus Script Library v1.2.0
-------------------------------------------------------------------------------------------
Installation:
~/Library/Script Libraries/BridgePlus.scptd
-------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------
use framework "Foundation" use script "BridgePlus" load framework
set availableInputSources to (current application's SMSForder's availableInputSourceIDs()) as list set allAvailableInputSources to (current application's SMSForder's allAvailableInputSourceIDs()) as list
-------------------------------------------------------------------------------------------
set langSwitchResult to current application's SMSForder's changeInputSourceTo:"com.apple.keylayout.French" delay 0.1 set langSwitchResult to current application's SMSForder's changeInputSourceTo:"com.apple.keylayout.Russian" delay 0.1 set langSwitchResult to current application's SMSForder's changeInputSourceTo:"com.apple.keylayout.US"
-------------------------------------------------------------------------------------------
langSwitchResult will return true or false depending upon success or failure.
There are some other useful features in that baby too — such as regex match and replace.
-------------------------------------------------------------------------------------------
use framework "Foundation" use bpLib : script "BridgePlus" load framework
set l to {"one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten"} set sortedList to bpLib's sortListOfStrings:l caseSensitive:false
set _str to "Now is the time for all good men to come to the aid of their country." set newStr to bpLib's regexReplace :"\\bmen\\b" withThis :"women" inString :_str
-------------------------------------------------------------------------------------------
Not bad for a 365KB library.
|