Skip to content

Commit

Permalink
fix: most recently used windows order not working
Browse files Browse the repository at this point in the history
fix #21
  • Loading branch information
akiver committed Sep 29, 2024
1 parent 3a1c6b1 commit c49e137
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions AltBacktick.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "Config.h"
#include <deque>
#include <sstream>
#include <thread>
#include <unordered_map>

HWND lastWindow = nullptr;
Expand Down Expand Up @@ -46,10 +47,16 @@ LRESULT CALLBACK KeyboardHook(int nCode, WPARAM wParam, LPARAM lParam) {
if (IsModifierKeyKeyboardEvent(kbEvent)) {
HWND currentWindow = GetForegroundWindow();
if (currentWindow != nullptr) {
std::wstring currentProcessUniqueId = windowFinder.GetProcessUniqueId(currentWindow);
if (!currentProcessUniqueId.empty()) {
UpdateMRUForProcess(currentWindow, currentProcessUniqueId);
}
std::thread([currentWindow]() {
HRESULT hr = CoInitialize(NULL);
if (SUCCEEDED(hr)) {
std::wstring currentProcessUniqueId = windowFinder.GetProcessUniqueId(currentWindow);
if (!currentProcessUniqueId.empty()) {
UpdateMRUForProcess(currentWindow, currentProcessUniqueId);
}
CoUninitialize();
}
}).detach();
}

isModifierKeyPressed = false;
Expand Down

0 comments on commit c49e137

Please sign in to comment.