简体   繁体   中英

Finding possible key combination of a char regarding current keyboard layout

How can I find a possible key combination of a char regarding to current keyboard layout

for example;

lets say my keyboard's caps lock is off So in that case for char "A" key combination should be Shift + A

that was easy. how about non ascii chars or non visible chars on keyboard such as "@" char or "\\"

for "@" I use Ctrl + Alt + Q
for "\" I use Ctrl + Alt + *
for "{" I use Ctrl + Alt + 7

So how could I know which key combination should I send to an application to make it handle "{" key assuming that application validates that combination to determine if I am bot or human.

Thanks in advance

In Windows you can use VkKeyScan(char ch) function. It returns a short value which contains the virtual key code on low-order byte and modifier key flags on high-order byte.

You can call it in C# by declaring:

[DllImport("user32.dll", CharSet = CharSet.Unicode)]
static extern short VkKeyScan(char ch);

Here is the link to the documentation:

https://msdn.microsoft.com/en-us/library/windows/desktop/ms646329%28v=vs.85%29.aspx

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM