static void __cdecl FlashThreadFunction(void*) { BOOL bEvent = FALSE; DWORD dwEventStarted = 0, dwFlashStarted = 0; BYTE data, unchangedLeds; while (TRUE) { unchangedLeds = (BYTE)(LedState(VK_PAUSE) * !bFlashLed[2] + ((LedState(VK_NUMLOCK) * !bFlashLed[0]) << 1) + ((LedState(VK_CAPITAL) * !bFlashLed[1]) << 2)); GetAsyncKeyState(VK_PAUSE); // empty Pause/Break's keystroke buffer // Start flashing while (bEvent && bFlashingEnabled) { // Let's give the user the opportunity of finishing flashing manually :) if (GetAsyncKeyState(VK_PAUSE) & 1) break; if ((bFlashUntil & UNTIL_NBLINKS) && GetTickCount() > (dwFlashStarted + wBlinksNumber * 1000)) break; if (bFlashUntil & UNTIL_REATTENDED) { if (bMirandaOrWindows == ACTIVE_WINDOWS && !bEmulateKeypresses) { LASTINPUTINFO ii = { sizeof(ii) }; GetLastInputInfo(&ii); dwLastInput = ii.dwTime; } if (dwLastInput > dwEventStarted) break; } if ((bFlashUntil & UNTIL_EVENTSOPEN) && !checkUnopenEvents()) break; if ((bFlashUntil & UNTIL_CONDITIONS) && (!checkNotifyOptions() || !checkGlobalStatus() || !checkGlobalXstatus())) break; data = getBlinkingLeds(); ToggleKeyboardLights((BYTE)(data | unchangedLeds)); // Wait for exit event if (WaitForSingleObject(hExitEvent, nWaitDelay) == WAIT_OBJECT_0) return; } RestoreLEDState(); setFlashingSequence(); bReminderDisabled = FALSE; // Wait for new event HANDLE Objects[2]; Objects[0] = hFlashEvent; Objects[1] = hExitEvent; if (WaitForMultipleObjects(2, Objects, FALSE, INFINITE) == WAIT_OBJECT_0 + 1) return; bEvent = TRUE; bReminderDisabled = TRUE; dwEventStarted = GetTickCount(); // Wait StartDelay seconds if (wStartDelay > 0) Sleep(wStartDelay * 1000); dwFlashStarted = GetTickCount(); } }
void LoadSettings(void) { bFlashOnMsg = db_get_b(NULL, KEYBDMODULE, "onmsg", DEF_SETTING_ONMSG); bFlashOnURL = db_get_b(NULL, KEYBDMODULE, "onurl", DEF_SETTING_ONURL); bFlashOnFile = db_get_b(NULL, KEYBDMODULE, "onfile", DEF_SETTING_ONFILE); bFlashOnOther = db_get_b(NULL, KEYBDMODULE, "onother", DEF_SETTING_OTHER); bFullScreenMode = db_get_b(NULL, KEYBDMODULE, "fscreenmode", DEF_SETTING_FSCREEN); bScreenSaverRunning = db_get_b(NULL, KEYBDMODULE, "ssaverrunning", DEF_SETTING_SSAVER); bWorkstationLocked = db_get_b(NULL, KEYBDMODULE, "wstationlocked", DEF_SETTING_LOCKED); bProcessesAreRunning = db_get_b(NULL, KEYBDMODULE, "procsrunning", DEF_SETTING_PROCS); bWorkstationActive = db_get_b(NULL, KEYBDMODULE, "wstationactive", DEF_SETTING_ACTIVE); bFlashIfMsgOpen = db_get_b(NULL, KEYBDMODULE, "ifmsgopen", DEF_SETTING_IFMSGOPEN); bFlashIfMsgWinNotTop = db_get_b(NULL, KEYBDMODULE, "ifmsgnottop", DEF_SETTING_IFMSGNOTTOP); bFlashIfMsgOlder = db_get_b(NULL, KEYBDMODULE, "ifmsgolder", DEF_SETTING_IFMSGOLDER); wSecondsOlder = db_get_w(NULL, KEYBDMODULE, "secsolder", DEF_SETTING_SECSOLDER); bFlashUntil = db_get_b(NULL, KEYBDMODULE, "funtil", DEF_SETTING_FLASHUNTIL); wBlinksNumber = db_get_w(NULL, KEYBDMODULE, "nblinks", DEF_SETTING_NBLINKS); bMirandaOrWindows = db_get_b(NULL, KEYBDMODULE, "mirorwin", DEF_SETTING_MIRORWIN); wStatusMap = db_get_w(NULL, KEYBDMODULE, "status", DEF_SETTING_STATUS); wReminderCheck = db_get_w(NULL, KEYBDMODULE, "remcheck", DEF_SETTING_CHECKTIME); bFlashLed[0] = !!db_get_b(NULL, KEYBDMODULE, "fnum", DEF_SETTING_FLASHNUM); bFlashLed[1] = !!db_get_b(NULL, KEYBDMODULE, "fcaps", DEF_SETTING_FLASHCAPS); bFlashLed[2] = !!db_get_b(NULL, KEYBDMODULE, "fscroll", DEF_SETTING_FLASHSCROLL); bFlashEffect = db_get_b(NULL, KEYBDMODULE, "feffect", DEF_SETTING_FLASHEFFECT); bSequenceOrder = db_get_b(NULL, KEYBDMODULE, "order", DEF_SETTING_SEQORDER); wCustomTheme = db_get_w(NULL, KEYBDMODULE, "custom", DEF_SETTING_CUSTOMTHEME); bTrillianLedsMsg = db_get_b(NULL, KEYBDMODULE, "ledsmsg", DEF_SETTING_LEDSMSG); bTrillianLedsURL = db_get_b(NULL, KEYBDMODULE, "ledsurl", DEF_SETTING_LEDSURL); bTrillianLedsFile = db_get_b(NULL, KEYBDMODULE, "ledsfile", DEF_SETTING_LEDSFILE); bTrillianLedsOther = db_get_b(NULL, KEYBDMODULE, "ledsother", DEF_SETTING_LEDSOTHER); wStartDelay = db_get_w(NULL, KEYBDMODULE, "sdelay", DEF_SETTING_STARTDELAY); bFlashSpeed = db_get_b(NULL, KEYBDMODULE, "speed", DEF_SETTING_FLASHSPEED); switch (bFlashSpeed) { case 0: nWaitDelay = 1500; break; case 1: nWaitDelay = 0750; break; case 2: nWaitDelay = 0250; break; case 3: nWaitDelay = 0150; break; case 4: nWaitDelay = 0100; break; default: nWaitDelay = 0050; break; } setFlashingSequence(); bEmulateKeypresses = db_get_b(NULL, KEYBDMODULE, "keypresses", DEF_SETTING_KEYPRESSES); bOverride = db_get_b(NULL, KEYBDMODULE, "override", DEF_SETTING_OVERRIDE); // Create hidden settings (for test button) if needed if (db_get_b(NULL, KEYBDMODULE, "testnum", -1) == -1) db_set_b(NULL, KEYBDMODULE, "testnum", DEF_SETTING_TESTNUM); if (db_get_b(NULL, KEYBDMODULE, "testsecs", -1) == -1) db_set_b(NULL, KEYBDMODULE, "testsecs", DEF_SETTING_TESTSECS); for (int i=0; i < ProtoList.protoCount; i++) if (ProtoList.protoInfo[i].visible) { unsigned int j; ProtoList.protoInfo[i].enabled = db_get_b(NULL, KEYBDMODULE, ProtoList.protoInfo[i].szProto, DEF_SETTING_PROTOCOL); for (j=0; j < ProtoList.protoInfo[i].xstatus.count; j++) ProtoList.protoInfo[i].xstatus.enabled[j] = db_get_b(NULL, KEYBDMODULE, fmtDBSettingName("%sxstatus%d", ProtoList.protoInfo[i].szProto, j), DEF_SETTING_XSTATUS); } bMetaProtoEnabled = db_get_b(NULL, META_PROTO, "Enabled", 1); destroyProcessList(); createProcessList(); UnhookWindowsHooks(); HookWindowsHooks(); }