I'm using the following AHK script to switch keyboard layouts with Caps Lock in Windows 10:
WM_INPUTLANGCHANGEREQUEST := 0x50
INPUTLANGCHANGE_FORWARD := 0x0002
HKL_NEXT := 1
PostMessage, WM_INPUTLANGCHANGEREQUEST, INPUTLANGCHANGE_FORWARD, HKL_NEXT, , A
It works well for normal windows. However if any modal dialog box is on the screen, like Save As, or a search dialog in Notepad++, the layout switch stops working. I assume this is because the "A" window selector does not select the dialog but the main app window and the message gets ignored. Is there any way to fix this?