How to change the current keyboard layout in PowerShell?

I have two languages ​​installed in the settings of my windows - Czech (by default) and English (for programming). I want to switch between them in powershell.

I generally work in Czech, and this is my default language on my PC. Therefore, whenever I (re) run any application, it starts with a Czech keyboard layout.

But I am programming an English layout. Therefore, I always need to press Alt + Shift when I launch a new programming application - that is, a powershell window.

Is there a way to do this with some command in powershell? Or in C #, perhaps through some kind of win32 api call (since I could make a small cmdlet for myself)?

I found this question (and some others), but I did not really understand it (them) ...

I have never worked with the Win API, so I don’t know what exactly is possible and how to work with it ...

Does anyone have a cmdlet or a small tutorial on how to do this?

+3
source share
2 answers

I found a nice and very simple solution! There is a WASP project on Codeplex. This project allows you to manage windows, send keys to them and send clicks to them.

The solution to my problem is to import the WASP module when powershell starts, then select the powershell window (using WASP) and send it Alt + Shift (using WASP).

powershell profile.ps1, :

Import-Module WASP
Select-Window powershell | Send-Keys "%+" # '%' = ALT key, '+' = SHIFT key
0
-5

All Articles