My code is far too large to post, however the relivant function goes like this:
Code:
LRESULT CALLBACK KeyboardFunc (int nCode, WPARAM wParam, LPARAM lParam )
{
HDC hDC;
HWND hwndTopWindow;
int iError;
TCHAR szBuffer[20];
int x;
int i = 0 ;
x = wParam;
if ( nCode >= 0 ) {
if ( nCode == HC_NOREMOVE )
strcpy(szType, "NOT Removed from Queue");
else
strcpy(szType, "REMOVED from Queue ");
wsprintf((LPSTR)szFilterLine[KEYBOARDINDEX],
"KEYBOARD\tKey:%d\t%s",wParam,(LPSTR)szType);
if(x==commandkey&&!executing)
{
executing = 1;
executions++;
if(executions%2)
{
executing = 1;
hwndTopWindow = GetTopWindow(NULL);
if(hwndTopWindow == NULL)
{
wsprintf(szBuffer, TEXT("Error with GetTopWindow(). Error Number %i"), GetLastError() );
MessageBox (NULL, szBuffer, TEXT("ERROR"), MB_ICONERROR);
}else{
ShowWindow(hwndTopWindow, SW_MAXIMIZE);
}
executing = 0;
//We return here so that the command character 220 "\" isnt seen as pressed.
return 1;
}
executing = 0;
}
hDC = GetDC(hwndMain);
TabbedTextOut(hDC, 1, nLineHeight * KEYBOARDINDEX,
(LPSTR)szFilterLine[KEYBOARDINDEX],
strlen(szFilterLine[KEYBOARDINDEX]), 0, NULL, 1);
ReleaseDC(hwndMain, hDC);
}
// If the message isnt for us, just peek at it and pass it on.
//
return( CallNextHookEx(hhookHooks[KEYBOARDINDEX], nCode, wParam, lParam));
}
Some of it is borrowed, other parts are poorly writen, and yes it uses global variables in parts. This code was for a personal utility and never meant to be seen by others so its not very nice. Thanks for your time.