Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to translate hardware ascii to hardware scan code in win32

Is there a way to translate a character to its corresponding hardware scan code (not the virtual key code)? I need that to communicate with ancient hardware device.

like image 497
Elazar Leibovich Avatar asked Oct 29 '25 10:10

Elazar Leibovich


1 Answers

Seems the most direct method would be to use MapVirtualKey or MapVirtualKeyEx which translates from VK-codes to Scan codes.

The character to VK scan code can be gotten using VkKeyScan (extracting the low byte which contains the VK Code according to MS documentation). So to get the scan code of 'X':

 UINT VKCode=LOBYTE(VkKeyScan('X'));
 UINT ScanCode=MapVirtualKey(VKCode,0);
like image 140
Elemental Avatar answered Oct 31 '25 13:10

Elemental



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!