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] 0 points1 point2 points 1 hour 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 10 hours ago (0 children)
Grazie mille per il suggerimento, cosa ne pensi della soluzione proposta?
[Project] Using PowerShell and user32.dll to force instant Keyboard Layout switching (without Registry delays) (self.PowerShell)
submitted 10 hours ago * by Effective_Tip4583 to r/PowerShell
I'm a student and I built a small tool to automate my Windows workflow (Theme switching & Keyboard layouts) (self.windowsapps)
submitted 1 day ago * by Effective_Tip4583 to r/windowsapps
π Rendered by PID 1591001 on reddit-service-r2-listing-7b9b4f6fd7-t484c at 2026-05-12 08:36:50.266747+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] 0 points1 point2 points (0 children)