Hey zeltak,
Sorry for the DIY instructions with the bad AppleScript. If you're still needing a solution, here's a fully assembled macro to try out, arriving late as it is.
If you've moved on, I understand completely.
This macro launches a conflict palette and toggles the keyboard to the language that matches the conflict palette's expected input. When the palette closes, it toggles the input language back to the previous keyboard.
The download comes with 3 macros.
- "A Macro" (triggered by F7)
- "B Macro" (triggered by F7)
- "Toggle keyboard layout for conflict palette" is the controller macro. (triggered by F8)
The first 2 make up the test conflict palette.
THe third controls the launch of the conflict palette, toggles the keyboard to the input layout that works with 2 and 3, and when the conflict palette closes, toggles the keyboard back to the previous keyboard.
To run the test:
- Make sure the English U.S. keyboard layout is installed on your Mac.
- Set your input keyboard to a keyboard layout that is not U.S. English.
Press F8. - A conflict palette with A Macro and B Macro will appear and the keyboard will switch to U.S. English.
- Type a to play the Submarine sound. b plays the Blow sound. Typing escape closes the palette. In any case, you should see the keyboard switch back to previous keyboard.
To customize the macro's hotkeys, the hotkeys that launch the conflict palette, and the keyboard that get toggled, refer to the instructions included in the second, yellow comment,"Settings Instructions”, of the macro named, "Toggle keyboard layout for conflict palette"
Credits:
@Nige_S For taking the time to show me the correct and only way to trigger the conflict palette.
@ComplexPoint For the sine qua non jxa script that accomplishes what AppleScript cannot: retrieve the keyboard id.
Launch conflict palette and toggle keyboard.kmmacros (18.2 KB)