I have done some tests with the emoji panel, and it's very problematic.
First, any change of the system language will cause it to terminate
immediately, so language changes need to be done before launching it.
Second, there is no way to launch it except via the keyboard,
nor to programmatically detect when it runs or when it terminates.
My solution (that works in my environment) is a script that intercepts
Win+; and does the following
(to use Win+. change the line with $#;::
to
$#.::
):
- Conserves the current active window and system language
- Changes the system language to English US
- Issues the key Win+; (not intercepted this time)
- Waits for the previous active window to become active again
(meaning the language panel was terminated)
- Resets the system language to what it was.
The tool I used is the free AutoHotkey.
In the script below, the section between "start debug" and "end debug"
is only for your convenience and should be deleted once everything works.
curlang := 0
; >>>> start debug : function keys for testing
; https://docs.microsoft.com/en-us/previous-versions/ms957130(v=msdn.10)
F7:: SetDefaultKeyboardLang(0x0409) ; english usa
F8:: SetDefaultKeyboardLang(0x040c) ; french
F9:: SetDefaultKeyboardLang(0x0415) ; polish
F12:: ;- show current keyboard language
SetFormat, Integer, H
curlang:= DllCall("user32.dll\GetKeyboardLayout", "UInt", ThreadId, "UInt")
msgbox,Language identifier=%curlang%
curlang := 0
Return
; <<<< end debug
$#;:: ; intercept win+;
WinGet, activewin, ID, A
curlang:= DllCall("user32.dll\GetKeyboardLayout", "UInt", ThreadId, "UInt")
ActiveHwnd := WinExist("A")
SetDefaultKeyboardLang(0x0409) ; english usa
Sleep, 100
Send, {LWin down}`;{LWin up} ; semi-colon needs to be escaped
curlang := 0
SetTimer, waitactive, 200
return
waitactive:
if WinActive("ahk_id" activewin) {
SetDefaultKeyboardLang(curlang)
SetTimer, waitactive, Off
}
return
;-------------------------------
; https://autohotkey.com/boards/viewtopic.php?f=6&t=18519
SetDefaultKeyboardLang(LocaleID){
Static SPI_SETDEFAULTINPUTLANG := 0x005A, SPIF_SENDWININICHANGE := 2
Lan := DllCall("LoadKeyboardLayout", "Str", Format("{:08x}", LocaleID), "Int", 0)
VarSetCapacity(binaryLocaleID, 4, 0)
NumPut(LocaleID, binaryLocaleID)
DllCall("SystemParametersInfo", "UInt", SPI_SETDEFAULTINPUTLANG, "UInt", 0, "UPtr", &binaryLocaleID, "UInt", SPIF_SENDWININICHANGE)
WinGet, windows, List
Loop % windows {
PostMessage 0x50, 0, % Lan, , % "ahk_id " windows%A_Index%
}
}
After installing AutoHotKey, put the above text in a .ahk
file and
double-click it to test. You may stop the script by right-click on
the green H icon in the traybar and choosing Exit. To have it run on login,
place it in the Startup group at
C:\Users\USER-NAME\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup
.
Useful AutoHotkey documentation: