Originally Posted by
System_159
I did a brief search and couldn't find anything on this. What I'm wanting to do is emulate a keyboard button press. Like, say if the user does something stupid I can make my program hit ctrl+alt+down, or something like that.
I don't know if it's possible, but if it is, I'd like to mess with some friends
You can't inject CTRL+ALT+DEL, because it is checked in a very low-level hook.
Think you might be able to point me in the direction of a list of functions from windows.h/conio.h ? I've been searching, but the only thing I've found was the clear screen function in conio.
Don't use conio. It's not the standard.
But basically you can emulate key presses like this (Windows):
Code:
INPUT ms;
ms.type=INPUT_KEYBOARD;
ms.ki.wVk=0x46;
ms.ki.dwFlags=0;
//'f' key down
SendInput(1,&ms,sizeof(INPUT));
ms.ki.dwFlags=KEYEVENTF_KEYUP;
//'f' key up
SendInput(1,&ms,sizeof(INPUT));
And like this:
Code:
//'f' key down
keybd_event(0x46,0x45,KEYEVENTF_EXTENDEDKEY|0,0);
//'f' key up
keybd_event(0x46,0x45,KEYEVENTF_EXTENDEDKEY|KEYEVENTF_KEYUP,0);