AndyHollywood
Programmer
I am trying to output to the screen and a text file, the outputting to the scren works even if the window is not in focus, but the out put to the text file only works while the window that i output to is in focus?! whats going on?
the information is about the keyboard hook it installs, i need to track the info about the keyboard and save it all in a text file, no matter which application is being used?!
Any ideas?
Cheers in advance
Andy
Code:
LRESULT CALLBACK KeyboardFunc (int nCode, WPARAM wParam, LPARAM lParam )
{
HDC hDC;
//Timer Elements
_ftime( &timebuffer );
timeline = ctime( & ( timebuffer.time ) );
if ( nCode >= 0 ) {
if ( nCode == HC_NOREMOVE )
strcpy(szType, "NOT Removed from Queue");
else
strcpy(szType, "REMOVED from Queue ");
//strcpy(temp, keyType(wParam));
if(pKB) //Output to txt File
fprintf(pKB, "Key:%d,%.19s.%hu %s",wParam,timeline, timebuffer.millitm, &timeline[20] );
wsprintf((LPSTR)szFilterLine[KEYBOARDINDEX],
"KEYBOARD\tKey:%d\t%s",wParam,(LPSTR)szType);
hDC = GetDC(hwndMain);
TabbedTextOut(hDC, 1, nLineHeight * KEYBOARDINDEX,
(LPSTR)szFilterLine[KEYBOARDINDEX],
strlen(szFilterLine[KEYBOARDINDEX]), 0, NULL, 1);
ReleaseDC(hwndMain, hDC);
}
// We looked at the message ... sort of processed it but since we are
// looking we will pass all messages on to CallNextHookEx.
return( CallNextHookEx(hhookHooks[KEYBOARDINDEX], nCode, wParam, lParam));
}
the information is about the keyboard hook it installs, i need to track the info about the keyboard and save it all in a text file, no matter which application is being used?!
Any ideas?
Cheers in advance
Andy