| 40 | } |
| 41 | |
| 42 | static bool EnableScrollLock(bool enable) |
| 43 | { |
| 44 | auto const& args = GetCommandLineArgs(); |
| 45 | |
| 46 | auto enabled = (GetKeyState(VK_SCROLL) & 1) == 1; |
| 47 | if (enabled != enable) { |
| 48 | // If the hotkey is SCROLLLOCK, SendInput() will cause the hotkey to |
| 49 | // trigger (entering an infinite recording toggle loop) so note that |
| 50 | // the message handler should ignore one of them. |
| 51 | if (args.mHotkeySupport && |
| 52 | args.mHotkeyVirtualKeyCode == VK_SCROLL && |
| 53 | args.mHotkeyModifiers == MOD_NOREPEAT) { |
| 54 | gHotkeyIgnoreCount += 1; |
| 55 | } |
| 56 | |
| 57 | // Send SCROLLLOCK press message. |
| 58 | auto extraInfo = GetMessageExtraInfo(); |
| 59 | INPUT input[2] = {}; |
| 60 | |
| 61 | input[0].type = INPUT_KEYBOARD; |
| 62 | input[0].ki.wVk = VK_SCROLL; |
| 63 | input[0].ki.dwExtraInfo = extraInfo; |
| 64 | |
| 65 | input[1].type = INPUT_KEYBOARD; |
| 66 | input[1].ki.wVk = VK_SCROLL; |
| 67 | input[1].ki.dwFlags = KEYEVENTF_KEYUP; |
| 68 | input[1].ki.dwExtraInfo = extraInfo; |
| 69 | |
| 70 | auto sendCount = SendInput(2, input, sizeof(INPUT)); |
| 71 | if (sendCount != 2) { |
| 72 | PrintWarning(L"warning: could not toggle scroll lock.\n"); |
| 73 | } |
| 74 | } |
| 75 | |
| 76 | return enabled; |
| 77 | } |
| 78 | |
| 79 | static bool IsRecording() |
| 80 | { |
no test coverage detected