valinet / ExplorerPatcher

This project aims to enhance the working environment on Windows
GNU General Public License v2.0
24.75k stars 1.05k forks source link

When using Simple Window Switcher, an ENG input method will appear in the taskbar #1347

Open bgycn opened 1 year ago

bgycn commented 1 year ago

When using Simple Window Switcher, an ENG input method will appear in the taskbar, and this input method cannot be deleted. Note that this problem will only occur if you log out of Windows and log in again.

image

valinet commented 1 year ago

Does it happen repeatedly? Windows has this habit, under certain conditions, to add the default keyboard layout from the default user profile, which is usually "English (US)", unless you changed it, to your language list. Indeed, it cannot be removed from Windows Settings, since it doesn't show up in the list of installed keyboard. To remove it, add it to the list from in there, then remove it.

So, if you do this, and fix it, having only your keyboard, then restart File Explorer, use the computer for a while, and eventually log out and back in or restart, does it reappear again?

Do you connect via Remote Desktop by any chance? One of the conditions under which Windows employs the behavior I described in the first paragraph is when you remote into your machine. The behavior is described here: https://learn.microsoft.com/en-us/troubleshoot/windows-server/application-management/regional-and-language-options-settings

To disable this behavior, merge the following in the registry:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout]
"IgnoreRemoteKeyboardLayout"=dword:00000001

Simple Window Switcher indeed subscribes to keyboard change notifications, in order to be able to correctly map the Alt+key above Tab combination. Windows only allows registering hot keys using virtual key codes. Virtual key codes are virtual, which means their physical positions can change, deepening on the keyboard layout used. This is usually fine, but in sws' case, it needs to find out the virtual key code for the key located above Tab for whatever keyboard layout the user is using, and then register a hot key with that, in order to provide consistent functionality. This change in registration has to occur every time the user switches languages, so it has to subscribe to some facility that notifies regarding this. I don't remember how I got to it, but there's basically no public API for such notifications, so the functionality was implemented using undocumented APIs that I found explorer to be using based on its disassembly.

The issue is described here: https://github.com/valinet/ExplorerPatcher/issues/283 The implementation is here: https://github.com/valinet/sws/commit/a293c851987c5323438c48c1eb1731f092089c84

bgycn commented 1 year ago

This problem will definitely occur whenever you use Simple Window Switcher, restart your computer or log out and back in again. I've tried adding "English (US)" and removing it, but it doesn't work.

foriequal0 commented 5 months ago

The problem happens to me several times daily, even during seemingly normal sessions.

I didn't restart, log out, or connect RDP to it. It suddenly changed to ENG especially when there was a short idle time. Like lifting the hand from the keyboard, grabbing the mouse, focusing on other windows, scrolling another pane, staring at the wall, taking a sip of coffee, getting back to the context, and suddenly the keyboard layout has been changed, thinking I'm delusional or not... It happened once while I was writing this comment.

I don't have an English language pack installed on this system, but there is an English keyboard layout. The other system is the laptop, which has an English language pack. It doesn't seem to change the symptom rate. Re-opening the lid a long time after closing the lid doesn't reliably reproduce the bug. Rebooting the laptop seems to reproduce the bug reliably. Restarting the explorer through ExplorePatcher doesn't seem to reproduce the bug reliably.

edit: OS: Windows 11 Pro, 23H2, 22631.3880, Korean

chang7e commented 4 months ago

Could you please confirm if this issue has been resolved? I've tried uninstalling and reinstalling several times, but whenever I install ExplorerPatcher, an additional "eng keyboard" appears and cannot be removed. I've exhausted all methods to delete it, and this has been quite troublesome for my regular use.

pyrates999 commented 4 months ago

It would help for anyone this happens to, to include if it's windows 10 or 11 and if it's a non-english version of windows or not. If it's a non-english version of windows, what language was your windows that you installed?

chang7e commented 3 months ago

language is chinese

foriequal0 commented 2 months ago

Simple Window Switcher indeed subscribes to keyboard change notifications, in order to be able to correctly map the Alt+key above Tab combination.

Some keyboards have a different virtual code other than OEM_3 for a key over the tab key, but some others have the same VK_OEM_3 for the key. http://kbdlayout.info/00000410/shortcut/29+38 How about providing an option that disables the dynamic shortcut register?

Or LowLevelKeyboardHook might be used to get a scan code https://learn.microsoft.com/en-us/previous-versions/windows/desktop/legacy/ms644985(v=vs.85)

It seems that PowerToys is migrating to that from RegisterHotKeys https://github.com/microsoft/PowerToys/blob/f8269af125deeb21d5d520a7976bf011bd762e2b/src/runner/centralized_kb_hook.cpp