简体   繁体   中英

C++ sends virtual key with WM_KEYDOWN on keybd_event()

I would like my program to send this third party virtual key VK_ALOGIN or 0xf7 with WM_KEYDOWN.

So I try the following:

keybd_event(0xf7, 0, 0, 0);

But the program that receives this keyboard message, it receives only VK_ALOGIN, and not with WM_KEYDOWN. So is it possible that I can send 0xf7 with WM_KEYDOWN?

Please note that VK_ALOGIN is not Microsoft Virtual Key.

Receiver might be looking for keydown, as well as key up. Try sending both.

keybd_event( VK_ALOGIN, 0, 0, 0 );
keybd_event( VK_ALOGIN, 0, KEYEVENTF_KEYUP, 0 );

or

keybd_event( VK_ALOGIN, 0, KEYEVENTF_EXTENDEDKEY, 0 );
keybd_event( VK_ALOGIN, 0, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0 );

Edit: I deleted reference to SendInput because now I think it has nothing to do with the question, and I am not sure if I got SendInput right.

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