简体   繁体   中英

How to stop pressing a key after using keybd_event?

I a problem using keybd_event function. When I call it to press Ctrl once:

keybd_event(VK_CONTROL,0x9C,0,0);

then if I call it to press X key, it will press Ctrl+X. For example, the next line is:

keybd_event(0x43,0x9C,0,0);  //0x43 is the Virtual-Key Code of 'C' key

So, it will copy the text (Ctrl+C) not type the letter 'C'. Actually, it does not stop pressing Ctrl, even after closing the program. So how can I stop pressing Ctrl key anymore? I have the same problem with Shift key.

Read your own link - keybd_event function has KEYEVENTF_UP flag:

KEYEVENTF_KEYUP 0x0002 If specified, the key is being released. If not specified, the key is being depressed.

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