Original Post
Hi, I'm writing a program which grabs what your type on one computer, and types it on another. I have most of this program done, but I'm having trouble simulating key presses correctly. In this sample code I'm trying to hold the spacebar down for 10 seconds. But, what actually happens is the spacebar is being pressed and immediately released. Am I using keybd_event incorrectly? Is there some other function I can use to hold a key down for N seconds? My program MUST work on Windows 98, so I can't use SendInput. Thanks. -Caeddyn
#include <iostream>
#include <windows.h>
using namespace std;
int main()
{
Sleep(5000);
keybd_event(VK_SPACE, MapVirtualKey(VK_SPACE, 0), 0, 0);
Sleep(10000);
keybd_event(VK_SPACE, MapVirtualKey(VK_SPACE, 0), KEYEVENTF_KEYUP, 0);
return 0;
}