From 66e24b5efc7cd20eb7cf6bea35135fa1325368ed Mon Sep 17 00:00:00 2001 From: Anatolii Hrynchuk Date: Fri, 6 Nov 2026 00:18:04 +0200 Subject: [PATCH] Disable Viber chat OCR while preserving saved profiles --- README.md | 5 +++++ src/app.cpp | 17 +---------------- src/chat_context.h | 3 --- src/ocr.cpp | 1 - src/ui.cpp | 11 +++++------ 5 files changed, 11 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index b326c1f..5a4f290 100644 --- a/README.md +++ b/README.md @@ -272,6 +272,11 @@ thumbnails and source labels aligned with the scaled fonts and spacing. ### Chat language profiles — v0.6.48 +> Local development change: Viber chat OCR is temporarily disabled. Saved Viber profiles are retained but inactive. Telegram and Teams profiles are unchanged; clipboard/image OCR remains available. +> +> Локальна зміна: OCR чатів Viber тимчасово вимкнений. Збережені профілі Viber залишаються, але не діють. Профілі Telegram і Teams та OCR зображень/буфера працюють як раніше. + + Settings separates General, Languages, Shortcuts, Clipboard and Tools into native tabs. Switching tabs preserves edits; Save, Cancel, Import and Export stay available below every page. diff --git a/src/app.cpp b/src/app.cpp index 8e072cb..cfba9cc 100644 --- a/src/app.cpp +++ b/src/app.cpp @@ -974,11 +974,10 @@ void App::switchChatLayout(bool reverse) auto cycle = chatCycle(settings, key, layouts); auto available = layouts; resetInput(); - enqueue([this, target, key, cycle, available, reverse, options = settings] + enqueue([this, target, key, cycle, available, reverse] { struct Reset { std::atomic &busy; ~Reset() { busy = false; } } reset{busy}; auto valid = [&] { return GetForegroundWindow() == target && windowChatKey(target) == key; }; - if (key.starts_with(L"viber\n") && recognizeViberChat(target, options) != key) return; if (!valid()) return; auto next = nextChatLayout(cycle, available, windowLayout(target), reverse); if (next) switchWindowLayout(target, next, valid); @@ -1276,8 +1275,6 @@ void App::transform(int command, int snippet) } } reset{busy, window, preDeferred}; auto effectiveChat = requestedChat; - if (lower(processName(target)) == L"viber") - effectiveChat = recognizeViberChat(target, config); config.cycle = chatCycle(config, effectiveChat, available); auto start = GetTickCount64(); std::wstring reason = L"cancelled-before-selection"; @@ -2182,17 +2179,6 @@ LRESULT CALLBACK App::windowProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp) return TRUE; } case WM_TIMER: - if (wp == 7) - { - static std::atomic pending{false}; - auto target = GetForegroundWindow(); - if (!app->settings.chatCycles.empty() && lower(processName(target)) == L"viber" && !pending.exchange(true)) - { - auto options = app->settings; - app->enqueue([target, options] { recognizeViberChat(target, options); pending = false; }); - } - return 0; - } if (wp == 6) { if (app->notificationRegistration && WaitForSingleObject(app->notificationRegistration, 0) == WAIT_OBJECT_0) @@ -2333,7 +2319,6 @@ int App::execute() scheduleHistoryOcr(settings); addTray(); SetTimer(window, 1, 60000, nullptr); - if (!smoke) SetTimer(window, 7, 750, nullptr); if (!smoke) SetTimer(window, 6, 1000, nullptr); SetThreadExecutionState(ES_CONTINUOUS | (settings.awake ? (ES_DISPLAY_REQUIRED | ES_SYSTEM_REQUIRED) : 0)); diff --git a/src/chat_context.h b/src/chat_context.h index 5ac507a..d019992 100644 --- a/src/chat_context.h +++ b/src/chat_context.h @@ -4,8 +4,6 @@ namespace ks { -std::wstring cachedViberChat(HWND); -std::wstring recognizeViberChat(HWND, const Settings &); struct ChatSwitchHook { bool pressed[256]{}; @@ -66,7 +64,6 @@ inline std::wstring chatKey(std::wstring process, std::wstring title) } inline std::wstring windowChatKey(HWND window) { - if (window && lower(processName(window)) == L"viber") return cachedViberChat(window); return window ? chatKey(processName(window), chatTitle(window)) : L""; } inline std::vector chatCycle(const Settings &settings, const std::wstring &key, diff --git a/src/ocr.cpp b/src/ocr.cpp index 1d4b43b..6636605 100644 --- a/src/ocr.cpp +++ b/src/ocr.cpp @@ -429,4 +429,3 @@ std::wstring recognizeText(const Clip &clip, const Settings &s) return wide(text.get()); } } // namespace ks -#include "viber_ocr.inc" diff --git a/src/ui.cpp b/src/ui.cpp index b144d76..34e991e 100644 --- a/src/ui.cpp +++ b/src/ui.cpp @@ -1013,7 +1013,7 @@ LRESULT CALLBACK chatLanguagesProc(HWND w, UINT msg, WPARAM wp, LPARAM lp) { int selected = (int)SendDlgItemMessageW(w, 710, LB_GETCURSEL, 0, 0); if (selected < 0 || selected >= (int)v->keys.size()) - throw std::runtime_error("Open a Telegram, Teams or Viber chat, then reopen this dialog. Viber requires Tesseract."); + throw std::runtime_error("Open a Telegram or Teams chat, then reopen this dialog. Viber OCR is disabled."); auto next = v->settings->draft; if (id == 713) next.chatCycles.erase(v->keys[selected]); else @@ -1055,8 +1055,7 @@ void showChatLanguages(HWND parent, SettingsView *settings) { if (!IsWindowVisible(candidate)) return TRUE; auto &data = *(Context *)context; - auto key = lower(processName(candidate)) == L"viber" - ? recognizeViberChat(candidate, data.settings) : windowChatKey(candidate); + auto key = windowChatKey(candidate); if (!key.empty()) data.keys.insert(std::move(key)); return TRUE; }, (LPARAM)&context); @@ -1064,13 +1063,13 @@ void showChatLanguages(HWND parent, SettingsView *settings) auto *v = new ChatLanguagesView{parent, settings, {keys.begin(), keys.end()}}; SetWindowLongPtrW(w, GWLP_HWNDPARENT, (LONG_PTR)parent); SetWindowLongPtrW(w, GWLP_USERDATA, (LONG_PTR)v); - label(w, L"Telegram / Teams / Viber (experimental OCR) chat profiles", 18, 16, 604); + label(w, L"Telegram / Teams profiles; saved Viber profiles are inactive", 18, 16, 604); control(w, L"LISTBOX", L"", WS_TABSTOP | WS_VSCROLL | LBS_NOTIFY | LBS_NOINTEGRALHEIGHT | WS_BORDER, 710, 18, 44, 604, 140); for (const auto &key : v->keys) { auto split = key.find(L'\n'); - auto name = std::wstring(key.starts_with(L"telegram\n") ? L"Telegram: " : key.starts_with(L"viber\n") ? L"Viber: " : L"Teams: ") + key.substr(split + 1); + auto name = std::wstring(key.starts_with(L"telegram\n") ? L"Telegram: " : key.starts_with(L"viber\n") ? L"Viber (inactive): " : L"Teams: ") + key.substr(split + 1); SendDlgItemMessageW(w, 710, LB_ADDSTRING, 0, (LPARAM)name.c_str()); } control(w, L"STATIC", L"Open a chat, then reopen this dialog to add it.", 0, 712, 18, 194, 604, 26); @@ -1989,7 +1988,7 @@ void showSettings(App &app, bool visible) label(w, L"Backspace / Delete clears it", 454, 270, 230); button(w, L"Re&fresh layouts", 253, 454, 322, 230); button(w, L"Languages for a &chat...", 259, 24, 378, 230); - label(w, L"Chat languages: Telegram, Teams, Viber (OCR).", 272, 382, 412); + label(w, L"Chat languages: Telegram / Teams. Viber OCR disabled.", 272, 382, 412); page(); label(w, L"Click a shortcut field and press the desired keys", 24, 76, 660);