I have several macros with AppleScripts changing the Input Source as I open certain apps.
It works like a charm, but I would like the script to check if the Input Source in question is already in use, and in that case do nothing.
See below the script Iām using at the moment.
Any thoughts?
Thanks,
Hakan
on changeKeyboardLayout(layoutName)
tell application "System Events" to tell process "SystemUIServer"
tell (1st menu bar item of menu bar 1 whose description is "text input") to {click, click (menu 1's menu item layoutName)}
end tell
end changeKeyboardLayout
changeKeyboardLayout("U.S.")
Thanks a lot Chris, but the script in the link does the same thing as the one I already use.
I want the script to do nothing at all if the Input Source in question is already in use.
------------------------------------------------------------
use framework "Foundation"
use script "BridgePlus"
load framework
use scripting additions
set currentLayout to current application's SMSForder's currentKeyboardInputSourceID as text
if currentLayout is not "com.apple.keylayout.US" then
set langSwitchResult to current application's SMSForder's changeInputSourceTo:"com.apple.keylayout.US"
else
# Comment-out the beep to make the script do nothing if nothing is to be changed.
beep
end if
------------------------------------------------------------
You can get a list of the available input IDs by running this:
------------------------------------------------------------
use framework "Foundation"
use script "BridgePlus"
load framework
use scripting additions
set currentLayout to current application's SMSForder's availableInputSourceIDs as list
------------------------------------------------------------
I saw that post when I searched before I posted myself, but I donāt have that action.
Iām on KM 6.4.8 since Iām still on Mavericks, if that has anything to do with it.