KTS_SRC: Easy key params for the host
//Use enter key to start new sequence
#include <windows.h>
#include <stdio.h>
int main(int argc, char* argv[])
{
HANDLE hConIn = CreateFile(
"CONIN$"
, GENERIC_READ | GENERIC_WRITE
, FILE_SHARE_READ, NULL, OPEN_EXISTING
, FILE_ATTRIBUTE_NORMAL
, 0);
DWORD dwTmp;
INPUT_RECORD ir = {0};
char buff[1000] = {0};
char buff1[1000] = {0};
while( 1 )
{
WaitForSingleObject( hConIn, INFINITE );
ReadConsoleInputW( hConIn, &ir, 1, &dwTmp);
if( ir.EventType == KEY_EVENT )
{
sprintf( buff, "%X %X %X %X %X"
, ir.Event.KeyEvent.bKeyDown
, ir.Event.KeyEvent.dwControlKeyState
, ir.Event.KeyEvent.uChar.UnicodeChar
, ir.Event.KeyEvent.wRepeatCount
, ir.Event.KeyEvent.wVirtualKeyCode);
if( strcmp( buff, buff1 ) == 0 ) continue;
if( strcmp( buff, "1 0 D 1 D" ) == 0 )
{
printf( "\nFFFFFFFF " );
continue;
}
if( strcmp( buff, "0 0 D 1 D" ) == 0 )
{
continue;
}
if( strcmp( buff, "1 80 D 1 D" ) == 0 )
{
printf( "\nFFFFFFFF " );
continue;
}
if( strcmp( buff, "0 80 D 1 D" ) == 0 )
{
continue;
}
strcpy( buff1, buff );
printf( "%s ", buff );
}
}
}
Thursday, January 01, 2009