Phil Hannent
Phil Hannent

Reputation: 12317

Why do some of my keyboard events work and others do not?

I have the following examples in c++, the first works as expected the second does not. I also note that the Windows System keyboard has the same problem. Anybody know why or a work around/better way of doing this?

keybd_event(VK_LWIN,0x5b,0 , 0); /* Windows Key Press */
keybd_event(VkKeyScan('l'), 0, 0, 0); /* L key Press */
keybd_event(VkKeyScan('l'), 0, KEYEVENTF_KEYUP,0); /* L key Release */
keybd_event(VK_LWIN,0x5b,KEYEVENTF_KEYUP,0); /* Windows Key Release */

This one fails:

keybd_event(VK_CONTROL,0x11,0 , 0); /* Control Key Press */
keybd_event(VK_MENU,0xb8, 0, 0); /* Alt Press */
keybd_event(VK_DELETE,0x2e, 0, 0); /* Del Press */

keybd_event(VK_DELETE,0x2e, KEYEVENTF_KEYUP,0); /* Del Release */
keybd_event(VK_MENU,0xb8, KEYEVENTF_KEYUP,0); /* Alt Release */
keybd_event(VK_CONTROL,0x11,KEYEVENTF_KEYUP,0); /* Control Key Release */

Upvotes: 0

Views: 968

Answers (1)

CannibalSmith
CannibalSmith

Reputation: 4820

It's probable that that particular combination is protected by the system. Windows has this feature where you can set so that it asks you to press Crtl+Alt+Del before you can enter your username and password to log in. I remember reading somewhere that that feature is to make sure it's a real person entering the credentials and not a malicious program.

Upvotes: 2

Related Questions