diff --git a/src/win/advanced-scene-switcher-win.cpp b/src/win/advanced-scene-switcher-win.cpp index bbed0c74..17ae98de 100644 --- a/src/win/advanced-scene-switcher-win.cpp +++ b/src/win/advanced-scene-switcher-win.cpp @@ -406,26 +406,29 @@ static std::unordered_map keyTable = { void PressKeys(const std::vector keys, int duration) { + const int repeatInterval = 100; + INPUT ip; ip.type = INPUT_KEYBOARD; ip.ki.wScan = 0; ip.ki.time = 0; ip.ki.dwExtraInfo = 0; - // Press keys - ip.ki.dwFlags = 0; - for (auto &key : keys) { - auto it = keyTable.find(key); - if (it == keyTable.end()) { - continue; + for (int cur = 0; cur < duration; cur += repeatInterval) { + // Press keys + ip.ki.dwFlags = 0; + for (auto &key : keys) { + auto it = keyTable.find(key); + if (it == keyTable.end()) { + continue; + } + ip.ki.wVk = it->second; + SendInput(1, &ip, sizeof(INPUT)); } - ip.ki.wVk = it->second; - SendInput(1, &ip, sizeof(INPUT)); + // When instantly releasing the key presses OBS might miss them + Sleep(repeatInterval); } - // When instantly releasing the key presses OBS might miss them - Sleep(duration); - // Release keys ip.ki.dwFlags = KEYEVENTF_KEYUP; for (auto &key : keys) {