0

I am trying to create a DLL for a Unipaas app. And I need to create a function which will find out which language is set for keyboard and if needed change that language to next one.

here is what i need to find out

I have been looking on many possible solutions but most of them are using Win Forms or WPF:

InputLanguageManager.Current.CurrentInputLanguage

This doesnt work for me because I am not creating any form. I do just call a function.

I did try this:

int language = Thread.CurrentThread.CurrentCulture.KeyboardLayoutId;

but it will give me system language and not keyboard language. There were some other solutions but they were hard for me to understand and implement.

Like here: Change keyboard layout from C# code with .NET 4.5.2

I know that there is GetKeyboardLayout function (winuser.h) in order to retrieve the current keyboard language. However I am still confused on how it works.

Markus
  • 5,976
  • 5
  • 6
  • 21
  • 1
    What if 2 programs decided to change they keyboard to different layouts at the same time? It should be up to the user to change THEIR keyboard to whatever THEY choose. Programs shouldn't be changing the way a users UI is configured. – Neil Oct 27 '22 at 12:53
  • Well i know this issue but that should not happen in my instance.. unfortunately i have to find out how to do it because i dont have any other option :/ for now its handled by Delphi(Pascal) DLL but i need to do it in c# – Michael Hluchník Oct 31 '22 at 09:16

0 Answers0