Skip to content

Commit

Permalink
Using enhanced knowledge of SendInput to improve responsiveness of au…
Browse files Browse the repository at this point in the history
…to-selecting second clip.
  • Loading branch information
Carson-Shook committed Dec 15, 2021
1 parent c8d89f0 commit a7754b4
Showing 1 changed file with 12 additions and 16 deletions.
28 changes: 12 additions & 16 deletions Winclipper/ClipsManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -657,27 +657,23 @@ void ClipsManager::ShowClipsMenu(HWND hWnd, const LPPOINT cPos, bool showExit)

void ClipsManager::SelectDefaultMenuItem(bool select2ndClip) noexcept
{
INPUT inputDownKey;
INPUT inputs[2] = {};
ZeroMemory(inputs, sizeof(inputs));

inputDownKey.type = INPUT_KEYBOARD;
inputDownKey.ki.wVk = VK_DOWN;
inputDownKey.ki.wScan = 0;
inputDownKey.ki.time = 0;
inputDownKey.ki.dwFlags = 0;
inputDownKey.ki.dwExtraInfo = 0;
inputs[0].type = INPUT_KEYBOARD;
inputs[0].ki.time = 0;
inputs[0].ki.wVk = VK_DOWN;

SendInput(1, &inputDownKey, sizeof(INPUT));
Sleep(50);
inputDownKey.ki.dwFlags = KEYEVENTF_KEYUP;
SendInput(1, &inputDownKey, sizeof(INPUT));
inputs[1].type = INPUT_KEYBOARD;
inputs[1].ki.time = 0;
inputs[1].ki.wVk = VK_DOWN;
inputs[1].ki.dwFlags = KEYEVENTF_KEYUP;

SendInput(2, inputs, sizeof(INPUT));

if (select2ndClip)
{
inputDownKey.ki.dwFlags = 0;
SendInput(1, &inputDownKey, sizeof(INPUT));
Sleep(50);
inputDownKey.ki.dwFlags = KEYEVENTF_KEYUP;
SendInput(1, &inputDownKey, sizeof(INPUT));
SendInput(2, inputs, sizeof(INPUT));
}
return;
}

0 comments on commit a7754b4

Please sign in to comment.