Created
October 22, 2019 19:16
-
-
Save M3t0r/a50ea3453aa7740605bf8a08d4e70f2b to your computer and use it in GitHub Desktop.
Toggle macOS input method between two values
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # adapted from https://stackoverflow.com/a/23741934/371128 | |
| tell application "System Events" to tell process "SystemUIServer" | |
| tell (menu bar item 1 of menu bar 1 whose description is "text input") | |
| # !! Sadly, we must *visibly* select (open) the text-input menu-bar extra in order to | |
| # !! populate its menu with the available input sources. | |
| click | |
| tell menu 1 | |
| # I only have two input methods, so selecting the first that isn't active toggles them | |
| click (first menu item whose value of attribute "AXMenuItemMarkChar" is not "✓") | |
| end tell | |
| end tell | |
| end tell |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment