Disable Viber chat OCR while preserving saved profiles
This commit is contained in:
1 parent
178573233b
commit
66e24b5efc
5 files changed
+11
-26
No files matched your search
@@ -272,6 +272,11 @@ thumbnails and source labels aligned with the scaled fonts and spacing.
|
|||||||
|
|
||||||
### Chat language profiles — v0.6.48
|
### 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.
|
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.
|
Switching tabs preserves edits; Save, Cancel, Import and Export stay available below every page.
|
||||||
|
|
||||||
|
|||||||
+1
-16
@@ -974,11 +974,10 @@ void App::switchChatLayout(bool reverse)
|
|||||||
auto cycle = chatCycle(settings, key, layouts);
|
auto cycle = chatCycle(settings, key, layouts);
|
||||||
auto available = layouts;
|
auto available = layouts;
|
||||||
resetInput();
|
resetInput();
|
||||||
enqueue([this, target, key, cycle, available, reverse, options = settings]
|
enqueue([this, target, key, cycle, available, reverse]
|
||||||
{
|
{
|
||||||
struct Reset { std::atomic<bool> &busy; ~Reset() { busy = false; } } reset{busy};
|
struct Reset { std::atomic<bool> &busy; ~Reset() { busy = false; } } reset{busy};
|
||||||
auto valid = [&] { return GetForegroundWindow() == target && windowChatKey(target) == key; };
|
auto valid = [&] { return GetForegroundWindow() == target && windowChatKey(target) == key; };
|
||||||
if (key.starts_with(L"viber\n") && recognizeViberChat(target, options) != key) return;
|
|
||||||
if (!valid()) return;
|
if (!valid()) return;
|
||||||
auto next = nextChatLayout(cycle, available, windowLayout(target), reverse);
|
auto next = nextChatLayout(cycle, available, windowLayout(target), reverse);
|
||||||
if (next) switchWindowLayout(target, next, valid);
|
if (next) switchWindowLayout(target, next, valid);
|
||||||
@@ -1276,8 +1275,6 @@ void App::transform(int command, int snippet)
|
|||||||
}
|
}
|
||||||
} reset{busy, window, preDeferred};
|
} reset{busy, window, preDeferred};
|
||||||
auto effectiveChat = requestedChat;
|
auto effectiveChat = requestedChat;
|
||||||
if (lower(processName(target)) == L"viber")
|
|
||||||
effectiveChat = recognizeViberChat(target, config);
|
|
||||||
config.cycle = chatCycle(config, effectiveChat, available);
|
config.cycle = chatCycle(config, effectiveChat, available);
|
||||||
auto start = GetTickCount64();
|
auto start = GetTickCount64();
|
||||||
std::wstring reason = L"cancelled-before-selection";
|
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;
|
return TRUE;
|
||||||
}
|
}
|
||||||
case WM_TIMER:
|
case WM_TIMER:
|
||||||
if (wp == 7)
|
|
||||||
{
|
|
||||||
static std::atomic<bool> 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 (wp == 6)
|
||||||
{
|
{
|
||||||
if (app->notificationRegistration && WaitForSingleObject(app->notificationRegistration, 0) == WAIT_OBJECT_0)
|
if (app->notificationRegistration && WaitForSingleObject(app->notificationRegistration, 0) == WAIT_OBJECT_0)
|
||||||
@@ -2333,7 +2319,6 @@ int App::execute()
|
|||||||
scheduleHistoryOcr(settings);
|
scheduleHistoryOcr(settings);
|
||||||
addTray();
|
addTray();
|
||||||
SetTimer(window, 1, 60000, nullptr);
|
SetTimer(window, 1, 60000, nullptr);
|
||||||
if (!smoke) SetTimer(window, 7, 750, nullptr);
|
|
||||||
if (!smoke) SetTimer(window, 6, 1000, nullptr);
|
if (!smoke) SetTimer(window, 6, 1000, nullptr);
|
||||||
SetThreadExecutionState(ES_CONTINUOUS |
|
SetThreadExecutionState(ES_CONTINUOUS |
|
||||||
(settings.awake ? (ES_DISPLAY_REQUIRED | ES_SYSTEM_REQUIRED) : 0));
|
(settings.awake ? (ES_DISPLAY_REQUIRED | ES_SYSTEM_REQUIRED) : 0));
|
||||||
|
|||||||
@@ -4,8 +4,6 @@
|
|||||||
|
|
||||||
namespace ks
|
namespace ks
|
||||||
{
|
{
|
||||||
std::wstring cachedViberChat(HWND);
|
|
||||||
std::wstring recognizeViberChat(HWND, const Settings &);
|
|
||||||
struct ChatSwitchHook
|
struct ChatSwitchHook
|
||||||
{
|
{
|
||||||
bool pressed[256]{};
|
bool pressed[256]{};
|
||||||
@@ -66,7 +64,6 @@ inline std::wstring chatKey(std::wstring process, std::wstring title)
|
|||||||
}
|
}
|
||||||
inline std::wstring windowChatKey(HWND window)
|
inline std::wstring windowChatKey(HWND window)
|
||||||
{
|
{
|
||||||
if (window && lower(processName(window)) == L"viber") return cachedViberChat(window);
|
|
||||||
return window ? chatKey(processName(window), chatTitle(window)) : L"";
|
return window ? chatKey(processName(window), chatTitle(window)) : L"";
|
||||||
}
|
}
|
||||||
inline std::vector<std::wstring> chatCycle(const Settings &settings, const std::wstring &key,
|
inline std::vector<std::wstring> chatCycle(const Settings &settings, const std::wstring &key,
|
||||||
|
|||||||
@@ -429,4 +429,3 @@ std::wstring recognizeText(const Clip &clip, const Settings &s)
|
|||||||
return wide(text.get());
|
return wide(text.get());
|
||||||
}
|
}
|
||||||
} // namespace ks
|
} // namespace ks
|
||||||
#include "viber_ocr.inc"
|
|
||||||
+5
-6
@@ -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);
|
int selected = (int)SendDlgItemMessageW(w, 710, LB_GETCURSEL, 0, 0);
|
||||||
if (selected < 0 || selected >= (int)v->keys.size())
|
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;
|
auto next = v->settings->draft;
|
||||||
if (id == 713) next.chatCycles.erase(v->keys[selected]);
|
if (id == 713) next.chatCycles.erase(v->keys[selected]);
|
||||||
else
|
else
|
||||||
@@ -1055,8 +1055,7 @@ void showChatLanguages(HWND parent, SettingsView *settings)
|
|||||||
{
|
{
|
||||||
if (!IsWindowVisible(candidate)) return TRUE;
|
if (!IsWindowVisible(candidate)) return TRUE;
|
||||||
auto &data = *(Context *)context;
|
auto &data = *(Context *)context;
|
||||||
auto key = lower(processName(candidate)) == L"viber"
|
auto key = windowChatKey(candidate);
|
||||||
? recognizeViberChat(candidate, data.settings) : windowChatKey(candidate);
|
|
||||||
if (!key.empty()) data.keys.insert(std::move(key));
|
if (!key.empty()) data.keys.insert(std::move(key));
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}, (LPARAM)&context);
|
}, (LPARAM)&context);
|
||||||
@@ -1064,13 +1063,13 @@ void showChatLanguages(HWND parent, SettingsView *settings)
|
|||||||
auto *v = new ChatLanguagesView{parent, settings, {keys.begin(), keys.end()}};
|
auto *v = new ChatLanguagesView{parent, settings, {keys.begin(), keys.end()}};
|
||||||
SetWindowLongPtrW(w, GWLP_HWNDPARENT, (LONG_PTR)parent);
|
SetWindowLongPtrW(w, GWLP_HWNDPARENT, (LONG_PTR)parent);
|
||||||
SetWindowLongPtrW(w, GWLP_USERDATA, (LONG_PTR)v);
|
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,
|
control(w, L"LISTBOX", L"", WS_TABSTOP | WS_VSCROLL | LBS_NOTIFY | LBS_NOINTEGRALHEIGHT | WS_BORDER,
|
||||||
710, 18, 44, 604, 140);
|
710, 18, 44, 604, 140);
|
||||||
for (const auto &key : v->keys)
|
for (const auto &key : v->keys)
|
||||||
{
|
{
|
||||||
auto split = key.find(L'\n');
|
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());
|
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);
|
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);
|
label(w, L"Backspace / Delete clears it", 454, 270, 230);
|
||||||
button(w, L"Re&fresh layouts", 253, 454, 322, 230);
|
button(w, L"Re&fresh layouts", 253, 454, 322, 230);
|
||||||
button(w, L"Languages for a &chat...", 259, 24, 378, 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();
|
page();
|
||||||
|
|
||||||
label(w, L"Click a shortcut field and press the desired keys", 24, 76, 660);
|
label(w, L"Click a shortcut field and press the desired keys", 24, 76, 660);
|
||||||
|
|||||||
Reference in new issue
Block a user