0

I am writing a program that monitors a pressed key (at any process). I am successfully getting the pressed key, but the only problem is that I get that key at English, even though the pressed key was of another language (lets say Spanish). So, I thought of a solution: create a dictionary of key codes and their Spanish definitions, and identify the keyboard language at the moment of the key press.

Do you think that is a good solution? If so - my problem is that I cannot get the current keyboard language (on my Windows 10 machine). I have tried several ways, like:

1. GetKeyboardLayout

2. CultureInfo

3. InputLanguage
Veve
  • 6,643
  • 5
  • 39
  • 58
albeck
  • 510
  • 1
  • 7
  • 16
  • I don't think you would need to do all that. https://msdn.microsoft.com/library/windows/apps/br206804 I believe the libraries above should help determine the language - it might also help determine the keys without having to do a key-value mapping. – Maertin Jan 26 '16 at 20:28
  • Thanks for your answer, but I couldn't find a working (for Win10) solution. You are correct with the fact that I should be doing key-value mapping, because I have the Key Code, but is there a way? – albeck Jan 26 '16 at 20:35
  • Related: [my function `Get-KeyboardLayoutForPid`](https://stackoverflow.com/a/59038452/3439404) and [`ToUnicodeEx`](https://www.pinvoke.net/default.aspx/user32/ToUnicodeEx.html). – JosefZ Nov 27 '19 at 22:03

0 Answers0