Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I'm stumped as half of it works!!

Status
Not open for further replies.

AndyHollywood

Programmer
Oct 7, 2001
30
GB
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?

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
 
sorry i should have said the code fracment is the keyboard function that output to the screen and file!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top