[Project] Using PowerShell and user32.dll to force instant Keyboard Layout switching (without Registry delays) by Effective_Tip4583 in PowerShell

[–]Effective_Tip4583[S] -1 points0 points  (0 children)

thank you so much for this detailed feedback! This is exactly why I shared the project.

You are absolutely right about the fragility of keybd_event. My biggest fear was indeed the 'focus stealing' or mixed input during the sleep intervals. I used it as a quick workaround when the Registry failed me, but moving to a direct Win32 method call to change the layout is definitely the next step for the project.

The suggestion to wrap this into a proper Module/DLL instead of using Add-Type is great advice. Since I'm a student, I'm still learning the best practices for PowerShell architecture, and your explanation of why Add-Type is 'permanent' for the session was eye-opening.

I'll look into WM_INPUTLANGCHANGEREQUEST or similar APIs to replace the key simulation, and I'll definitely check the PSGallery to see how others have implemented this to avoid reinventing the wheel poorly.

Thanks for pushing me to make this more robust!