Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
178573233b |
No files matched your search
+1
-1
@@ -1,5 +1,5 @@
|
||||
cmake_minimum_required(VERSION 3.24)
|
||||
project(KSwitcher VERSION 0.6.48 LANGUAGES CXX RC)
|
||||
project(KSwitcher VERSION 0.6.49 LANGUAGES CXX RC)
|
||||
if(NOT WIN32)
|
||||
message(FATAL_ERROR "KSwitcher uses native Windows APIs")
|
||||
endif()
|
||||
|
||||
@@ -290,7 +290,13 @@ Direct layout shortcuts are unchanged. Profiles do not change Windows' installed
|
||||
Matching uses the application and visible chat name, not a unique account/contact ID.
|
||||
Identically named chats in one application share a profile; renamed chats need a new
|
||||
profile. Telegram unread counters are ignored. Teams currently recognizes the desktop
|
||||
`Chat | name | Microsoft Teams` title format; other title formats and Viber are not supported.
|
||||
`Chat | name | Microsoft Teams` title format; other Teams title formats are not supported.
|
||||
From v0.6.49, experimental Viber header OCR is supported using an installed
|
||||
Tesseract 5 and the languages selected in OCR options. Open a non-minimized Viber chat
|
||||
before opening the profile dialog. Recognition runs locally; message text is not sent
|
||||
to OCR and screenshots are not saved. Allow about two seconds after entering a chat.
|
||||
An unreadable or changing header does not produce a profile match. OCR mistakes,
|
||||
truncated names and Viber UI changes can affect matching. Viber support starts with v0.6.49.
|
||||
Profiles stay on this PC (excluded from cloud sync), and are included in manual settings
|
||||
export/import. Available from v0.6.48.
|
||||
|
||||
@@ -306,8 +312,14 @@ for a chat…**. Вибери чат і потрібні мови, натисн
|
||||
Прямі комбінації мов не змінюються; явно задані комбінації KSwitcher мають пріоритет.
|
||||
Зіставлення виконується за програмою та назвою чату: однакові назви в одній програмі
|
||||
мають спільний профіль, після перейменування потрібен новий. Лічильник непрочитаних
|
||||
Telegram ігнорується. Teams підтримує зазначений вище формат заголовка; Viber поки
|
||||
не підтримується. Профілі локальні, входять до ручного експорту/імпорту, але не до
|
||||
Telegram ігнорується. Teams підтримує зазначений вище формат заголовка.
|
||||
З v0.6.49 Viber експериментально визначається через локальний OCR заголовка:
|
||||
потрібен Tesseract 5 із мовами, вибраними в OCR options. Перед відкриттям профілів
|
||||
відкрий чат у незгорнутому Viber. Після переходу в чат зачекай приблизно дві секунди.
|
||||
Текст повідомлень не передається в OCR, знімки не зберігаються. Нечитабельний або
|
||||
мінливий заголовок не дає збігу; помилки OCR, обрізані імена та зміни інтерфейсу Viber
|
||||
можуть впливати на визначення. Підтримка Viber доступна з v0.6.49.
|
||||
Профілі локальні, входять до ручного експорту/імпорту, але не до
|
||||
хмарної синхронізації. Доступно з v0.6.48.
|
||||
|
||||
### Existing features
|
||||
|
||||
Binary file not shown.
+8
-8
@@ -1,22 +1,22 @@
|
||||
# Latest Windows release
|
||||
|
||||
## v0.6.48 — 2026-11-05
|
||||
## v0.6.49 — 2026-11-05
|
||||
|
||||
## Changes
|
||||
- Add manually configured language subsets for Telegram Desktop and Microsoft Teams chats. Open **Settings → Languages → Languages for a chat...**, choose a chat and one or more languages, then **Use languages → Save**.
|
||||
- Apply the matching profile to **Alt+Shift**, **Win+Space**, reverse **Win+Shift+Space**, and KSwitcher's **Next layout** conversion. Explicit shortcut bindings take precedence. Without a matching profile, normal Windows behavior and the global KSwitcher cycle remain available. Direct layout shortcuts retain their targets.
|
||||
- Match the application and visible chat name; ignore Telegram unread badges. Same-name chats share a profile, renamed chats need a new one, and Teams currently supports `Chat | name | Microsoft Teams` desktop titles. Profiles are local, included in manual export/import and excluded from OpenBao sync. Viber is not included.
|
||||
- Organize Settings into **General, Languages, Shortcuts, Clipboard and Tools** tabs. Remove overlapping controls, reduce the window height and preserve drafts across tabs. Save, Cancel, Import and Export remain available on every tab; existing preferences and shortcut defaults are preserved.
|
||||
- Rename the tray **Utilities** menu to **Tools**. Keep bundled StayHere and the v0.6.47 multi-word replacement behavior.
|
||||
- Add experimental Viber chat language profiles using local OCR of the chat header. Requires a separate Tesseract 5 installation and the language packs selected in OCR options; Tesseract is not bundled.
|
||||
- Open a non-minimized Viber chat, then **Settings → Languages → Languages for a chat...**. Select its Viber entry, choose languages, and click **Use languages → Save**.
|
||||
- Apply the profile to **Alt+Shift**, **Win+Space**, reverse **Win+Shift+Space**, and KSwitcher's **Next layout** conversion. Allow about 1–2 seconds after switching chats. OCR runs outside the keyboard hook; the header is checked again before a profile-based system switch.
|
||||
- Match by application and recognized name. Identical names share a profile; renamed chats need a new profile. Unreadable or changing headers produce no match. OCR errors, truncated names, scaling and future Viber UI changes can affect recognition. Telegram and Teams profiles retain their existing behavior.
|
||||
- Recognition is local: only the cropped header is passed to OCR, screenshots are not saved, and no message text is submitted to OCR. Profiles remain local, are included in manual export/import, and excluded from OpenBao synchronization.
|
||||
|
||||
## Validation
|
||||
Passed 653 chat-profile/UI checks (including visible-control overlap checks on all five tabs), 332 native checks, 564 input checks, 105 sync checks, complete dictionary equivalence (140,939 words), shared wheel regressions, isolated StayHere lifecycle and Utilities checks, screenshot UI/save/registration checks, 54 updater checks and updater progress UI checks. Development visual checks covered the five tabs at 250% scaling; the release fixture also passed at 100%. Release binary versions, archive contents, manifest hashes and published downloads are verified as part of publication.
|
||||
Passed 653 chat-profile/UI checks (including Viber profile persistence), 332 native checks, 564 input checks, 105 sync checks, complete dictionary equivalence (140,939 words), wheel, StayHere, Utilities, screenshot UI/save/registration, 54 updater checks and updater progress checks. Live Viber header recognition correctly identified a Ukrainian contact; the user confirmed the development integration works. Release binaries, archive, manifest and published downloads are checked during publication.
|
||||
|
||||
## Upgrade
|
||||
Choose **Update** in the tray menu. Legacy v0.3.0–v0.4.1 clients first receive the v0.4.2 compatibility bridge, then the current full release. v0.2.3 and earlier require manual installation.
|
||||
For manual installation, exit KSwitcher, close its configurator and screenshot editors, and extract the entire ZIP into its installation folder. Keep personal `data/`, customized dictionaries and your own tools. Keep the three KSwitcher executables together; StayHere runs independently.
|
||||
|
||||
When synchronizing phrase replacements across PCs, update each participating PC to v0.6.47 or newer: older versions reject spaces in replacement pairs. Chat language profiles do not synchronize.
|
||||
When synchronizing phrase replacements across PCs, update each participating PC to v0.6.47 or newer. Chat language profiles do not synchronize. A settings file containing Viber profiles requires v0.6.49 or newer; retain a backup before downgrading.
|
||||
|
||||
Download **KSwitcher-win-x64.zip** with **SHA256SUMS.txt**. The package contains no personal settings, credentials or clipboard history.
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
8c6cd9d5f531e5492ef320f1861ba5e84b5631fa7bac42aa97b2c006fe0abc7c KSwitcher-win-x64.zip
|
||||
3c99e7d6b7f3ea059bf9cbff2266eb89f7cbba32287b7ce52a3ac65596131962 KSwitcher-win-x64.zip
|
||||
+33
-33
@@ -1,81 +1,81 @@
|
||||
{
|
||||
"version": "0.6.48",
|
||||
"version": "0.6.49",
|
||||
"schema": 1,
|
||||
"files": [
|
||||
{
|
||||
"sha256": "386b85b62ada4cfea1bd379246e91a3b4976dc37e7e625483821724b58ca4bd5",
|
||||
"size": 1841152,
|
||||
"path": "KSwitcher.exe",
|
||||
"size": 1833984
|
||||
"sha256": "e64518d5224055c4bf09df0e32493ecfe50a1d225436117e56d102cddd7506e0"
|
||||
},
|
||||
{
|
||||
"sha256": "b47864f6dc7653af9b882403a0316fa48ab258d7ee667715a70d4511ca6d1abd",
|
||||
"size": 1704960,
|
||||
"path": "KSwitcher.Config.exe",
|
||||
"size": 1697792
|
||||
"sha256": "c3cb3163c9bd4683362154ec2be1d3fb95e72df879a18b356ad89d37bfdd444f"
|
||||
},
|
||||
{
|
||||
"sha256": "1dce2939a245370d09ef9e80202027a5b88b9f7e6aac0314dd1b5a62e53c4363",
|
||||
"size": 2892800,
|
||||
"path": "KSwitcher.Screenshot.exe",
|
||||
"size": 2885120
|
||||
"sha256": "4785c3cfb4b3ee9783703040237a000a387569100828d239615039fd417f1855"
|
||||
},
|
||||
{
|
||||
"sha256": "d3c81140cce01c26bf6cbf52aa40e0825e1fa35b9a91d1387170a65d2597082c",
|
||||
"size": 4401,
|
||||
"path": "LICENSE",
|
||||
"size": 4401
|
||||
"sha256": "d3c81140cce01c26bf6cbf52aa40e0825e1fa35b9a91d1387170a65d2597082c"
|
||||
},
|
||||
{
|
||||
"sha256": "61e08da79c44061654015ce6b0c4061c23ee1dd18237fbf09e9bfda3c0ea2831",
|
||||
"size": 1096,
|
||||
"path": "json-LICENSE.txt",
|
||||
"size": 1096
|
||||
"sha256": "61e08da79c44061654015ce6b0c4061c23ee1dd18237fbf09e9bfda3c0ea2831"
|
||||
},
|
||||
{
|
||||
"sha256": "a3266c023b5705ad1d14506cc39cc6548d20531878c17804a659cabbb7bbf56b",
|
||||
"size": 69715,
|
||||
"path": "README.md",
|
||||
"size": 68424
|
||||
"sha256": "2ac72789dc57c42303859956eb3f2a31b69bc5eea06e71ccf0588d6f08135948"
|
||||
},
|
||||
{
|
||||
"sha256": "d0c022b27b9fbc2ff7b6b8bec723cc1adc4eef517202f9ff77eed5d8bea3acb9",
|
||||
"size": 732485,
|
||||
"path": "dictionaries/en.txt",
|
||||
"size": 732485
|
||||
"sha256": "d0c022b27b9fbc2ff7b6b8bec723cc1adc4eef517202f9ff77eed5d8bea3acb9"
|
||||
},
|
||||
{
|
||||
"sha256": "0bdfb0201d1803634f268cdff0993b8349d2c70e956a06dbb667c8dd65254ec5",
|
||||
"size": 20566,
|
||||
"path": "dictionaries/LICENSE-CC-BY-SA-4.0.txt",
|
||||
"size": 20566
|
||||
"sha256": "0bdfb0201d1803634f268cdff0993b8349d2c70e956a06dbb667c8dd65254ec5"
|
||||
},
|
||||
{
|
||||
"sha256": "3017bf44d3be9d9dfab21bd6778aa52b7947e61acf9ce2bc86b41d6e949ac311",
|
||||
"size": 2265,
|
||||
"path": "dictionaries/README.md",
|
||||
"size": 2265
|
||||
"sha256": "3017bf44d3be9d9dfab21bd6778aa52b7947e61acf9ce2bc86b41d6e949ac311"
|
||||
},
|
||||
{
|
||||
"sha256": "80e6b6a27815973535f7facb636c597eb845dfee45cfabfc4e9b3341b9332849",
|
||||
"size": 1109134,
|
||||
"path": "dictionaries/ru.txt",
|
||||
"size": 1109134
|
||||
"sha256": "80e6b6a27815973535f7facb636c597eb845dfee45cfabfc4e9b3341b9332849"
|
||||
},
|
||||
{
|
||||
"sha256": "98e5b3fe7304e37705c9e5ff48b0b399ccb16e806736d21f09921b99e5f2a408",
|
||||
"size": 1280,
|
||||
"path": "dictionaries/sources.json",
|
||||
"size": 1280
|
||||
"sha256": "98e5b3fe7304e37705c9e5ff48b0b399ccb16e806736d21f09921b99e5f2a408"
|
||||
},
|
||||
{
|
||||
"sha256": "d30e990d6ec2983c04f3644a3c61c6c668e8c542323f5931916fdd55b916eebf",
|
||||
"size": 940799,
|
||||
"path": "dictionaries/uk.txt",
|
||||
"size": 940799
|
||||
"sha256": "d30e990d6ec2983c04f3644a3c61c6c668e8c542323f5931916fdd55b916eebf"
|
||||
},
|
||||
{
|
||||
"sha256": "a34b5161a8315af037e1ec71d816bfc688f7c364141d4ee2347cf0515ef0c82a",
|
||||
"size": 993,
|
||||
"path": "tools/README.txt",
|
||||
"size": 993
|
||||
"sha256": "a34b5161a8315af037e1ec71d816bfc688f7c364141d4ee2347cf0515ef0c82a"
|
||||
},
|
||||
{
|
||||
"sha256": "6ef5cf64708d62b7fc63c3c793cc99188a513433ff4774cae01dc014f6664376",
|
||||
"size": 134656,
|
||||
"path": "tools/StayHere.exe",
|
||||
"size": 134656
|
||||
"sha256": "6ef5cf64708d62b7fc63c3c793cc99188a513433ff4774cae01dc014f6664376"
|
||||
},
|
||||
{
|
||||
"sha256": "ba214e2aca7405e698b3ab21ceb1f41ce088edd996b3e30e4a9d58ff496f9413",
|
||||
"size": 2796,
|
||||
"path": "tools/StayHere-README.md",
|
||||
"size": 2796
|
||||
"sha256": "ba214e2aca7405e698b3ab21ceb1f41ce088edd996b3e30e4a9d58ff496f9413"
|
||||
}
|
||||
],
|
||||
"schema": 1
|
||||
]
|
||||
}
|
||||
+3
-3
@@ -9,8 +9,8 @@ IDC_SCREENSHOT_PENCIL CURSOR "icons/lucide/pencil.cur"
|
||||
1 RT_MANIFEST "app.manifest"
|
||||
201 RCDATA "update.ps1"
|
||||
1 VERSIONINFO
|
||||
FILEVERSION 0,6,48,0
|
||||
PRODUCTVERSION 0,6,48,0
|
||||
FILEVERSION 0,6,49,0
|
||||
PRODUCTVERSION 0,6,49,0
|
||||
FILEOS VOS_NT_WINDOWS32
|
||||
FILETYPE VFT_APP
|
||||
BEGIN
|
||||
@@ -20,7 +20,7 @@ BEGIN
|
||||
BEGIN
|
||||
VALUE "FileDescription", "KSwitcher — native keyboard and clipboard utility"
|
||||
VALUE "ProductName", "KSwitcher"
|
||||
VALUE "FileVersion", "0.6.48"
|
||||
VALUE "FileVersion", "0.6.49"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
|
||||
+20
-4
@@ -963,7 +963,7 @@ void App::refreshChatContext()
|
||||
HWND target = GetForegroundWindow();
|
||||
chatWindow = target;
|
||||
activeChatTitle = chatTitle(target);
|
||||
activeChat = settings.chatCycles.empty() ? L"" : chatKey(processName(target), activeChatTitle);
|
||||
activeChat = settings.chatCycles.empty() ? L"" : windowChatKey(target);
|
||||
}
|
||||
void App::switchChatLayout(bool reverse)
|
||||
{
|
||||
@@ -974,10 +974,11 @@ void App::switchChatLayout(bool reverse)
|
||||
auto cycle = chatCycle(settings, key, layouts);
|
||||
auto available = layouts;
|
||||
resetInput();
|
||||
enqueue([this, target, key, cycle, available, reverse]
|
||||
enqueue([this, target, key, cycle, available, reverse, options = settings]
|
||||
{
|
||||
struct Reset { std::atomic<bool> &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);
|
||||
@@ -1258,9 +1259,8 @@ void App::transform(int command, int snippet)
|
||||
version = inputVersion;
|
||||
}
|
||||
const auto requestedChat = config.chatCycles.empty() ? L"" : windowChatKey(target);
|
||||
config.cycle = chatCycle(config, requestedChat, available);
|
||||
enqueue(
|
||||
[this, target, recent, previous, config, available, version, command, snippet, attempt, manual, requestedAt, preDeferred]
|
||||
[this, target, recent, previous, config, available, version, command, snippet, attempt, manual, requestedAt, preDeferred, requestedChat]() mutable
|
||||
{
|
||||
struct BusyReset
|
||||
{
|
||||
@@ -1275,6 +1275,10 @@ void App::transform(int command, int snippet)
|
||||
b = false;
|
||||
}
|
||||
} 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";
|
||||
std::wstring text, result, expected, actual, verification = L"not-attempted";
|
||||
@@ -2178,6 +2182,17 @@ LRESULT CALLBACK App::windowProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
|
||||
return TRUE;
|
||||
}
|
||||
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 (app->notificationRegistration && WaitForSingleObject(app->notificationRegistration, 0) == WAIT_OBJECT_0)
|
||||
@@ -2318,6 +2333,7 @@ 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));
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
|
||||
namespace ks
|
||||
{
|
||||
std::wstring cachedViberChat(HWND);
|
||||
std::wstring recognizeViberChat(HWND, const Settings &);
|
||||
struct ChatSwitchHook
|
||||
{
|
||||
bool pressed[256]{};
|
||||
@@ -64,6 +66,7 @@ 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<std::wstring> chatCycle(const Settings &settings, const std::wstring &key,
|
||||
|
||||
@@ -429,3 +429,4 @@ std::wstring recognizeText(const Clip &clip, const Settings &s)
|
||||
return wide(text.get());
|
||||
}
|
||||
} // namespace ks
|
||||
#include "viber_ocr.inc"
|
||||
+1
-1
@@ -67,7 +67,7 @@ void validateSettings(const Settings &s)
|
||||
auto separator = key.find(L'\n');
|
||||
if (separator == key.npos || separator + 1 == key.size() || key.size() > 1024 ||
|
||||
key.find(L'\n', separator + 1) != key.npos || key.find(L'\r') != key.npos ||
|
||||
(key.substr(0, separator) != L"telegram" && key.substr(0, separator) != L"ms-teams"))
|
||||
(key.substr(0, separator) != L"telegram" && key.substr(0, separator) != L"ms-teams" && key.substr(0, separator) != L"viber"))
|
||||
throw std::runtime_error("Invalid chat language profile");
|
||||
if (cycle.empty() || cycle.size() > 64) throw std::runtime_error("Select at least one chat language");
|
||||
std::vector<std::wstring> seen;
|
||||
|
||||
+10
-7
@@ -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 or Teams chat, then reopen this dialog.");
|
||||
throw std::runtime_error("Open a Telegram, Teams or Viber chat, then reopen this dialog. Viber requires Tesseract.");
|
||||
auto next = v->settings->draft;
|
||||
if (id == 713) next.chatCycles.erase(v->keys[selected]);
|
||||
else
|
||||
@@ -1050,24 +1050,27 @@ void showChatLanguages(HWND parent, SettingsView *settings)
|
||||
{
|
||||
std::set<std::wstring> keys;
|
||||
for (const auto &[key, cycle] : settings->draft.chatCycles) keys.insert(key);
|
||||
struct Context { std::set<std::wstring> &keys; const Settings &settings; } context{keys, settings->draft};
|
||||
EnumWindows([](HWND candidate, LPARAM context) -> BOOL
|
||||
{
|
||||
if (!IsWindowVisible(candidate)) return TRUE;
|
||||
auto key = windowChatKey(candidate);
|
||||
if (!key.empty()) ((std::set<std::wstring> *)context)->insert(std::move(key));
|
||||
auto &data = *(Context *)context;
|
||||
auto key = lower(processName(candidate)) == L"viber"
|
||||
? recognizeViberChat(candidate, data.settings) : windowChatKey(candidate);
|
||||
if (!key.empty()) data.keys.insert(std::move(key));
|
||||
return TRUE;
|
||||
}, (LPARAM)&keys);
|
||||
}, (LPARAM)&context);
|
||||
HWND w = makeWindow(*settings->app, L"KSwitcher.ChatLanguages", L"Languages for a chat", chatLanguagesProc, 640, 524);
|
||||
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"Saved profiles and currently open Telegram / Teams chats", 18, 16, 604);
|
||||
label(w, L"Telegram / Teams / Viber (experimental OCR) chat profiles", 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: " : 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: " : 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);
|
||||
@@ -1986,7 +1989,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"Choose a separate set for each Telegram or Teams chat.", 272, 382, 412);
|
||||
label(w, L"Chat languages: Telegram, Teams, Viber (OCR).", 272, 382, 412);
|
||||
page();
|
||||
|
||||
label(w, L"Click a shortcut field and press the desired keys", 24, 76, 660);
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
#include "platform.h"
|
||||
namespace ks
|
||||
{
|
||||
inline constexpr wchar_t AppVersion[] = L"0.6.48";
|
||||
inline constexpr wchar_t AppVersion[] = L"0.6.49";
|
||||
inline constexpr UINT UpdateMessage = WM_APP + 7;
|
||||
inline constexpr UINT UpdateCheckIntervalMs = 6 * 60 * 60 * 1000;
|
||||
inline constexpr UINT UpdateNotificationRetryMs = 5 * 60 * 1000;
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
// Experimental Viber header OCR; never called on the keyboard hook thread.
|
||||
#include <uiautomation.h>
|
||||
#include <mutex>
|
||||
namespace ks {
|
||||
namespace {
|
||||
std::mutex viberMutex;
|
||||
HWND viberWindow{};
|
||||
std::wstring viberKey;
|
||||
ULONGLONG viberTime{};
|
||||
std::wstring elementClass(IUIAutomationElement *e) {
|
||||
BSTR s{}; e->get_CurrentClassName(&s); std::wstring out=s?s:L""; SysFreeString(s); return out;
|
||||
}
|
||||
bool findViberHeader(IUIAutomationTreeWalker *walker,IUIAutomationElement *e,RECT &pane,RECT &search,int depth,int &budget) {
|
||||
if(depth>5 || --budget<0) return false;
|
||||
bool stack=elementClass(e).starts_with(L"StackView_");
|
||||
Com<IUIAutomationElement> child;walker->GetFirstChildElement(e,child.out());
|
||||
bool found=false,info=false;
|
||||
while(child.p && --budget>0) {
|
||||
if(stack) {
|
||||
auto name=elementClass(child.p);
|
||||
if(name.starts_with(L"SearchButton_")){child->get_CurrentBoundingRectangle(&search);found=true;}
|
||||
if(name.starts_with(L"InfoButton_")) info=true;
|
||||
} else if(findViberHeader(walker,child.p,pane,search,depth+1,budget)) return true;
|
||||
Com<IUIAutomationElement> next;walker->GetNextSiblingElement(child.p,next.out());
|
||||
child.p->Release();child.p=next.p;next.p=nullptr;
|
||||
}
|
||||
if(found && info){e->get_CurrentBoundingRectangle(&pane);return true;}
|
||||
return false;
|
||||
}
|
||||
Pixels viberHeader(HWND window) {
|
||||
if(!IsWindow(window)||IsIconic(window)) return {};
|
||||
Com<IUIAutomation2> automation;
|
||||
check(CoCreateInstance(CLSID_CUIAutomation8,nullptr,CLSCTX_INPROC_SERVER,IID_IUIAutomation2,(void**)automation.out()));
|
||||
automation->put_ConnectionTimeout(200);automation->put_TransactionTimeout(200);
|
||||
Com<IUIAutomationElement> root;check(automation->ElementFromHandle(window,root.out()));
|
||||
Com<IUIAutomationTreeWalker> walker;check(automation->get_RawViewWalker(walker.out()));
|
||||
RECT pane{},search{},rect{};int budget=160;
|
||||
if(!findViberHeader(walker.p,root.p,pane,search,0,budget)||!GetWindowRect(window,&rect)) return {};
|
||||
double scale=GetDpiForWindow(window)/96.0;
|
||||
int x=pane.left+int(76*scale)-rect.left,y=search.top-int(12*scale)-rect.top;
|
||||
int width=search.left-int(12*scale)-rect.left-x,height=int(28*scale);
|
||||
int ww=rect.right-rect.left,wh=rect.bottom-rect.top;
|
||||
if(width<30||height<10||x<0||y<0||x+width>ww||y+height>wh||uint64_t(ww)*wh>16000000) return {};
|
||||
HDC dc=CreateCompatibleDC(nullptr);BITMAPINFO bi{};bi.bmiHeader.biSize=sizeof(BITMAPINFOHEADER);
|
||||
bi.bmiHeader.biWidth=ww;bi.bmiHeader.biHeight=-wh;bi.bmiHeader.biPlanes=1;bi.bmiHeader.biBitCount=32;
|
||||
void *bits{};HBITMAP bitmap=CreateDIBSection(dc,&bi,DIB_RGB_COLORS,&bits,nullptr,0);
|
||||
if(!bitmap){DeleteDC(dc);return {};}
|
||||
auto old=SelectObject(dc,bitmap);Pixels p;
|
||||
if(PrintWindow(window,dc,2)) {
|
||||
p.width=width;p.height=height;p.bgra.resize(size_t(width)*height*4);
|
||||
for(int row=0;row<height;++row) memcpy(p.bgra.data()+size_t(row)*width*4,(BYTE*)bits+(size_t(y+row)*ww+x)*4,size_t(width)*4);
|
||||
}
|
||||
SelectObject(dc,old);DeleteObject(bitmap);DeleteDC(dc);return p;
|
||||
}
|
||||
}
|
||||
std::wstring cachedViberChat(HWND window) {
|
||||
std::lock_guard lock(viberMutex);
|
||||
return window==viberWindow && GetTickCount64()-viberTime<2000 ? viberKey : L"";
|
||||
}
|
||||
std::wstring recognizeViberChat(HWND window,const Settings &settings) {
|
||||
std::wstring key;
|
||||
try {
|
||||
auto hr=CoInitializeEx(nullptr,COINIT_MULTITHREADED);
|
||||
struct Apartment {bool owned;~Apartment(){if(owned)CoUninitialize();}} apartment{SUCCEEDED(hr)};
|
||||
auto context=SetThreadDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2);
|
||||
struct Dpi {DPI_AWARENESS_CONTEXT old;~Dpi(){if(old)SetThreadDpiAwarenessContext(old);}} dpi{context};
|
||||
auto before=viberHeader(window);
|
||||
if(!before.bgra.empty()) {
|
||||
Settings options=settings;options.useTesseract=true;
|
||||
Clip clip;clip.formats.push_back(imageDib(before));
|
||||
auto title=recognizeText(clip,options);
|
||||
while(!title.empty() && iswspace(title.back())) title.pop_back();
|
||||
while(!title.empty() && iswspace(title.front())) title.erase(0,1);
|
||||
auto after=viberHeader(window);
|
||||
if(!title.empty() && title.size()<512 && title.find_first_of(L"\r\n")==title.npos && before.width==after.width && before.height==after.height && before.bgra==after.bgra)
|
||||
key=L"viber\n"+title;
|
||||
}
|
||||
} catch(...) {}
|
||||
{std::lock_guard lock(viberMutex);viberWindow=window;viberKey=key;viberTime=GetTickCount64();}
|
||||
return key;
|
||||
}
|
||||
}
|
||||
@@ -19,7 +19,7 @@ void contextChecks()
|
||||
require(ks::chatKey(L"Telegram", L"Тестовий чат") == key, "stable unread profile");
|
||||
require(ks::chatKey(L"Telegram", L"Team (2026)") == L"telegram\nTeam (2026)", "preserve parentheses");
|
||||
require(ks::chatKey(L"Telegram", L"Telegram").empty(), "no profile on home");
|
||||
require(ks::chatKey(L"Viber", L"Rakuten Viber").empty(), "unsupported app");
|
||||
require(ks::chatKey(L"Viber", L"Rakuten Viber").empty(), "Viber generic window title is not a chat");
|
||||
require(ks::chatKey(L"ms-teams", L"Chat | Alice | Microsoft Teams") == L"ms-teams\nAlice", "Teams chat");
|
||||
require(ks::chatKey(L"ms-teams", L"Calendar | Alice | Microsoft Teams").empty(), "Teams calendar excluded");
|
||||
require(ks::chatKey(L"ms-teams", L"Chat | Microsoft Teams").empty(), "Teams chat home excluded");
|
||||
@@ -27,6 +27,7 @@ void contextChecks()
|
||||
ks::Settings settings;
|
||||
settings.cycle = {L"win:04090409", L"win:04220422", L"win:04190419"};
|
||||
settings.chatCycles[key] = {settings.cycle[1], settings.cycle[0]};
|
||||
settings.chatCycles[L"viber\nТестовий контакт"] = {settings.cycle[1], settings.cycle[0]};
|
||||
std::vector<ks::Layout> installed(3);
|
||||
for (size_t i = 0; i < installed.size(); ++i)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user