Add event-driven Telegram Web K chat profiles for Chrome

This commit is contained in:
agrynco committed 2026-11-06 10:26:42 +02:00
1 parent 15197da548
commit c18148a574
8 files changed
+197 -6

No files matched your search

+4
View File
@@ -559,6 +559,7 @@ App::App(HINSTANCE h, bool test, const std::filesystem::path &dataRoot, HWND ser
}
App::~App()
{
stopBrowserChatMonitor();
if (auto host = historyController(historyProcess)) PostMessageW(host, WM_CLOSE, 0, 0);
if (historyProcess) CloseHandle(historyProcess);
if (notificationRegistration) CloseHandle(notificationRegistration);
@@ -978,6 +979,7 @@ void App::switchChatLayout(bool reverse)
{
struct Reset { std::atomic<bool> &busy; ~Reset() { busy = false; } } reset{busy};
auto valid = [&] { return GetForegroundWindow() == target && windowChatKey(target) == key; };
if (key.starts_with(L"telegram-web\n") && readChromeChat(target) != key) return;
if (!valid()) return;
auto next = nextChatLayout(cycle, available, windowLayout(target), reverse);
if (next) switchWindowLayout(target, next, valid);
@@ -1275,6 +1277,7 @@ void App::transform(int command, int snippet)
}
} reset{busy, window, preDeferred};
auto effectiveChat = requestedChat;
if (lower(processName(target)) == L"chrome") effectiveChat = readChromeChat(target);
config.cycle = chatCycle(config, effectiveChat, available);
auto start = GetTickCount64();
std::wstring reason = L"cancelled-before-selection";
@@ -2318,6 +2321,7 @@ int App::execute()
// Resume pending OCR, including older images without a saved OCR state.
scheduleHistoryOcr(settings);
addTray();
if (!smoke) startBrowserChatMonitor();
SetTimer(window, 1, 60000, nullptr);
if (!smoke) SetTimer(window, 6, 1000, nullptr);
SetThreadExecutionState(ES_CONTINUOUS |