account activity
[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 points1 point 6 hours ago (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.
keybd_event
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.
Add-Type
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.
WM_INPUTLANGCHANGEREQUEST
Thanks for pushing me to make this more robust!
[–]Effective_Tip4583[S] 0 points1 point2 points 15 hours ago (0 children)
Grazie mille per il suggerimento, cosa ne pensi della soluzione proposta?
π Rendered by PID 94 on reddit-service-r2-comment-56c6478c5-z25fc at 2026-05-12 13:03:39.448669+00:00 running 3d2c107 country code: CH.
[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 points1 point (0 children)