I use click menu script as a temporary solution.
I have Bartender's AppleScript support to simulate menu bar item click.
Here is a sample script:
changeKeyboardLayout("Squirrel - Simplified")
on changeKeyboardLayout(layoutName)
tell application "Bartender 4"
activate "com.apple.TextInputMenuAgent-Item-0"
end tell
tell application "System Events"
tell process "TextInputMenuAgent"
click menu item layoutName of menu 1 of menu bar item 1 of menu bar 2
end tell
end tell
end changeKeyboardLayout
In the above code, Squirrel - Simplified
is the name of the target input method. See below:
The problem is that if the current window is Alfred
search window, then Alfred
will be deactivated. There is another post to discuss about a solution for this issue.