Compare commits
36
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
727dc96908 | ||
|
|
ede4ce47c0 | ||
|
|
3b8b8f26fe | ||
|
|
19f1e4531c | ||
|
|
a124e030ab | ||
|
|
c18148a574 | ||
|
|
15197da548 | ||
|
|
66e24b5efc | ||
|
|
178573233b | ||
|
|
4e7a683c47 | ||
|
|
e33387c2d5 | ||
|
|
5de5b791bf | ||
|
|
c109408a98 | ||
|
|
90b2e0841f | ||
|
|
6621a49022 | ||
|
|
a2b88f247c | ||
|
|
684ca1b3cc | ||
|
|
524a836cc0 | ||
|
|
00c9cb0ee4 | ||
|
|
fa2f6d2ce4 | ||
|
|
30e70192dc | ||
|
|
94cab4c112 | ||
|
|
d13e9849a7 | ||
|
|
004fee4976 | ||
|
|
b08c5ff8ff | ||
|
|
b6e7bda220 | ||
|
|
89e506faae | ||
|
|
c78b51d341 | ||
|
|
0184b837f4 | ||
|
|
ca553a5e7d | ||
|
|
55993c0f90 | ||
|
|
738c81dce2 | ||
|
|
22edece7cf | ||
|
|
908985d775 | ||
|
|
20f3b72287 | ||
|
|
9b231146cb |
No files matched your search
+97
-3
@@ -1,14 +1,28 @@
|
|||||||
cmake_minimum_required(VERSION 3.24)
|
cmake_minimum_required(VERSION 3.24)
|
||||||
project(KSwitcher VERSION 0.6.22 LANGUAGES CXX RC)
|
project(KSwitcher VERSION 0.6.53 LANGUAGES CXX RC)
|
||||||
if(NOT WIN32)
|
if(NOT WIN32)
|
||||||
message(FATAL_ERROR "KSwitcher uses native Windows APIs")
|
message(FATAL_ERROR "KSwitcher uses native Windows APIs")
|
||||||
endif()
|
endif()
|
||||||
set(CMAKE_CXX_STANDARD 20)
|
set(CMAKE_CXX_STANDARD 20)
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
add_library(kscore src/core.cpp src/platform.cpp src/autostart.cpp src/autocorrect.cpp src/storage.cpp src/ocr.cpp src/richtext.cpp src/update.cpp)
|
add_executable(StayHere WIN32 utilities/StayHere/main.cpp)
|
||||||
|
add_executable(StayHereTest WIN32 utilities/StayHere/main.cpp)
|
||||||
|
target_compile_definitions(StayHereTest PRIVATE STAYHERE_TEST_INSTANCE)
|
||||||
|
set_target_properties(StayHere PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/tools")
|
||||||
|
foreach(utilityTarget StayHere StayHereTest)
|
||||||
|
target_compile_definitions(${utilityTarget} PRIVATE UNICODE _UNICODE _WIN32_WINNT=0x0A00)
|
||||||
|
target_link_libraries(${utilityTarget} PRIVATE user32 shell32 gdi32 wtsapi32)
|
||||||
|
if(MSVC)
|
||||||
|
target_compile_options(${utilityTarget} PRIVATE /utf-8)
|
||||||
|
set_property(TARGET ${utilityTarget} PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
|
||||||
|
else()
|
||||||
|
target_link_options(${utilityTarget} PRIVATE -municode -static -static-libgcc -static-libstdc++)
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
add_library(kscore src/core.cpp src/platform.cpp src/autostart.cpp src/autocorrect.cpp src/storage.cpp src/ocr.cpp src/richtext.cpp src/update.cpp src/sync.cpp)
|
||||||
target_include_directories(kscore PUBLIC src PRIVATE vendor)
|
target_include_directories(kscore PUBLIC src PRIVATE vendor)
|
||||||
target_compile_definitions(kscore PUBLIC UNICODE _UNICODE WIN32_LEAN_AND_MEAN NOMINMAX _WIN32_WINNT=0x0A00)
|
target_compile_definitions(kscore PUBLIC UNICODE _UNICODE WIN32_LEAN_AND_MEAN NOMINMAX _WIN32_WINNT=0x0A00)
|
||||||
target_link_libraries(kscore PUBLIC user32 shell32 shlwapi advapi32 crypt32 imm32 comctl32 gdi32 ole32 oleaut32 taskschd comdlg32 uuid windowscodecs runtimeobject uiautomationcore)
|
target_link_libraries(kscore PUBLIC winhttp user32 shell32 shlwapi advapi32 crypt32 imm32 comctl32 gdi32 ole32 oleaut32 taskschd comdlg32 uuid windowscodecs runtimeobject uiautomationcore)
|
||||||
add_executable(KSwitcher WIN32 src/main.cpp src/app.cpp src/screenshot_notifications.cpp src/screenshot_launcher.cpp src/screenshot_activation.cpp src/configuration.cpp src/ui.cpp resources/app.rc)
|
add_executable(KSwitcher WIN32 src/main.cpp src/app.cpp src/screenshot_notifications.cpp src/screenshot_launcher.cpp src/screenshot_activation.cpp src/configuration.cpp src/ui.cpp resources/app.rc)
|
||||||
target_compile_definitions(KSwitcher PRIVATE KS_RESIDENT_APP)
|
target_compile_definitions(KSwitcher PRIVATE KS_RESIDENT_APP)
|
||||||
target_link_libraries(KSwitcher PRIVATE kscore)
|
target_link_libraries(KSwitcher PRIVATE kscore)
|
||||||
@@ -17,11 +31,28 @@ set_target_properties(KSwitcherConfig PROPERTIES OUTPUT_NAME "KSwitcher.Config")
|
|||||||
target_compile_definitions(KSwitcherConfig PRIVATE KS_CONFIG_APP)
|
target_compile_definitions(KSwitcherConfig PRIVATE KS_CONFIG_APP)
|
||||||
target_link_libraries(KSwitcherConfig PRIVATE kscore)
|
target_link_libraries(KSwitcherConfig PRIVATE kscore)
|
||||||
add_executable(KSwitcherTests tests/tests.cpp)
|
add_executable(KSwitcherTests tests/tests.cpp)
|
||||||
|
add_executable(KSwitcherSyncTests tests/sync.cpp)
|
||||||
|
target_include_directories(KSwitcherSyncTests PRIVATE vendor)
|
||||||
|
target_link_libraries(KSwitcherSyncTests PRIVATE kscore)
|
||||||
|
if(MSVC)
|
||||||
|
set_property(TARGET KSwitcherSyncTests PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
|
||||||
|
else()
|
||||||
|
target_link_options(KSwitcherSyncTests PRIVATE -static -static-libgcc -static-libstdc++)
|
||||||
|
endif()
|
||||||
add_executable(KSwitcherScrollTests tests/scroll.cpp)
|
add_executable(KSwitcherScrollTests tests/scroll.cpp)
|
||||||
target_link_libraries(KSwitcherScrollTests PRIVATE kscore)
|
target_link_libraries(KSwitcherScrollTests PRIVATE kscore)
|
||||||
target_link_libraries(KSwitcherTests PRIVATE kscore)
|
target_link_libraries(KSwitcherTests PRIVATE kscore)
|
||||||
add_executable(KSwitcherIntegration tests/integration.cpp src/screenshot_launcher.cpp src/screenshot_activation.cpp src/app.cpp src/screenshot_notifications.cpp src/screenshot.cpp src/configuration.cpp src/ui.cpp resources/app.rc)
|
add_executable(KSwitcherIntegration tests/integration.cpp src/screenshot_launcher.cpp src/screenshot_activation.cpp src/app.cpp src/screenshot_notifications.cpp src/screenshot.cpp src/configuration.cpp src/ui.cpp resources/app.rc)
|
||||||
target_link_libraries(KSwitcherIntegration PRIVATE kscore)
|
target_link_libraries(KSwitcherIntegration PRIVATE kscore)
|
||||||
|
# Opt-in interactive fixture: requires an installed Far Manager.
|
||||||
|
add_executable(KSwitcherFarSnippetTests WIN32 tests/far_snippets.cpp src/screenshot_launcher.cpp src/screenshot_activation.cpp src/app.cpp src/screenshot_notifications.cpp src/screenshot.cpp src/configuration.cpp src/ui.cpp resources/app.rc)
|
||||||
|
target_link_libraries(KSwitcherFarSnippetTests PRIVATE kscore)
|
||||||
|
if(MSVC)
|
||||||
|
target_compile_options(KSwitcherFarSnippetTests PRIVATE /utf-8)
|
||||||
|
set_property(TARGET KSwitcherFarSnippetTests PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
|
||||||
|
else()
|
||||||
|
target_link_options(KSwitcherFarSnippetTests PRIVATE -municode -static -static-libgcc -static-libstdc++)
|
||||||
|
endif()
|
||||||
add_executable(KSwitcherInputTests tests/input.cpp src/screenshot_launcher.cpp src/screenshot_activation.cpp src/app.cpp src/screenshot_notifications.cpp src/screenshot.cpp src/configuration.cpp src/ui.cpp resources/app.rc)
|
add_executable(KSwitcherInputTests tests/input.cpp src/screenshot_launcher.cpp src/screenshot_activation.cpp src/app.cpp src/screenshot_notifications.cpp src/screenshot.cpp src/configuration.cpp src/ui.cpp resources/app.rc)
|
||||||
target_link_libraries(KSwitcherInputTests PRIVATE kscore)
|
target_link_libraries(KSwitcherInputTests PRIVATE kscore)
|
||||||
target_compile_definitions(KSwitcherInputTests PRIVATE KS_SCREENSHOT_RESOURCES)
|
target_compile_definitions(KSwitcherInputTests PRIVATE KS_SCREENSHOT_RESOURCES)
|
||||||
@@ -40,6 +71,7 @@ else()
|
|||||||
endif()
|
endif()
|
||||||
add_executable(KSwitcherOcrTests tests/ocr.cpp src/screenshot_launcher.cpp src/screenshot_activation.cpp src/app.cpp src/screenshot_notifications.cpp src/screenshot.cpp src/configuration.cpp src/ui.cpp resources/app.rc)
|
add_executable(KSwitcherOcrTests tests/ocr.cpp src/screenshot_launcher.cpp src/screenshot_activation.cpp src/app.cpp src/screenshot_notifications.cpp src/screenshot.cpp src/configuration.cpp src/ui.cpp resources/app.rc)
|
||||||
target_link_libraries(KSwitcherOcrTests PRIVATE kscore)
|
target_link_libraries(KSwitcherOcrTests PRIVATE kscore)
|
||||||
|
add_dependencies(KSwitcherOcrTests KSwitcherScreenshot)
|
||||||
if(MSVC)
|
if(MSVC)
|
||||||
set_property(TARGET kscore KSwitcher KSwitcherConfig KSwitcherScreenshot KSwitcherTests KSwitcherScrollTests KSwitcherIntegration KSwitcherInputTests KSwitcherOcrTests PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
|
set_property(TARGET kscore KSwitcher KSwitcherConfig KSwitcherScreenshot KSwitcherTests KSwitcherScrollTests KSwitcherIntegration KSwitcherInputTests KSwitcherOcrTests PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
|
||||||
target_compile_options(kscore PRIVATE /W4 /utf-8)
|
target_compile_options(kscore PRIVATE /W4 /utf-8)
|
||||||
@@ -57,10 +89,72 @@ else()
|
|||||||
target_link_options(KSwitcherOcrTests PRIVATE -static -static-libgcc -static-libstdc++)
|
target_link_options(KSwitcherOcrTests PRIVATE -static -static-libgcc -static-libstdc++)
|
||||||
endif()
|
endif()
|
||||||
enable_testing()
|
enable_testing()
|
||||||
|
add_executable(KSwitcherChatProfileTests tests/chat_profiles.cpp src/screenshot_launcher.cpp src/screenshot_activation.cpp src/app.cpp src/screenshot_notifications.cpp src/screenshot.cpp src/configuration.cpp src/ui.cpp resources/app.rc)
|
||||||
|
target_link_libraries(KSwitcherChatProfileTests PRIVATE kscore)
|
||||||
|
if(MSVC)
|
||||||
|
target_compile_options(KSwitcherChatProfileTests PRIVATE /utf-8)
|
||||||
|
set_property(TARGET KSwitcherChatProfileTests PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
|
||||||
|
else()
|
||||||
|
target_link_options(KSwitcherChatProfileTests PRIVATE -static -static-libgcc -static-libstdc++)
|
||||||
|
endif()
|
||||||
|
add_test(NAME chat-profile-regressions COMMAND KSwitcherChatProfileTests)
|
||||||
|
add_executable(KSwitcherHistoryHostTests tests/history_host.cpp)
|
||||||
|
target_link_libraries(KSwitcherHistoryHostTests PRIVATE kscore psapi)
|
||||||
|
set_target_properties(KSwitcherHistoryHostTests PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/history-host-fixture-$<CONFIG>")
|
||||||
|
add_dependencies(KSwitcherHistoryHostTests KSwitcher KSwitcherScreenshot)
|
||||||
|
add_custom_command(TARGET KSwitcherHistoryHostTests POST_BUILD
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E copy "$<TARGET_FILE:KSwitcher>" "$<TARGET_FILE_DIR:KSwitcherHistoryHostTests>/KSwitcher.exe"
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E copy "$<TARGET_FILE:KSwitcherScreenshot>" "$<TARGET_FILE_DIR:KSwitcherHistoryHostTests>/KSwitcher.Screenshot.exe"
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E touch "$<TARGET_FILE_DIR:KSwitcherHistoryHostTests>/.local-dev")
|
||||||
|
if(MSVC)
|
||||||
|
target_compile_options(KSwitcherHistoryHostTests PRIVATE /utf-8)
|
||||||
|
set_property(TARGET KSwitcherHistoryHostTests PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
|
||||||
|
else()
|
||||||
|
target_link_options(KSwitcherHistoryHostTests PRIVATE -static -static-libgcc -static-libstdc++)
|
||||||
|
endif()
|
||||||
|
add_executable(KSwitcherClipboardSnapshotTests tests/clipboard_snapshot.cpp)
|
||||||
|
target_link_libraries(KSwitcherClipboardSnapshotTests PRIVATE kscore psapi)
|
||||||
|
add_dependencies(KSwitcherClipboardSnapshotTests KSwitcherScreenshot)
|
||||||
|
if(MSVC)
|
||||||
|
target_compile_options(KSwitcherClipboardSnapshotTests PRIVATE /utf-8)
|
||||||
|
set_property(TARGET KSwitcherClipboardSnapshotTests PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
|
||||||
|
else()
|
||||||
|
target_link_options(KSwitcherClipboardSnapshotTests PRIVATE -static -static-libgcc -static-libstdc++)
|
||||||
|
endif()
|
||||||
|
add_executable(KSwitcherImageCaptureTests tests/image_capture.cpp)
|
||||||
|
target_link_libraries(KSwitcherImageCaptureTests PRIVATE kscore)
|
||||||
|
add_dependencies(KSwitcherImageCaptureTests KSwitcherScreenshot)
|
||||||
|
if(MSVC)
|
||||||
|
target_compile_options(KSwitcherImageCaptureTests PRIVATE /utf-8)
|
||||||
|
set_property(TARGET KSwitcherImageCaptureTests PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
|
||||||
|
else()
|
||||||
|
target_link_options(KSwitcherImageCaptureTests PRIVATE -static -static-libgcc -static-libstdc++)
|
||||||
|
endif()
|
||||||
|
# Explicit interactive test: stop the resident first so its clipboard listener
|
||||||
|
# does not capture the test fixtures. Like KSwitcherIntegration, not part of ctest.
|
||||||
|
add_executable(KSwitcherDictionaryTests tests/dictionary.cpp)
|
||||||
|
target_link_libraries(KSwitcherDictionaryTests PRIVATE kscore psapi)
|
||||||
|
if(MSVC)
|
||||||
|
set_property(TARGET KSwitcherDictionaryTests PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
|
||||||
|
else()
|
||||||
|
target_link_options(KSwitcherDictionaryTests PRIVATE -static -static-libgcc -static-libstdc++)
|
||||||
|
endif()
|
||||||
|
add_test(NAME dictionary-regressions COMMAND KSwitcherDictionaryTests)
|
||||||
|
set_tests_properties(dictionary-regressions PROPERTIES WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||||
|
add_test(NAME sync-regressions COMMAND KSwitcherSyncTests)
|
||||||
add_test(NAME native-regressions COMMAND KSwitcherTests)
|
add_test(NAME native-regressions COMMAND KSwitcherTests)
|
||||||
|
add_executable(KSwitcherUtilitiesTests tests/utilities.cpp)
|
||||||
|
if(MSVC)
|
||||||
|
set_property(TARGET KSwitcherUtilitiesTests PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
|
||||||
|
else()
|
||||||
|
target_link_options(KSwitcherUtilitiesTests PRIVATE -static -static-libgcc -static-libstdc++)
|
||||||
|
endif()
|
||||||
|
add_test(NAME utilities-regressions COMMAND KSwitcherUtilitiesTests)
|
||||||
|
add_test(NAME stayhere-lifecycle COMMAND powershell -NoProfile -ExecutionPolicy Bypass -File "${CMAKE_CURRENT_SOURCE_DIR}/tests/stayhere.ps1" -Executable "$<TARGET_FILE:StayHereTest>")
|
||||||
add_test(NAME scroll-regressions COMMAND KSwitcherScrollTests)
|
add_test(NAME scroll-regressions COMMAND KSwitcherScrollTests)
|
||||||
add_test(NAME input-regressions COMMAND KSwitcherInputTests)
|
add_test(NAME input-regressions COMMAND KSwitcherInputTests)
|
||||||
add_test(NAME screenshot-ui-regressions COMMAND KSwitcherScreenshotUITests)
|
add_test(NAME screenshot-ui-regressions COMMAND KSwitcherScreenshotUITests)
|
||||||
|
add_test(NAME screenshot-save-regressions COMMAND KSwitcherScreenshotUITests --save-only)
|
||||||
add_test(NAME updater-regressions COMMAND powershell.exe -NoProfile -ExecutionPolicy Bypass -File "${CMAKE_CURRENT_SOURCE_DIR}/tests/update.ps1" -Executable "$<TARGET_FILE:KSwitcher>")
|
add_test(NAME updater-regressions COMMAND powershell.exe -NoProfile -ExecutionPolicy Bypass -File "${CMAKE_CURRENT_SOURCE_DIR}/tests/update.ps1" -Executable "$<TARGET_FILE:KSwitcher>")
|
||||||
set_tests_properties(native-regressions PROPERTIES WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}")
|
set_tests_properties(native-regressions PROPERTIES WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||||
install(TARGETS KSwitcher KSwitcherConfig KSwitcherScreenshot RUNTIME DESTINATION .)
|
install(TARGETS KSwitcher KSwitcherConfig KSwitcherScreenshot RUNTIME DESTINATION .)
|
||||||
|
|||||||
@@ -16,6 +16,16 @@ Run `build/KSwitcher.exe`, or extract `dist/KSwitcher-win-x64.zip` and run the e
|
|||||||
The build also refreshes the release copy in `build/release/`. Exit KSwitcher before rebuilding.
|
The build also refreshes the release copy in `build/release/`. Exit KSwitcher before rebuilding.
|
||||||
The application lives in the notification area. Right-click its icon for Settings, Snippets and history.
|
The application lives in the notification area. Right-click its icon for Settings, Snippets and history.
|
||||||
Double-click the tray icon to open Settings, the bold default menu item.
|
Double-click the tray icon to open Settings, the bold default menu item.
|
||||||
|
Closing Settings with unsaved changes (including accepted auto-correction or OCR options)
|
||||||
|
asks whether to save, discard changes, or keep editing. Unchanged settings close without a prompt.
|
||||||
|
If saving fails, the window stays open with your edits intact.
|
||||||
|
Menus support access keys: press the underlined letter while the menu is open (for example,
|
||||||
|
S for Settings or X for Exit in the tray menu). In forms, press Alt+the underlined letter
|
||||||
|
to activate a button, toggle a checkbox or focus a labeled field. Dialog underline visibility
|
||||||
|
still follows Windows preferences; press Alt in a dialog to reveal them.
|
||||||
|
From v0.6.33, tray and history menus show access letters in the right-hand column.
|
||||||
|
Press the menu letter without Alt: Alt dismisses an open menu. Shortcut-capture fields still record Alt combinations;
|
||||||
|
press Tab to leave a shortcut field before using form access keys.
|
||||||
Settings, the snippet editor and log viewer run on demand in **KSwitcher.Config.exe**, beside the main executable.
|
Settings, the snippet editor and log viewer run on demand in **KSwitcher.Config.exe**, beside the main executable.
|
||||||
Repeated launches activate the existing configurator; closing its last window exits that process.
|
Repeated launches activate the existing configurator; closing its last window exits that process.
|
||||||
Saving applies changes immediately through the resident KSwitcher process. The configurator does not
|
Saving applies changes immediately through the resident KSwitcher process. The configurator does not
|
||||||
@@ -65,6 +75,9 @@ Ctrl+Alt+Delete and Win+L; these cannot be assigned.
|
|||||||
|
|
||||||
Keyboard and mouse input forwarded by Microsoft Mouse Without Borders follows the same input
|
Keyboard and mouse input forwarded by Microsoft Mouse Without Borders follows the same input
|
||||||
path as a local keyboard/mouse, including shortcuts, recent-word conversion and snippets.
|
path as a local keyboard/mouse, including shortcuts, recent-word conversion and snippets.
|
||||||
|
On the sending computer, KSwitcher ignores keyboard events consumed by another keyboard hook
|
||||||
|
(including Mouse Without Borders forwarding). The receiving computer still processes delivered
|
||||||
|
input normally, so both computers can run KSwitcher without starting duplicate snippet operations.
|
||||||
KSwitcher marks its own generated input so copy/paste, selection, modifier releases and shell-mask
|
KSwitcher marks its own generated input so copy/paste, selection, modifier releases and shell-mask
|
||||||
keys cannot trigger recursive commands or overwrite the recorded typing run. Other injected input
|
keys cannot trigger recursive commands or overwrite the recorded typing run. Other injected input
|
||||||
is accepted, including key-up events and VK-only keyboard events. Unicode packets do not provide
|
is accepted, including key-up events and VK-only keyboard events. Unicode packets do not provide
|
||||||
@@ -90,6 +103,10 @@ broker can load them even when the profile directory is inaccessible to it.
|
|||||||
Notifications expire after 24 hours. Cache cleanup runs on capture/open; each cache is bounded to
|
Notifications expire after 24 hours. Cache cleanup runs on capture/open; each cache is bounded to
|
||||||
40 files and 256 MiB. Expired or evicted notifications cannot reopen their screenshot.
|
40 files and 256 MiB. Expired or evicted notifications cannot reopen their screenshot.
|
||||||
In the editor, **Ctrl+C** or **Enter** copies the current result without closing the window.
|
In the editor, **Ctrl+C** or **Enter** copies the current result without closing the window.
|
||||||
|
**Save… / Ctrl+S** saves the full-resolution image and annotations as PNG. The first save asks
|
||||||
|
for a file; later saves update that file. **Ctrl+Shift+S (Save As…)** always asks for a new
|
||||||
|
destination. Saving keeps the editor open and leaves the clipboard unchanged. Further edits
|
||||||
|
must be saved or copied again before closing without a warning.
|
||||||
The editor starts with **Pencil / Freehand (F)** for drawing. Choose **Pointer (V)** to select objects, move them, and edit geometry, thickness and
|
The editor starts with **Pencil / Freehand (F)** for drawing. Choose **Pointer (V)** to select objects, move them, and edit geometry, thickness and
|
||||||
other properties using handles and controls. Clicking empty space clears selection; dragging empty
|
other properties using handles and controls. Clicking empty space clears selection; dragging empty
|
||||||
space adds nothing. Choose a drawing tool to create objects, then return to **V** to edit them.
|
space adds nothing. Choose a drawing tool to create objects, then return to **V** to edit them.
|
||||||
@@ -107,10 +124,10 @@ change its diameter. Wheel up increases the size; wheel down decreases it. These
|
|||||||
and update linked arrows. **Ctrl+D** clones the selected object with a small offset. A cloned number
|
and update linked arrows. **Ctrl+D** clones the selected object with a small offset. A cloned number
|
||||||
gets the smallest available positive number, just like a newly placed number: gaps left by deletion
|
gets the smallest available positive number, just like a newly placed number: gaps left by deletion
|
||||||
are filled first, without renumbering existing objects. A cloned arrow keeps its style but starts without endpoint links.
|
are filled first, without renumbering existing objects. A cloned arrow keeps its style but starts without endpoint links.
|
||||||
Arrow and line endpoints can attach to numbered markers, rectangles, circles, ellipses, text blocks,
|
Arrow and line endpoints can attach to numbered markers, rectangles, circles, ellipses, triangles, trapezoids, text blocks,
|
||||||
and other arrows or strokes. In Arrow or Straight line mode, hold **Ctrl** and drag from one object
|
and other arrows or strokes. In Arrow or Straight line mode, hold **Ctrl** and drag from one object
|
||||||
to another to draw over them and automatically attach both endpoints. Without Ctrl, existing objects
|
to another to draw over them and automatically attach both endpoints. Without Ctrl, existing objects
|
||||||
can still be selected and edited as before. With Pointer, drag an existing endpoint onto a target to attach it. Attached endpoints follow movement and resizing; text attachments
|
can still be selected and edited as before. With Pointer, drag an existing endpoint onto a target to attach it. Attached endpoints follow movement and resizing; shape and text attachments
|
||||||
also follow rotation. Arrow-to-arrow attachments retain their relative position along the target line.
|
also follow rotation. Arrow-to-arrow attachments retain their relative position along the target line.
|
||||||
Clicking a connector or adding/editing its caption preserves its links. Moving the whole connector
|
Clicking a connector or adding/editing its caption preserves its links. Moving the whole connector
|
||||||
intentionally detaches its endpoints; moving one endpoint detaches only that end. Deleting a target
|
intentionally detaches its endpoints; moving one endpoint detaches only that end. Deleting a target
|
||||||
@@ -158,7 +175,45 @@ resize; circles keep equal width and height. Move shapes by their outlines, adju
|
|||||||
the mouse wheel or side handle, recolor, clone with Ctrl+D, and undo/redo as with other objects.
|
the mouse wheel or side handle, recolor, clone with Ctrl+D, and undo/redo as with other objects.
|
||||||
Hold Ctrl to start drawing over an existing object. Line style applies to outlines; Ends is disabled
|
Hold Ctrl to start drawing over an existing object. Line style applies to outlines; Ends is disabled
|
||||||
for shapes.
|
for shapes.
|
||||||
|
**Canvas zoom:** use **Ctrl++ / Ctrl+-** (including numpad keys) or **Ctrl+mouse wheel**.
|
||||||
|
Each step changes the view by 25%; the wheel zooms around the cursor, keyboard shortcuts around
|
||||||
|
the viewport center. **Ctrl+0** restores the initial fit. Drag with the **middle mouse button**
|
||||||
|
to pan an enlarged image. Panning is limited to axes where the image exceeds the viewport;
|
||||||
|
an image that fits stays centered. Zoom ranges from 0.1× to 16× the initial fit; the status bar shows the
|
||||||
|
actual image scale. Zoom and pan do not change annotations, export resolution or undo history.
|
||||||
|
The wheel without Ctrl still adjusts the object under the cursor.
|
||||||
|
|
||||||
**Freehand line (F)** draws an opaque curve by following the mouse. The curve is one object:
|
**Freehand line (F)** draws an opaque curve by following the mouse. The curve is one object:
|
||||||
|
after mouse release, nearly straight strokes become editable straight lines at their drawn angle,
|
||||||
|
preserving endpoints, color, thickness, line style and arrowheads. Short strokes, broad curves and
|
||||||
|
retraced strokes are not straightened. Other strokes receive light smoothing to reduce jitter.
|
||||||
|
Confidently recognized closed outlines become
|
||||||
|
rectangles, circles, ellipses, triangles or trapezoids (including tilted outlines), stored as shape objects.
|
||||||
|
Drag either bounding-box corner handle to resize the entire recognized outline; circles keep equal
|
||||||
|
width and height. Shapes can also be moved, recolored and cloned.
|
||||||
|
Every shape has a round rotation handle above its outline. Drag it to rotate around the center;
|
||||||
|
hold **Shift** for 15-degree steps. The handle works for toolbar shapes and recognized shapes,
|
||||||
|
including triangles. Resize handles and attached connectors follow the rotation; Ctrl+Z/Ctrl+Y
|
||||||
|
undo and redo it. The square handle still controls outline thickness.
|
||||||
|
From v0.6.34, endpoint, shape-corner and number-radius handles show the four-direction move cursor.
|
||||||
|
Thickness handles retain directional resize cursors; rotation retains the hand cursor. Dragging,
|
||||||
|
snapping and shape constraints are unchanged.
|
||||||
|
**Triangle (G)** is also available directly on the toolbar: drag to create a triangle.
|
||||||
|
Both drawn and recognized triangles have three independent vertex handles instead of bounding-box
|
||||||
|
resize handles. Drag any vertex to reshape the triangle while keeping the other two fixed, even
|
||||||
|
after rotation. Vertex edits support undo/redo, and the rotation and thickness handles remain available.
|
||||||
|
**Arc (U)** draws an open half ellipse inside the dragged rectangle. Use the corner handles
|
||||||
|
to resize it and the round handle to rotate it (Shift snaps to 15 degrees). Arcs support
|
||||||
|
color, thickness, line style, moving, cloning, undo/redo and PNG export.
|
||||||
|
|
||||||
|
**Trapezoid (B)** on the toolbar creates a trapezoid with parallel bases. Pencil recognition also
|
||||||
|
fits nearly parallel, unequal bases into a clean trapezoid. Trapezoids support bounding-box resizing,
|
||||||
|
rotation, styling and undo/redo; Ctrl+Z after recognition restores the original pencil stroke.
|
||||||
|
Oval fitting tolerates uneven contours and small closing gaps or overlaps; broad open arcs and
|
||||||
|
repeated loops remain freehand strokes.
|
||||||
|
Press **Ctrl+Z** once to restore the original stroke, again to remove it; **Ctrl+Y** reapplies the improvement.
|
||||||
|
Small strokes, strokes linked to other objects, and any stroke drawn partly with Shift are left unchanged.
|
||||||
|
Ambiguous shapes are only smoothed. To edit the resulting curve,
|
||||||
move it, change its color or thickness, clone it, or drag its endpoints. Hold Ctrl to start a new
|
move it, change its color or thickness, clone it, or drag its endpoints. Hold Ctrl to start a new
|
||||||
stroke over an existing object. Hold **Shift** while drawing to constrain the current segment
|
stroke over an existing object. Hold **Shift** while drawing to constrain the current segment
|
||||||
to a horizontal, vertical or 45-degree diagonal line; release Shift to resume freehand drawing in the same stroke.
|
to a horizontal, vertical or 45-degree diagonal line; release Shift to resume freehand drawing in the same stroke.
|
||||||
@@ -168,7 +223,7 @@ released repeatedly within one stroke. The **Line style** selector supports Soli
|
|||||||
Dash-dot; **Ends** supports an arrow at the end, start, both ends, or no arrows. These settings
|
Dash-dot; **Ends** supports an arrow at the end, start, both ends, or no arrows. These settings
|
||||||
apply to selected straight/freehand lines and set defaults for subsequent lines. Both are disabled
|
apply to selected straight/freehand lines and set defaults for subsequent lines. Both are disabled
|
||||||
for numbered markers and highlights unless a line drawing tool is active. Undo/Redo includes style changes.
|
for numbered markers and highlights unless a line drawing tool is active. Undo/Redo includes style changes.
|
||||||
The window close button asks for confirmation before discarding an uncopied screenshot.
|
The window close button asks for confirmation before discarding changes that have not been saved or copied.
|
||||||
**Escape** cancels region selection or inline text edits; it does not close the editor. Copy keeps the editor open and publishes the image
|
**Escape** cancels region selection or inline text edits; it does not close the editor. Copy keeps the editor open and publishes the image
|
||||||
at its original pixel size, ready to paste. The preview fits the window without changing export size.
|
at its original pixel size, ready to paste. The preview fits the window without changing export size.
|
||||||
The shortcut is configurable in Settings under **Screen capture**.
|
The shortcut is configurable in Settings under **Screen capture**.
|
||||||
@@ -219,6 +274,74 @@ thumbnails and source labels aligned with the scaled fonts and spacing.
|
|||||||
|
|
||||||
## Implemented
|
## Implemented
|
||||||
|
|
||||||
|
### Chat language profiles — v0.6.48
|
||||||
|
|
||||||
|
> From v0.6.50: Viber chat OCR is temporarily disabled. Saved Viber profiles are retained but inactive. Telegram and Teams profiles are unchanged; clipboard/image OCR remains available.
|
||||||
|
>
|
||||||
|
> З v0.6.50: 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.
|
||||||
|
|
||||||
|
Open the desired chat in Telegram Desktop or Microsoft Teams, then open Settings → Languages →
|
||||||
|
**Languages for a chat…**. Select the chat and click the languages to include. Choose
|
||||||
|
**Use languages**, then **Save** in Settings. The subset order is saved from the main
|
||||||
|
layout list when editing the profile; one-language profiles are supported. **Remove profile** restores default behavior.
|
||||||
|
|
||||||
|
For a matching chat, **Alt+Shift**, **Win+Space** (and reverse **Win+Shift+Space**) cycle
|
||||||
|
through that subset. KSwitcher's **Next layout** conversion uses the same subset.
|
||||||
|
Explicit KSwitcher hotkey bindings take precedence. Without a matching profile,
|
||||||
|
Windows shortcuts keep their normal behavior and Next layout uses the global cycle.
|
||||||
|
Unavailable layouts are skipped; if none remain installed, the global cycle is used.
|
||||||
|
Direct layout shortcuts are unchanged. Profiles do not change Windows' installed languages.
|
||||||
|
|
||||||
|
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 Teams title formats are not supported.
|
||||||
|
Experimental Viber profiles introduced in v0.6.49 are disabled in v0.6.50 because repeated OCR caused delays. There is no background Viber OCR, recognition during language switching, or recognition when opening profiles. Saved Viber profiles are retained and marked inactive; Windows switching and Next layout use their normal/global behavior in Viber. Clipboard and image OCR are unchanged.
|
||||||
|
From v0.6.53, chat profiles (application, visible chat name and ordered language IDs) are included in settings synchronization and manual export/import. Update every synchronizing PC to v0.6.53 or newer first: older clients reject this shared field. Profiles for different chats merge independently; conflicting edits or deletion versus editing of one chat require a choice. Missing Windows layouts stay saved and are skipped during switching, with global-cycle fallback if none are installed. Keep this PC's layouts preserves the global cycle and shortcuts while chat profiles still synchronize. Downloading a pre-v0.6.53 profile preserves existing chat profiles. Chat matching is unchanged; Viber profiles remain inactive.
|
||||||
|
|
||||||
|
**Українською.** Налаштування розділено на вкладки General, Languages, Shortcuts, Clipboard
|
||||||
|
і Tools. Перехід між ними зберігає незбережені зміни; Save, Cancel, Import і Export доступні
|
||||||
|
на кожній вкладці. Відкрий потрібний чат у Telegram або Teams, потім **Settings → Languages → Languages
|
||||||
|
for a chat…**. Вибери чат і потрібні мови, натисни **Use languages**, а потім **Save**.
|
||||||
|
Набір діє для **Alt+Shift**, **Win+Space**, **Win+Shift+Space** та **Next layout** KSwitcher.
|
||||||
|
Можна вибрати й одну мову; порядок зберігається із загального списку під час редагування профілю. **Remove profile**
|
||||||
|
повертає звичайну поведінку. Без профілю системні комбінації працюють як раніше,
|
||||||
|
а Next layout використовує загальний набір. Видалені з Windows розкладки пропускаються;
|
||||||
|
якщо доступних мов профілю не залишилося, використовується загальний набір.
|
||||||
|
Прямі комбінації мов не змінюються; явно задані комбінації KSwitcher мають пріоритет.
|
||||||
|
Зіставлення виконується за програмою та назвою чату: однакові назви в одній програмі
|
||||||
|
мають спільний профіль, після перейменування потрібен новий. Лічильник непрочитаних
|
||||||
|
Telegram ігнорується. Teams підтримує зазначений вище формат заголовка.
|
||||||
|
Експериментальні профілі Viber із v0.6.49 вимкнено у v0.6.50 через затримки від повторного OCR. Фонове розпізнавання, OCR при перемиканні мов та відкритті профілів більше не запускаються. Профілі Viber збережені й позначені як неактивні; системне перемикання та Next layout у Viber використовують звичайну поведінку й загальний набір. OCR буфера та зображень не змінено.
|
||||||
|
Профілі локальні, входять до ручного експорту/імпорту, але не до
|
||||||
|
хмарної синхронізації. Доступно з v0.6.48.
|
||||||
|
|
||||||
|
|
||||||
|
### Telegram Web in Chrome — v0.6.51
|
||||||
|
|
||||||
|
Open a chat in Telegram Web K (`https://web.telegram.org/k/`) in Chrome, then use **Settings → Languages → Languages for a chat...** and select **Telegram Web: name**. Choose languages, then **Use languages → Save**. The same subset applies to Alt+Shift, Win+Space, Win+Shift+Space and Next layout. Web profiles are separate from desktop Telegram profiles. Same-name chats across browser profiles/accounts share a web profile.
|
||||||
|
|
||||||
|
Recognition uses Chrome accessibility: the address bar and active document must both identify a Telegram chat, then the visible header supplies the name. The app watches foreground/focus and address/header-change events; it does not use OCR, a polling timer, an extension, or message-history extraction. The address bar, home page and unsupported URLs do not match. Web A and other browsers have not been validated and are not advertised as supported. Page or accessibility changes can make a chat unavailable instead of guessing.
|
||||||
|
|
||||||
|
**Українською.** З v0.6.51 підтримано Telegram Web K у Chrome. Відкрий чат, потім **Settings → Languages → Languages for a chat...**, вибери **Telegram Web: ім’я**, мови та **Use languages → Save**. Набір діє для Alt+Shift, Win+Space, Win+Shift+Space і Next layout. Вебпрофілі окремі від Telegram Desktop; однакові назви в різних акаунтах/профілях браузера мають спільний вебпрофіль. Адреса й назва беруться через accessibility, без OCR, таймера, розширення та читання історії повідомлень. В адресному рядку, на головній сторінці й для непідтримуваних адрес профіль не діє. Web A та інші браузери не перевірені й не заявлені як підтримувані.
|
||||||
|
|
||||||
|
### Application-specific snippets — v0.6.51
|
||||||
|
|
||||||
|
In **Tools → Snippets**, select a snippet and enable **Only in these applications**. Enter executable names separated by commas, or select a currently open application's process and choose **Add app**. For example: `ms-teams.exe, outlook.exe`. Uncheck the option for a global snippet. A checked but empty restriction cannot be saved. Save applies the changes; Cancel discards them.
|
||||||
|
|
||||||
|
A matching application-specific snippet takes precedence over a global snippet with the same trigger. The same trigger can be used for different applications; overlapping scopes for the same trigger are rejected. Existing snippets without a scope remain global. Matching is case-insensitive by process name, with or without `.exe`, and is checked before insertion. No OCR or timer is involved. Chrome scope means the entire browser, not one website.
|
||||||
|
|
||||||
|
Scopes are saved with snippets and included in manual import/export and synchronization; merge conflicts consider the application scopes. Use v0.6.51 or newer on every synchronizing PC before sharing scoped snippets: older versions do not understand the restriction and may treat the snippet as global.
|
||||||
|
|
||||||
|
**Українською.** У **Tools → Snippets** вибери сніпет, увімкни **Only in these applications** та задай назви процесів через кому або вибери відкриту програму зі списку й натисни **Add app**. Наприклад: `ms-teams.exe, outlook.exe`. Вимкнений прапорець означає всі програми. Увімкнений прапорець із порожнім списком не можна зберегти. **Save** зберігає, **Cancel** відкидає зміни.
|
||||||
|
|
||||||
|
Сніпет конкретної програми має пріоритет над глобальним із тим самим тригером. Для різних програм однакові тригери дозволені, для перетинних областей — ні. Старі сніпети залишаються глобальними. Зіставлення за назвою процесу не залежить від регістру та суфікса `.exe`; OCR і таймерів немає. Для Chrome це весь браузер, а не окремий сайт. Обмеження входять до експорту/імпорту та синхронізації. Перед синхронізацією онови всі ПК до v0.6.51 або новішої: старі версії не розуміють обмеження та можуть застосувати сніпет глобально.
|
||||||
|
### Existing features
|
||||||
|
|
||||||
- Installed Windows keyboard layouts, configurable cycle/order and direct shortcuts; IMEs are switch-only.
|
- Installed Windows keyboard layouts, configurable cycle/order and direct shortcuts; IMEs are switch-only.
|
||||||
Text conversion cycles skip layouts that leave the text unchanged and use the next enabled layout
|
Text conversion cycles skip layouts that leave the text unchanged and use the next enabled layout
|
||||||
that changes it. If none changes the text, the operation keeps the text and advances one layout.
|
that changes it. If none changes the text, the operation keeps the text and advances one layout.
|
||||||
@@ -226,13 +349,31 @@ thumbnails and source labels aligned with the scaled fonts and spacing.
|
|||||||
of the complete expected text. Browser/editor compatibility depends on its handling of simulated input.
|
of the complete expected text. Browser/editor compatibility depends on its handling of simulated input.
|
||||||
- Selection conversion and verified recent input (physical scan codes, 2-second typing-run boundary).
|
- Selection conversion and verified recent input (physical scan codes, 2-second typing-run boundary).
|
||||||
- Same-process clipboard ownership plus verified WebView2 descendants, including the Teams fix.
|
- Same-process clipboard ownership plus verified WebView2 descendants, including the Teams fix.
|
||||||
|
Clipboard synchronizers such as Mouse Without Borders may republish a copy only when
|
||||||
|
KSwitcher first observed it owned by the target application and the selection text and
|
||||||
|
editor selection metadata remain identical. Unobserved or altered foreign copies are rejected.
|
||||||
|
Snippets normally require accessibility verification of their selected trigger and pasted text,
|
||||||
|
even with logging disabled. If verification is unavailable or the paste differs, expansion
|
||||||
|
stops without running cursor or Enter actions. Clipboard changes during paste also cancel actions.
|
||||||
|
Far Manager uses its native Alt+Shift+Arrow selection, Ctrl+Insert copy and Shift+Insert
|
||||||
|
paste commands instead: both the trigger and inserted text must match verified clipboard
|
||||||
|
copies from Far. Cancellation restores the full temporary selection, not one cursor step.
|
||||||
|
Far supports nonempty single-line replacements up to 4096 caret steps, including
|
||||||
|
`{cursor}` and verified `{enter}` actions. Empty or multiline replacements are rejected
|
||||||
|
before selection; pasting a newline could execute a command before it can be verified.
|
||||||
- Teams recent-word conversion uses a single word-selection command and validates the copied range.
|
- Teams recent-word conversion uses a single word-selection command and validates the copied range.
|
||||||
If the editor's word boundary differs from the recorded typing, it falls back to paced character
|
If the editor's word boundary differs from the recorded typing, it falls back to paced character
|
||||||
selection: Teams can coalesce a burst of Shift+Left events into just one character.
|
selection: Teams can coalesce a burst of Shift+Left events into just one character.
|
||||||
- Clipboard snapshot/restoration with concurrent-copy, foreground and input-version checks.
|
- Clipboard snapshot/restoration with concurrent-copy, foreground and input-version checks.
|
||||||
|
A snapshot interrupted by a concurrent clipboard publication is retried up to three total
|
||||||
|
attempts before selection starts, provided the foreground and input context remain unchanged.
|
||||||
A silently dropped copy is retried up to three total attempts while the clipboard and input
|
A silently dropped copy is retried up to three total attempts while the clipboard and input
|
||||||
context remain unchanged. Temporary transaction contents are excluded from Windows clipboard
|
context remain unchanged. Temporary transaction contents are excluded from Windows clipboard
|
||||||
history and cloud synchronization. Paste is not blindly retried.
|
history and cloud synchronization. Paste is not blindly retried: with manual paste readback
|
||||||
|
enabled by Write log, a native Windows EDIT gets at most one retry when readback reports the
|
||||||
|
original and fresh native queries confirm that exactly the original range is still selected.
|
||||||
|
Other controls and unknown/changed selections are not retried. A verified failed paste clears
|
||||||
|
repeat-conversion state and does not switch the Windows layout.
|
||||||
- Case cycling, Russian/Ukrainian transliteration, verified undo and repeated conversion.
|
- Case cycling, Russian/Ukrainian transliteration, verified undo and repeated conversion.
|
||||||
- Text snippets across layouts, multiline insertion and a verified `{cursor}` position;
|
- Text snippets across layouts, multiline insertion and a verified `{cursor}` position;
|
||||||
`{enter}` presses Enter after insertion and cursor placement (once per marker), before buffered typing resumes.
|
`{enter}` presses Enter after insertion and cursor placement (once per marker), before buffered typing resumes.
|
||||||
@@ -282,6 +423,10 @@ existing saved shortcuts are preserved. While KSwitcher runs, this binding opens
|
|||||||
|
|
||||||
History controls: Enter to paste, Shift+Enter for plain text, Ctrl+1…9 for quick paste,
|
History controls: Enter to paste, Shift+Enter for plain text, Ctrl+1…9 for quick paste,
|
||||||
Ctrl+P to pin/unpin, Delete to delete, Ctrl+O for the full item, Escape to hide.
|
Ctrl+P to pin/unpin, Delete to delete, Ctrl+O for the full item, Escape to hide.
|
||||||
|
|
||||||
|
**Clear history… / Alt+H** in the history window clears all saved entries after confirmation,
|
||||||
|
including pinned entries and entries hidden by search. No is the default choice. The current
|
||||||
|
Windows clipboard and future recording are unchanged. Settings also retains its Clear history action.
|
||||||
For an image, **Edit image**, **Ctrl+O**, or **Edit image in screenshot editor**
|
For an image, **Edit image**, **Ctrl+O**, or **Edit image in screenshot editor**
|
||||||
in the context menu opens the original image in the built-in screenshot editor.
|
in the context menu opens the original image in the built-in screenshot editor.
|
||||||
Annotate it there, then copy the result. Opening the editor leaves the
|
Annotate it there, then copy the result. Opening the editor leaves the
|
||||||
@@ -297,7 +442,14 @@ the executable's directory is not writable. Each clipboard payload is an encrypt
|
|||||||
only bounded previews/metadata stay in memory. Image data is loaded on demand and released when
|
only bounded previews/metadata stay in memory. Image data is loaded on demand and released when
|
||||||
the history popup is hidden. Settings **Write log** (`writeLog`, enabled by default) controls all
|
the history popup is hidden. Settings **Write log** (`writeLog`, enabled by default) controls all
|
||||||
log writes. Disabling it also clears diagnostic context from memory; existing log files remain.
|
log writes. Disabling it also clears diagnostic context from memory; existing log files remain.
|
||||||
Diagnostic stages stay in a memory buffer of at most 40 events for 30 seconds.
|
Diagnostic stages stay in a memory buffer of at most 128 events for 30 seconds.
|
||||||
|
Selection diagnostics include the expected text, each copied candidate before and after suffix
|
||||||
|
recovery, paced Shift+Left progress or batch delivery counts, and clipboard sequence changes,
|
||||||
|
retry counts and elapsed times. Focus, caret geometry and keyboard layout are recorded when
|
||||||
|
Windows exposes them; selection offsets are available for native EDIT controls and explicitly
|
||||||
|
marked unavailable for other editors. Input interruptions identify keyboard, mouse, settings
|
||||||
|
or layout-refresh events during an operation. Failed selection verification includes the expected
|
||||||
|
selection and actual copied text in the operation details, without implying that a paste occurred.
|
||||||
Only problem operations write a structured summary to `kswitcher.log`, with their preceding
|
Only problem operations write a structured summary to `kswitcher.log`, with their preceding
|
||||||
context. Successful operations stay in that bounded memory buffer and are included only when
|
context. Successful operations stay in that bounded memory buffer and are included only when
|
||||||
a subsequent problem flushes it; they do not create separate rows. Flushed context is discarded. Ordinary application
|
a subsequent problem flushes it; they do not create separate rows. Flushed context is discarded. Ordinary application
|
||||||
@@ -349,6 +501,143 @@ This is a working native implementation, not a claim of complete UI/release pari
|
|||||||
The Windows focus/injection rules still apply: an unelevated process cannot edit an elevated app.
|
The Windows focus/injection rules still apply: an unelevated process cannot edit an elevated app.
|
||||||
Conversion is cancelled rather than pasting into a different window or replacing unverified recent text.
|
Conversion is cancelled rather than pasting into a different window or replacing unverified recent text.
|
||||||
|
|
||||||
|
## OpenBao synchronization (experimental, opt-in)
|
||||||
|
|
||||||
|
The **Sync...** button is available in Settings for everyone. Synchronization remains disabled
|
||||||
|
until you configure your own OpenBao and enable it. Connection configuration is saved separately
|
||||||
|
in `sync.json`. The portable data directory is normally `data/` beside the executable; installations
|
||||||
|
without a writable application directory use the existing local-app-data fallback.
|
||||||
|
No server address or account is included in the application.
|
||||||
|
|
||||||
|
The first provider is **OpenBao KV v2**. The dialog accepts an HTTPS server origin, username,
|
||||||
|
password, KV mount (default `kswitcher`), profile path (default `personal/settings`) and userpass
|
||||||
|
authentication mount (default `userpass`). Use the same profile on each of your PCs. This is
|
||||||
|
administrator-provisioned private access, not public account registration. Non-root namespaces,
|
||||||
|
reverse-proxy URL prefixes, MFA login flows and other providers are not implemented yet.
|
||||||
|
|
||||||
|
Enable synchronization and choose **Save / Sign in / Sync**. The dialog saves connection changes
|
||||||
|
immediately; the main Settings window's Save/Cancel does not control this separate configuration.
|
||||||
|
When synchronization is disabled, connection fields and sync actions are inactive. Check **Enable
|
||||||
|
synchronization** to make them available. To disable an existing connection, uncheck it and click
|
||||||
|
**Save**; this preserves the saved connection and password without starting a sync request.
|
||||||
|
**Disconnect / forget password** remains available while synchronization is disabled.
|
||||||
|
A blank password keeps the existing Windows credential for that server, login mount and username.
|
||||||
|
The password is saved in Windows Credential Manager, not in settings exports, logs or the remote
|
||||||
|
profile. HTTPS certificate validation is mandatory and redirects are refused. Login tokens are
|
||||||
|
kept in memory for one sync attempt, with best-effort self-revocation afterwards. Configure bounded
|
||||||
|
token lifetimes on the server as well (for example a 5-minute default and 10-minute maximum).
|
||||||
|
**Disconnect / forget password** disables synchronization and removes the current connection's
|
||||||
|
saved credential. A request already sent to the server may still complete; its downloaded settings
|
||||||
|
will not be applied after the connection changes. Old credentials for other connection identities
|
||||||
|
can be removed in Windows Credential Manager under `KSwitcher.Sync/`.
|
||||||
|
|
||||||
|
On the first connection, **Save / Sign in / Sync** merges the existing profiles without
|
||||||
|
requiring a whole-profile replacement. Independent entries (such as snippets, exclusions and
|
||||||
|
replacement pairs) are combined. Different values for the same setting remain on their respective
|
||||||
|
sides and appear in **Resolve individual conflicts...**; no value is guessed without a common history.
|
||||||
|
Nonconflicting changes synchronize immediately, and unresolved conflicts survive subsequent syncs.
|
||||||
|
|
||||||
|
- **Upload local** creates the remote profile or replaces it with this PC's saved shared settings.
|
||||||
|
- **Download remote** replaces this PC's shared settings with the server profile.
|
||||||
|
- If the server has no profile yet, choose **Upload local** to create it.
|
||||||
|
- Unsaved edits in Settings are not synchronized. Close and reopen Settings after a download;
|
||||||
|
the existing stale-editor check prevents an old Settings window overwriting downloaded changes.
|
||||||
|
|
||||||
|
Once connected, the resident checks at startup, every **10 minutes**, and about two seconds after saving settings, on a separate
|
||||||
|
network thread. Errors back off for 15 minutes; the Sync button allows a manual retry. Local use
|
||||||
|
continues offline. Independent changes to different settings fields are merged against the last
|
||||||
|
successful baseline. **Resolve individual conflicts...** shows the name and local/server values
|
||||||
|
for each conflict. Choose either value for selected settings and apply your choices; unselected
|
||||||
|
conflicts stay pending. Other, nonconflicting changes continue to synchronize. Choices are checked
|
||||||
|
against freshly read values before writing, so a stale dialog cannot overwrite a newer edit.
|
||||||
|
Conflicting shortcuts are separate settings, including bindings for individual keyboard layouts.
|
||||||
|
Exclusions and personal dictionary words merge by membership. Ordered layout/dictionary lists
|
||||||
|
remain single settings because their ordering affects behavior.
|
||||||
|
|
||||||
|
Snippets have persistent IDs that survive renaming. Different snippets merge independently;
|
||||||
|
trigger and text edits within a snippet can merge too. Deleting a snippet retains a deletion
|
||||||
|
marker, so an unchanged offline copy cannot bring it back. Deletion versus a concurrent edit
|
||||||
|
is an explicit conflict, offering the deleted or edited version. Duplicate triggers and shortcut
|
||||||
|
collisions created by independent edits are also presented for resolution. Deletion markers are
|
||||||
|
retained without automatic expiry; recreating a snippet in the editor gives it a new ID.
|
||||||
|
|
||||||
|
Existing profiles migrate automatically: legacy snippet IDs derive deterministically from the
|
||||||
|
original trigger, then are stored permanently. Sync writes use envelope version 2; older clients
|
||||||
|
refuse this version instead of dropping IDs/deletions. Update all participating PCs before using
|
||||||
|
the new merge behavior. Existing version-1 profiles and local baselines remain readable.
|
||||||
|
|
||||||
|
Download/Upload are still available for deliberate whole-profile recovery/initialization, not
|
||||||
|
required for ordinary conflicts. Every server write uses the version just read as a CAS
|
||||||
|
condition, including explicit Upload. A racing write is rejected rather than silently overwritten.
|
||||||
|
Deleted server versions are not silently recreated.
|
||||||
|
|
||||||
|
Hotkeys, snippets, application exclusions, layout order, conversion, screenshot and autocorrection
|
||||||
|
preferences are shared. Startup/elevation, keep-awake, logging, history enablement/limits,
|
||||||
|
Tesseract executable/engine selection, connection details and credentials stay local. Clipboard
|
||||||
|
history, screenshots and dictionary files are never uploaded. Full synchronization identifies
|
||||||
|
missing keyboard layouts by language (when Windows can identify it) and exact ID.
|
||||||
|
Install the same layout variant, or select **Keep this PC's layouts and layout shortcuts (sync
|
||||||
|
other settings)** and click **Save / Sign in / Sync**. This device-local option keeps the entire
|
||||||
|
local layout cycle and its direct shortcuts unchanged while synchronizing the other shared settings.
|
||||||
|
The server's layout cycle and direct shortcuts are preserved on automatic sync and explicit Upload;
|
||||||
|
Download also keeps the local layout configuration. Later syncs cannot erase missing server layouts
|
||||||
|
just because this PC does not have them installed. Uncheck the option to resume full layout sync.
|
||||||
|
Settings are JSON inside OpenBao; this is not end-to-end encryption from the vault administrator.
|
||||||
|
|
||||||
|
The last common profile (`sync-base.bin`) and the settings preceding the most recent downloaded
|
||||||
|
change (`settings-before-sync.bin`) are protected with Windows DPAPI and belong to this Windows
|
||||||
|
account/machine. Reinstallation recovery uses the remote profile and a fresh login; copying these
|
||||||
|
local DPAPI files to a new machine does not recover them. For an older server snapshot, use OpenBao
|
||||||
|
KV version history to restore that snapshot as the latest version, then choose Download remote.
|
||||||
|
The app does not yet provide a server-history browser. Keep ordinary server backups too.
|
||||||
|
|
||||||
|
OpenBao administrator setup:
|
||||||
|
|
||||||
|
1. Enable a KV **version 2** engine at `kswitcher`; enable **Require Check-and-Set** and set
|
||||||
|
maximum versions to a suitable value, such as 30.
|
||||||
|
2. Create a dedicated userpass account, with a policy restricted to the chosen profile. Do not
|
||||||
|
use the administrator account. For the defaults, the application needs only:
|
||||||
|
|
||||||
|
```hcl
|
||||||
|
path "kswitcher/data/personal/settings" {
|
||||||
|
capabilities = ["create", "read", "update"]
|
||||||
|
}
|
||||||
|
path "auth/token/revoke-self" {
|
||||||
|
capabilities = ["update"]
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
3. Set bounded token lifetimes on that account/auth mount and enter its credentials in KSwitcher.
|
||||||
|
Keep the server's address and TLS certificate reachable/trusted on each participating PC.
|
||||||
|
|
||||||
|
`SyncProvider` separates versioned read/conditional-write operations from merging, local state
|
||||||
|
and UI integration, so another service can be added without replacing the synchronization logic.
|
||||||
|
Protocol and conflict regressions run with `build.ps1 -Test` or CMake's `sync-regressions` test.
|
||||||
|
|
||||||
|
## Portable utilities
|
||||||
|
|
||||||
|
The tray menu's **Tools** submenu lists `.exe` files in a `tools` folder beside
|
||||||
|
`KSwitcher.exe`, sorted by filename. For example, place `StayHere.exe` at
|
||||||
|
`tools/StayHere.exe` and choose **Tools → StayHere** to launch it manually.
|
||||||
|
The folder is rescanned whenever the menu opens; no configuration or restart is needed.
|
||||||
|
Only files directly in `tools` are listed (not subfolders, shortcuts, or KSwitcher's
|
||||||
|
own executables beside the main program). Utilities start with `tools` as their working
|
||||||
|
directory and are never started automatically. Their lifetime is independent of KSwitcher.
|
||||||
|
An absent or empty folder displays a disabled placeholder; launch errors are reported.
|
||||||
|
From v0.6.45, the release includes `tools/README.txt`, so extracting the ZIP or
|
||||||
|
installing an update creates the folder. Add your own trusted portable executables;
|
||||||
|
StayHere is bundled from v0.6.46, and settings synchronization does not transfer
|
||||||
|
utility files. Updates preserve personal utilities and refresh bundled StayHere and
|
||||||
|
documentation. Repository development scripts
|
||||||
|
are not included in the portable tools folder.
|
||||||
|
|
||||||
|
Choose **Tools → StayHere** to start the bundled activity utility. It starts
|
||||||
|
enabled; left-click its tray icon to pause/resume or right-click for Exit. While
|
||||||
|
enabled it prevents automatic sleep and, after three minutes without input, sends
|
||||||
|
F15 on its 15-second check. It does not move the mouse, bypass locking, start with
|
||||||
|
KSwitcher automatically, or directly control Teams status. Locked/disconnected
|
||||||
|
sessions do not receive simulated activity. See `tools/StayHere-README.md`.
|
||||||
|
|
||||||
## Build
|
## Build
|
||||||
|
|
||||||
The easiest reproducible local route uses the pinned portable w64devkit toolchain:
|
The easiest reproducible local route uses the pinned portable w64devkit toolchain:
|
||||||
@@ -368,13 +657,44 @@ Alternatively open this directory as a CMake project in Visual Studio with the C
|
|||||||
and Windows SDK installed, or use CMake with a Windows GCC toolchain. CMake/MSVC is provided but the
|
and Windows SDK installed, or use CMake with a Windows GCC toolchain. CMake/MSVC is provided but the
|
||||||
verified local build uses GCC/w64devkit.
|
verified local build uses GCC/w64devkit.
|
||||||
|
|
||||||
## Automatic layout correction (experimental)
|
## Automatic correction (experimental)
|
||||||
|
|
||||||
Enable **Automatically correct layout (experimental)** in Settings, then use **Auto-correction
|
Enable **Automatic correction (experimental)** in Settings, then use **Auto-correction
|
||||||
options…** to select dictionary languages and edit excluded applications or words to never correct.
|
options…** to select dictionary languages and edit excluded applications or words to never correct.
|
||||||
The feature is off by default. English and Ukrainian are selected initially; Russian is optional.
|
The feature is off by default. English and Ukrainian are selected initially; Russian is optional.
|
||||||
Target layouts must also be enabled in the layout cycle.
|
Target layouts must also be enabled in the layout cycle.
|
||||||
|
|
||||||
|
### Custom replacements and spelling typos
|
||||||
|
|
||||||
|
Two optional modes in **Auto-correction options…** extend layout correction. Both are off by
|
||||||
|
default and require the main **Automatic correction (experimental)** checkbox to be enabled.
|
||||||
|
|
||||||
|
- **Use custom replacements**: enter one `typo=correction` pair per line, for example
|
||||||
|
`првиіт=привіт` or `helo=hello`. Entries are normalized to lowercase; duplicate source words
|
||||||
|
are rejected. The typo must contain 1–32 letters. The correction may contain several words
|
||||||
|
separated by single spaces, for example `мамамила=мама мила`, up to 32 characters including
|
||||||
|
spaces. Both sides must use the same supported language, without punctuation; leading,
|
||||||
|
trailing and repeated spaces are not allowed. Explicit pairs take priority over dictionary recognition, including
|
||||||
|
already valid words, and do not require dictionary membership or satisfy the frequency limit.
|
||||||
|
- **Correct spelling typos using dictionaries**: checks unknown words in the current language
|
||||||
|
after no layout correction is found. It accepts exactly one dictionary candidate reachable
|
||||||
|
by inserting, deleting or replacing one letter, or swapping two adjacent letters. Both input
|
||||||
|
and target must have at least four letters. Multiple candidates leave the input unchanged,
|
||||||
|
even if a frequency limit would exclude one of them. Personal dictionary words participate.
|
||||||
|
This is word-level spelling correction, not grammar or sentence-context correction.
|
||||||
|
|
||||||
|
Both modes run after Space, preserve surrounding punctuation and an initial capital, and keep
|
||||||
|
the current layout. The selected dictionary languages, enabled layout cycle, minimum input
|
||||||
|
length, excluded applications, never-correct list, protected fields and Undo behavior apply.
|
||||||
|
ALL CAPS, mixed-case identifiers, numbers, URLs and email addresses are skipped. A replacement
|
||||||
|
is applied once, without chaining. Click **OK**, then **Save** in Settings; pairs and switches
|
||||||
|
are included in settings export/import and synchronization. Undo restores the original word
|
||||||
|
and suppresses its correction until restart.
|
||||||
|
When synchronizing phrase replacements, update all participating PCs to v0.6.47 or newer;
|
||||||
|
older clients reject spaces in replacement pairs.
|
||||||
|
|
||||||
|
### Layout correction and shared options
|
||||||
|
|
||||||
**Characters before a word** and **Characters after a word** configure punctuation to preserve around
|
**Characters before a word** and **Characters after a word** configure punctuation to preserve around
|
||||||
the corrected word. Enter characters directly, without spaces or separators; a comma or semicolon
|
the corrected word. Enter characters directly, without spaces or separators; a comma or semicolon
|
||||||
is itself a character. Defaults include parentheses, square/curly brackets, quotation marks and common
|
is itself a character. Defaults include parentheses, square/curly brackets, quotation marks and common
|
||||||
@@ -389,6 +709,8 @@ protect already valid input, and ambiguous alternatives remain unchanged regardl
|
|||||||
**My dictionary** provides separate English, Ukrainian and Russian fields for correct words missing
|
**My dictionary** provides separate English, Ukrainian and Russian fields for correct words missing
|
||||||
from the bundled dictionaries. Enter words separated by commas or new lines, then click OK and Save
|
from the bundled dictionaries. Enter words separated by commas or new lines, then click OK and Save
|
||||||
in Settings. Case and duplicates are normalized automatically; no file editing or ranks are needed.
|
in Settings. Case and duplicates are normalized automatically; no file editing or ranks are needed.
|
||||||
|
The v0.6.23 bundled Ukrainian dictionary includes `поточні`. The updater preserves existing dictionary files;
|
||||||
|
if upgrading from an older dictionary, add this word in My dictionary → Ukrainian and click OK → Save.
|
||||||
These entries are stored in settings and survive dictionary updates. They protect correct input and
|
These entries are stored in settings and survive dictionary updates. They protect correct input and
|
||||||
are eligible as correction targets at any frequency limit. The language and target layout must still
|
are eligible as correction targets at any frequency limit. The language and target layout must still
|
||||||
be enabled. **Never correct these words** is a separate exception list and takes precedence.
|
be enabled. **Never correct these words** is a separate exception list and takes precedence.
|
||||||
@@ -422,7 +744,12 @@ support automatic correction. Dictionary recognition is heuristic, not an unders
|
|||||||
subtitle vocabulary is incomplete, and uncommon names or jargon can need personal exceptions.
|
subtitle vocabulary is incomplete, and uncommon names or jargon can need personal exceptions.
|
||||||
|
|
||||||
No network service or language model is used. The three dictionary files occupy about 2.6 MB on disk;
|
No network service or language model is used. The three dictionary files occupy about 2.6 MB on disk;
|
||||||
the English/Ukrainian lookup data uses less than 3 MiB of RAM and is loaded on first automatic check.
|
the bundled EN/UK/RU lookup payload uses about 0.90 MiB of RAM. When automatic correction is enabled,
|
||||||
|
selected dictionaries are loaded before typing and shared by the input predictor and worker.
|
||||||
|
Words are stored in compact indexed blocks; all words and frequency ranks are retained, and editable
|
||||||
|
UTF-8 dictionary files keep the same format. Custom dictionaries can use more memory.
|
||||||
|
`build.ps1 -Test` checks every bundled word/rank and measures lookup speed; CMake exposes the same
|
||||||
|
check as `dictionary-regressions`. The payload figure excludes the rest of the process and allocator overhead.
|
||||||
Keep `dictionaries/` beside the executable when copying the app. These word lists derive from
|
Keep `dictionaries/` beside the executable when copying the app. These word lists derive from
|
||||||
[FrequencyWords](https://github.com/hermitdave/FrequencyWords) and are separately licensed under
|
[FrequencyWords](https://github.com/hermitdave/FrequencyWords) and are separately licensed under
|
||||||
CC BY-SA 4.0; attribution, pinned source revision and license are in `dictionaries/`.
|
CC BY-SA 4.0; attribution, pinned source revision and license are in `dictionaries/`.
|
||||||
@@ -438,6 +765,7 @@ Run `./package.ps1 -PublishRelease` after building and testing to refresh the tr
|
|||||||
.\build.ps1 -Test # Pure/native regression checks; does not touch the user's clipboard
|
.\build.ps1 -Test # Pure/native regression checks; does not touch the user's clipboard
|
||||||
.\build.ps1 -Ocr # Render a synthetic image, decode it with WIC and recognize it with Windows OCR
|
.\build.ps1 -Ocr # Render a synthetic image, decode it with WIC and recognize it with Windows OCR
|
||||||
.\build.ps1 -Integration # Interactive, isolated test editor; avoid input for about 10 seconds
|
.\build.ps1 -Integration # Interactive, isolated test editor; avoid input for about 10 seconds
|
||||||
|
.\build.ps1 -Far # Explicit integration test using an isolated Far Manager profile
|
||||||
.\tests\configuration.ps1 # Separate-process settings tests; close KSwitcher first
|
.\tests\configuration.ps1 # Separate-process settings tests; close KSwitcher first
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -493,3 +821,31 @@ Keep `v0.4.2` as the last legacy `vX.Y.Z` release. Publish full packages as
|
|||||||
legacy version tag: clients that have not installed the bridge would select it.
|
legacy version tag: clients that have not installed the bridge would select it.
|
||||||
Keep the compatibility bridge in the first 100 releases returned by Gitea while
|
Keep the compatibility bridge in the first 100 releases returned by Gitea while
|
||||||
supporting old clients; their immutable update code only reads that page.
|
supporting old clients; their immutable update code only reads that page.
|
||||||
|
|
||||||
|
### Editors that omit copied trailing spaces
|
||||||
|
|
||||||
|
From v0.6.31, KSwitcher recovers trailing ordinary spaces omitted by Ctrl+C only when Windows accessibility proves the complete selection. The same focused control and range are rechecked before paste, and the result is read back even without Write log. Recent-text conversion, automatic correction, repeat conversion and Undo retain exact verification. Missing letters, tabs, line breaks and unavailable or ambiguous selections are not reconstructed. No setting or shortcut has changed.
|
||||||
|
|
||||||
|
### Notification registration and Viber — v0.6.36
|
||||||
|
|
||||||
|
Notification registration runs in KSwitcher.Screenshot.exe; keep all three executables together. Startup registration is asynchronous. Viber pastes allow 75 ms for clipboard notifications before Ctrl+V, retaining focus, ownership and selection checks. This mitigates an intermittent clipboard timing issue; it does not guarantee all Viber failures are resolved. UI Automation is unchanged.
|
||||||
|
|
||||||
|
### Image history, OCR and duplicate fingerprints — v0.6.37
|
||||||
|
|
||||||
|
Image clipboard capture and automatic/uncached manual history OCR run in short-lived KSwitcher.Screenshot.exe processes. Keep all three executables together. Original clipboard formats, image limits, privacy exclusions, Windows OCR, optional Tesseract and searchable encrypted OCR results are preserved. Background OCR is cancelled on shutdown or an OCR-profile change; late results do not recreate deleted entries.
|
||||||
|
|
||||||
|
Consecutive duplicates use SHA-256 fingerprints inside the encrypted history index, including pixel fingerprints for equivalent image encodings. Older entries acquire fingerprints on first comparison without a bulk migration. Pins and OCR caches survive duplicate detection; non-consecutive copies still create separate entries. New text no longer loads the preceding image to rule out a duplicate. No shortcut, setting or default changed.
|
||||||
|
|
||||||
|
Moving OCR isolates its temporary memory rather than reducing the combined processing peak. A controlled three-run comparison retained about 0.8 MiB less private RAM in the caller after recognition; combined peak RAM was about 55.6 MiB before and 56.6 MiB with the helper. Results depend on the image, OCR engine and system.
|
||||||
|
|
||||||
|
### Pinned history checkbox — v0.6.42
|
||||||
|
|
||||||
|
Check **★ Pinned only** beside the history search box to show only pinned entries; uncheck it to show all entries. The checkbox sits on the left, immediately followed by the search box; its right edge stays aligned with the history list when resizing. The text search applies within that filter. Unpinning an item removes it from the pinned view immediately. The checkbox state and search are remembered after closing and reopening history. **Clear history…** still deletes the entire history after confirmation, including entries hidden by the filter.
|
||||||
|
|
||||||
|
### History process and clipboard memory — v0.6.40
|
||||||
|
|
||||||
|
History opens in a separate, short-lived instance of **KSwitcher.exe**. **Esc** closes it even when focus is on the window or an action button, releasing Windows UI allocations with the process. The resident keeps keyboard hooks, clipboard capture and history storage. Search and the pinned-only filter are preserved in encrypted view state. Each fresh opening selects and reveals the newest matching entry; background refreshes preserve the selected record while browsing. If a full-text item viewer is still open, the helper stays alive until the last viewer closes. Pin/delete, formatted/plain paste and OCR remain available; settings and default shortcuts are unchanged.
|
||||||
|
|
||||||
|
Image thumbnails are decoded in **KSwitcher.Screenshot.exe**, returning only bounded preview pixels. Image clipboard backup/restore also uses that helper and encrypted temporary files, with clipboard-sequence checks before restoring. Selection reads avoid loading image formats. Keep all three executables together; no fourth executable is required. Paste allows a brief foreground handoff after history closes while preserving cancellation checks. UI Automation remains in the resident.
|
||||||
|
|
||||||
|
A live development-build test measured **4.37 MiB before history and 4.35 MiB after two open/Esc cycles**, compared with an earlier roughly 8–9 MiB plateau. A same-image clipboard-backup benchmark retained **12.78 MiB before versus 0.05 MiB after**. These measure private working set, not a guaranteed total footprint. Include all helpers when measuring active use: combined memory can be higher while history is open. No forced working-set trimming is used. Existing screenshots and shortcuts remain applicable. The v0.6.38 approach of retaining a hidden history window/RichEdit control is superseded by process termination.
|
||||||
Binary file not shown.
+13
-18
@@ -1,28 +1,23 @@
|
|||||||
# Latest Windows release
|
# Latest Windows release
|
||||||
|
|
||||||
## v0.6.22 — 2026-10-31
|
## v0.6.53 — 2026-11-06
|
||||||
|
|
||||||
## Changes
|
## Changes
|
||||||
- Recover partial selections during recent-text conversion, repeat conversion and undo: when copying returns a verified suffix of the expected text, extend the selection with paced Shift+Left presses and copy again. Replacement still requires a complete verified match.
|
- Include messenger chat language profiles in settings synchronization: Telegram Desktop, Telegram Web K in Chrome, Teams and saved inactive Viber profiles. Manual export/import continues to include them. Viber recognition remains disabled.
|
||||||
- Recent-text suffix checks map physical keys through convertible layouts, including Cyrillic and mixed case. This covers reported suffixes such as `Switcher ` from `PuntoSwitcher `, `зштп ` from the layout equivalent of `snipping `, and `лувШт ` from `LinkedIn `.
|
- Merge profiles by application and chat name. Independent chat changes merge; conflicting language lists and deletion versus editing of the same chat use the existing per-setting conflict choices. Preserve each profile's language order and propagate deletions.
|
||||||
- Diagnostic context records the expected previous result and selection-recovery stages. Unrelated or empty copied ranges are not extended; input/context changes still cancel replacement.
|
- Preserve saved profile IDs when a layout is missing on a PC; switching skips unavailable layouts and falls back to the global cycle if none remain. **Keep this PC's layouts** keeps the global layout cycle and shortcuts local while chat profiles still synchronize.
|
||||||
|
- Preserve local chat profiles when downloading older shared settings that do not contain the chat field. An explicit empty chat map from the new version removes profiles. Update every synchronizing PC before sharing the new format.
|
||||||
|
- Retain the **Arc (U)** screenshot tool from v0.6.52.
|
||||||
|
|
||||||
## Validation
|
## Validation
|
||||||
419 native regressions, 473 input/UI checks, screenshot editor UI, notification registration, 48 updater checks and updater progress checks passed, including Cyrillic and mixed-case suffix verification. The isolated editor integration test passed partial-selection recovery, the `PuntoSwitcher ` repeat-conversion case, clipboard restoration and rejection of unrelated text. Direct validation in LinkedIn and ChatGPT is still outstanding; native-editor tests do not establish browser-editor compatibility.
|
Passed 126 sync checks (18 new checks for chat profiles), 674 chat-profile checks, 568 input checks, 332 native checks, dictionary equivalence (140,939 words), wheel, StayHere, Utilities, screenshot UI/save/registration, 54 updater checks and updater progress checks. Chat sync checks cover upload/download, older-profile migration, independent merges, persisted conflict resolution, deletion, Unicode names, layout order, missing layouts, partial synchronization and malformed data rejection. Published assets, versions, checksums, update selection and bilingual Wiki pages are verified during publication.
|
||||||
|
|
||||||
## Limitations
|
## Upgrade and compatibility
|
||||||
Recovery is attempted once and still depends on the editor processing simulated selection keys. A failed full-text check cancels replacement. Existing clipboard, accessibility and input-context restrictions remain; this patch does not change paste readback verification.
|
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.
|
||||||
|
|
||||||
**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.
|
**Update every synchronizing PC to v0.6.51 or newer before sharing application-specific snippets. Older versions do not understand application restrictions and may treat scoped snippets as global.** Keep a backup before downgrading. Settings with Telegram Web profiles require v0.6.51 or newer. Chat profiles now synchronize from v0.6.53. Update every synchronizing PC to v0.6.53 or newer before syncing: older clients reject the chat-profile field. Synchronization stores application names, visible chat names and language IDs on your configured OpenBao server. No message contents are included.
|
||||||
For manual installation, exit KSwitcher, close screenshot editors and extract the entire ZIP into its installation folder. Keep personal `data/` and customized dictionaries.
|
|
||||||
|
|
||||||
Download **KSwitcher-win-x64.zip** with **SHA256SUMS.txt**. The package contains all three executables, a release manifest, offline dictionaries, documentation and license notices. It contains no personal settings, clipboard history, Tesseract installation or language models.
|
Download **KSwitcher-win-x64.zip** with **SHA256SUMS.txt**. The package contains no personal settings, credentials or clipboard history.
|
||||||
|
|
||||||
Build and package:
|
Publish stable `release-vX.Y.Z` tags matching the executable version. Keep `v0.4.2` as the last legacy tag.
|
||||||
|
|
||||||
```powershell
|
|
||||||
.\build.ps1 -Stage -Test
|
|
||||||
.\package.ps1 -PublishRelease
|
|
||||||
```
|
|
||||||
|
|
||||||
Commit the archive, checksum and sources together. Publish both assets on a stable `release-vX.Y.Z` tag matching the executable version. Keep `v0.4.2` as the last legacy tag.
|
|
||||||
@@ -1 +1 @@
|
|||||||
b80632cc93abadf2a23921c3275b8ff37d98c92b8b583a9621d0c2b589ed6a35 KSwitcher-win-x64.zip
|
18ed8074c5c9a064b667612721389967f6fb758d7162abbcf4b73437724d2606 KSwitcher-win-x64.zip
|
||||||
@@ -0,0 +1,81 @@
|
|||||||
|
{
|
||||||
|
"version": "0.6.51",
|
||||||
|
"schema": 1,
|
||||||
|
"files": [
|
||||||
|
{
|
||||||
|
"size": 1847296,
|
||||||
|
"path": "KSwitcher.exe",
|
||||||
|
"sha256": "c40f90944169ec6f1b92803ccaec734573bf798939f13ab3553b982b709e479c"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size": 1716224,
|
||||||
|
"path": "KSwitcher.Config.exe",
|
||||||
|
"sha256": "8e8a5fee9be8f318b78516b82415c6b098ac67f7c374f4667ef271576a77f9fa"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size": 2897408,
|
||||||
|
"path": "KSwitcher.Screenshot.exe",
|
||||||
|
"sha256": "bb5ffc3a26955c752d593ba06f69476985d9902f2ed0345fe3efe9bfc2eb63c8"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size": 4401,
|
||||||
|
"path": "LICENSE",
|
||||||
|
"sha256": "d3c81140cce01c26bf6cbf52aa40e0825e1fa35b9a91d1387170a65d2597082c"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size": 1096,
|
||||||
|
"path": "json-LICENSE.txt",
|
||||||
|
"sha256": "61e08da79c44061654015ce6b0c4061c23ee1dd18237fbf09e9bfda3c0ea2831"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size": 74601,
|
||||||
|
"path": "README.md",
|
||||||
|
"sha256": "818f81e6c4bfaa6b014ac50351ec22f68ee6eb3c094ad5ecb7bac98d605e0918"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size": 732485,
|
||||||
|
"path": "dictionaries/en.txt",
|
||||||
|
"sha256": "d0c022b27b9fbc2ff7b6b8bec723cc1adc4eef517202f9ff77eed5d8bea3acb9"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size": 20566,
|
||||||
|
"path": "dictionaries/LICENSE-CC-BY-SA-4.0.txt",
|
||||||
|
"sha256": "0bdfb0201d1803634f268cdff0993b8349d2c70e956a06dbb667c8dd65254ec5"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size": 2265,
|
||||||
|
"path": "dictionaries/README.md",
|
||||||
|
"sha256": "3017bf44d3be9d9dfab21bd6778aa52b7947e61acf9ce2bc86b41d6e949ac311"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size": 1109134,
|
||||||
|
"path": "dictionaries/ru.txt",
|
||||||
|
"sha256": "80e6b6a27815973535f7facb636c597eb845dfee45cfabfc4e9b3341b9332849"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size": 1280,
|
||||||
|
"path": "dictionaries/sources.json",
|
||||||
|
"sha256": "98e5b3fe7304e37705c9e5ff48b0b399ccb16e806736d21f09921b99e5f2a408"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size": 940799,
|
||||||
|
"path": "dictionaries/uk.txt",
|
||||||
|
"sha256": "d30e990d6ec2983c04f3644a3c61c6c668e8c542323f5931916fdd55b916eebf"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size": 993,
|
||||||
|
"path": "tools/README.txt",
|
||||||
|
"sha256": "a34b5161a8315af037e1ec71d816bfc688f7c364141d4ee2347cf0515ef0c82a"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size": 134656,
|
||||||
|
"path": "tools/StayHere.exe",
|
||||||
|
"sha256": "6ef5cf64708d62b7fc63c3c793cc99188a513433ff4774cae01dc014f6664376"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size": 2796,
|
||||||
|
"path": "tools/StayHere-README.md",
|
||||||
|
"sha256": "ba214e2aca7405e698b3ab21ceb1f41ce088edd996b3e30e4a9d58ff496f9413"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
param([switch]$Test, [switch]$Integration, [switch]$Ocr, [switch]$Stage)
|
param([switch]$Test, [switch]$Integration, [switch]$Ocr, [switch]$Stage, [switch]$Far)
|
||||||
$ErrorActionPreference = 'Stop'
|
$ErrorActionPreference = 'Stop'
|
||||||
$root = $PSScriptRoot
|
$root = $PSScriptRoot
|
||||||
$compiler = Join-Path $root '.tools\w64devkit\bin\g++.exe'
|
$compiler = Join-Path $root '.tools\w64devkit\bin\g++.exe'
|
||||||
@@ -15,8 +15,14 @@ Set-Content -LiteralPath (Join-Path (Split-Path $executablePath) '.local-dev') -
|
|||||||
Push-Location $root
|
Push-Location $root
|
||||||
try {
|
try {
|
||||||
$common = @('-std=c++20','-Os','-DNDEBUG','-DUNICODE','-D_UNICODE','-DWIN32_LEAN_AND_MEAN','-DNOMINMAX','-D_WIN32_WINNT=0x0A00','-Wall','-Wextra','-Wno-missing-field-initializers','-Isrc','-Ivendor','-ffunction-sections','-fdata-sections')
|
$common = @('-std=c++20','-Os','-DNDEBUG','-DUNICODE','-D_UNICODE','-DWIN32_LEAN_AND_MEAN','-DNOMINMAX','-D_WIN32_WINNT=0x0A00','-Wall','-Wextra','-Wno-missing-field-initializers','-Isrc','-Ivendor','-ffunction-sections','-fdata-sections')
|
||||||
$libs = @('-luser32','-lshell32','-lshlwapi','-ladvapi32','-lcrypt32','-limm32','-lcomctl32','-lgdi32','-lole32','-loleaut32','-ltaskschd','-lcomdlg32','-luuid','-lwindowscodecs','-lruntimeobject','-luiautomationcore')
|
$libs = @('-lwinhttp','-luser32','-lshell32','-lshlwapi','-ladvapi32','-lcrypt32','-limm32','-lcomctl32','-lgdi32','-lole32','-loleaut32','-ltaskschd','-lcomdlg32','-luuid','-lwindowscodecs','-lruntimeobject','-luiautomationcore')
|
||||||
foreach ($name in @('core','platform','autostart','autocorrect','storage','ocr','richtext','update','screenshot','screenshot_main','screenshot_notifications','screenshot_activation','screenshot_launcher','app','ui','main','configuration','config_main')) {
|
$utilityDirectory = Join-Path (Split-Path $executablePath) 'tools'
|
||||||
|
New-Item -ItemType Directory -Force $utilityDirectory,build/release/tools | Out-Null
|
||||||
|
$stayHere = Join-Path $utilityDirectory 'StayHere.exe'
|
||||||
|
& $compiler @common -Werror -mwindows -municode -static -s utilities/StayHere/main.cpp -luser32 -lshell32 -lgdi32 -lwtsapi32 -o $stayHere
|
||||||
|
if ($LASTEXITCODE) { throw 'StayHere build failed' }
|
||||||
|
Copy-Item -LiteralPath $stayHere -Destination build/release/tools/StayHere.exe -Force
|
||||||
|
foreach ($name in @('core','platform','autostart','autocorrect','storage','sync','ocr','richtext','update','screenshot','screenshot_main','screenshot_notifications','screenshot_activation','screenshot_launcher','app','ui','main','configuration','config_main')) {
|
||||||
& $compiler @common -c "src/$name.cpp" -o "build/$name.o"
|
& $compiler @common -c "src/$name.cpp" -o "build/$name.o"
|
||||||
if ($LASTEXITCODE) { throw "Compilation failed: $name" }
|
if ($LASTEXITCODE) { throw "Compilation failed: $name" }
|
||||||
}
|
}
|
||||||
@@ -29,34 +35,56 @@ try {
|
|||||||
& windres --codepage=65001 -DKS_SCREENSHOT_RESOURCES resources/app.rc -O coff -o build/screenshot-res.o
|
& windres --codepage=65001 -DKS_SCREENSHOT_RESOURCES resources/app.rc -O coff -o build/screenshot-res.o
|
||||||
if ($LASTEXITCODE) { throw 'Screenshot resource compilation failed' }
|
if ($LASTEXITCODE) { throw 'Screenshot resource compilation failed' }
|
||||||
New-Item -ItemType Directory -Force build/release | Out-Null
|
New-Item -ItemType Directory -Force build/release | Out-Null
|
||||||
& $compiler -mwindows -municode -static -s '-Wl,--gc-sections' build/core.o build/platform.o build/autostart.o build/autocorrect.o build/storage.o build/ocr.o build/richtext.o build/update.o build/screenshot_launcher.o build/screenshot_activation.o build/screenshot_notifications.o build/app.o build/configuration.o build/ui-resident.o build/main.o build/app-res.o @libs -o $executablePath
|
& $compiler -mwindows -municode -static -s '-Wl,--gc-sections' build/core.o build/platform.o build/autostart.o build/autocorrect.o build/storage.o build/sync.o build/ocr.o build/richtext.o build/update.o build/screenshot_launcher.o build/screenshot_activation.o build/screenshot_notifications.o build/app.o build/configuration.o build/ui-resident.o build/main.o build/app-res.o @libs -o $executablePath
|
||||||
if ($LASTEXITCODE) { throw 'Link failed' }
|
if ($LASTEXITCODE) { throw 'Link failed' }
|
||||||
Copy-Item -LiteralPath $executablePath -Destination build/release/KSwitcher.exe -Force
|
Copy-Item -LiteralPath $executablePath -Destination build/release/KSwitcher.exe -Force
|
||||||
$configPath = Join-Path (Split-Path $executablePath) 'KSwitcher.Config.exe'
|
$configPath = Join-Path (Split-Path $executablePath) 'KSwitcher.Config.exe'
|
||||||
& $compiler -mwindows -municode -static -s '-Wl,--gc-sections' build/core.o build/platform.o build/storage.o build/ocr.o build/configuration.o build/config_main.o build/ui-config.o build/app-res.o @libs -o $configPath
|
& $compiler -mwindows -municode -static -s '-Wl,--gc-sections' build/core.o build/platform.o build/storage.o build/sync.o build/ocr.o build/configuration.o build/config_main.o build/ui-config.o build/app-res.o @libs -o $configPath
|
||||||
if ($LASTEXITCODE) { throw 'Configurator link failed' }
|
if ($LASTEXITCODE) { throw 'Configurator link failed' }
|
||||||
Copy-Item -LiteralPath $configPath -Destination build/release/KSwitcher.Config.exe -Force
|
Copy-Item -LiteralPath $configPath -Destination build/release/KSwitcher.Config.exe -Force
|
||||||
$screenshotPath = Join-Path (Split-Path $executablePath) 'KSwitcher.Screenshot.exe'
|
$screenshotPath = Join-Path (Split-Path $executablePath) 'KSwitcher.Screenshot.exe'
|
||||||
& $compiler -mwindows -municode -static -s '-Wl,--gc-sections' build/core.o build/platform.o build/ocr.o build/screenshot.o build/screenshot_notifications.o build/screenshot_activation.o build/screenshot_main.o build/screenshot-res.o @libs -o $screenshotPath
|
& $compiler -mwindows -municode -static -s '-Wl,--gc-sections' build/core.o build/platform.o build/storage.o build/ocr.o build/screenshot.o build/screenshot_notifications.o build/screenshot_activation.o build/screenshot_main.o build/screenshot-res.o @libs -o $screenshotPath
|
||||||
if ($LASTEXITCODE) { throw 'Screenshot link failed' }
|
if ($LASTEXITCODE) { throw 'Screenshot link failed' }
|
||||||
Copy-Item -LiteralPath $screenshotPath -Destination build/release/KSwitcher.Screenshot.exe -Force
|
Copy-Item -LiteralPath $screenshotPath -Destination build/release/KSwitcher.Screenshot.exe -Force
|
||||||
if ($Test) {
|
if ($Test) {
|
||||||
|
& $compiler @common -Werror -DSTAYHERE_TEST_INSTANCE -mwindows -municode -static -s utilities/StayHere/main.cpp -luser32 -lshell32 -lgdi32 -lwtsapi32 -o build/StayHereTest.exe
|
||||||
|
if ($LASTEXITCODE) { throw 'StayHere fixture build failed' }
|
||||||
|
& "$env:SystemRoot\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -ExecutionPolicy Bypass -File tests/stayhere.ps1 -Executable (Join-Path $outDir 'StayHereTest.exe')
|
||||||
|
if ($LASTEXITCODE) { throw 'StayHere lifecycle tests failed' }
|
||||||
|
& $compiler @common tests/utilities.cpp -static -s -o build/KSwitcherUtilitiesTests.exe
|
||||||
|
if ($LASTEXITCODE) { throw 'Utilities test build failed' }
|
||||||
|
& .\build\KSwitcherUtilitiesTests.exe
|
||||||
|
if ($LASTEXITCODE) { throw 'Utilities tests failed' }
|
||||||
|
& $compiler @common tests/dictionary.cpp build/core.o build/platform.o build/autocorrect.o @libs -lpsapi -static -s -o build/KSwitcherDictionaryTests.exe
|
||||||
|
if ($LASTEXITCODE) { throw 'Dictionary test build failed' }
|
||||||
|
& .\build\KSwitcherDictionaryTests.exe
|
||||||
|
if ($LASTEXITCODE) { throw 'Dictionary tests failed' }
|
||||||
|
& $compiler @common tests/sync.cpp build/core.o build/platform.o build/storage.o build/sync.o build/ocr.o @libs -static -s -o build/KSwitcherSyncTests.exe
|
||||||
|
if ($LASTEXITCODE) { throw 'Sync test build failed' }
|
||||||
|
& .\build\KSwitcherSyncTests.exe
|
||||||
|
if ($LASTEXITCODE) { throw 'Sync tests failed' }
|
||||||
& $compiler @common tests/scroll.cpp @libs -static -s -o build/KSwitcherScrollTests.exe
|
& $compiler @common tests/scroll.cpp @libs -static -s -o build/KSwitcherScrollTests.exe
|
||||||
if ($LASTEXITCODE) { throw 'Scroll test build failed' }
|
if ($LASTEXITCODE) { throw 'Scroll test build failed' }
|
||||||
& .\build\KSwitcherScrollTests.exe
|
& .\build\KSwitcherScrollTests.exe
|
||||||
if ($LASTEXITCODE) { throw 'Scroll tests failed' }
|
if ($LASTEXITCODE) { throw 'Scroll tests failed' }
|
||||||
& $compiler @common tests/tests.cpp build/core.o build/platform.o build/autostart.o build/autocorrect.o build/storage.o build/ocr.o build/richtext.o build/update.o @libs -static -s -o build/KSwitcherTests.exe
|
& $compiler @common tests/tests.cpp build/core.o build/platform.o build/autostart.o build/autocorrect.o build/storage.o build/sync.o build/ocr.o build/richtext.o build/update.o @libs -static -s -o build/KSwitcherTests.exe
|
||||||
if ($LASTEXITCODE) { throw 'Test build failed' }
|
if ($LASTEXITCODE) { throw 'Test build failed' }
|
||||||
& .\build\KSwitcherTests.exe
|
& .\build\KSwitcherTests.exe
|
||||||
if ($LASTEXITCODE) { throw 'Tests failed' }
|
if ($LASTEXITCODE) { throw 'Tests failed' }
|
||||||
& $compiler @common tests/input.cpp build/core.o build/platform.o build/autostart.o build/autocorrect.o build/storage.o build/ocr.o build/richtext.o build/update.o build/screenshot.o build/screenshot_launcher.o build/screenshot_activation.o build/screenshot_notifications.o build/app.o build/configuration.o build/ui.o build/screenshot-res.o @libs -static -s -o build/KSwitcherInputTests.exe
|
& $compiler @common tests/input.cpp build/core.o build/platform.o build/autostart.o build/autocorrect.o build/storage.o build/sync.o build/ocr.o build/richtext.o build/update.o build/screenshot.o build/screenshot_launcher.o build/screenshot_activation.o build/screenshot_notifications.o build/app.o build/configuration.o build/ui.o build/screenshot-res.o @libs -static -s -o build/KSwitcherInputTests.exe
|
||||||
if ($LASTEXITCODE) { throw 'Input test build failed' }
|
if ($LASTEXITCODE) { throw 'Input test build failed' }
|
||||||
& .\build\KSwitcherInputTests.exe
|
& .\build\KSwitcherInputTests.exe
|
||||||
if ($LASTEXITCODE) { throw 'Input tests failed' }
|
if ($LASTEXITCODE) { throw 'Input tests failed' }
|
||||||
|
& $compiler @common tests/chat_profiles.cpp build/core.o build/platform.o build/autostart.o build/autocorrect.o build/storage.o build/sync.o build/ocr.o build/richtext.o build/update.o build/screenshot.o build/screenshot_launcher.o build/screenshot_activation.o build/screenshot_notifications.o build/app.o build/configuration.o build/ui.o build/screenshot-res.o @libs -static -s -o build/KSwitcherChatProfileTests.exe
|
||||||
|
if ($LASTEXITCODE) { throw 'Chat profile test build failed' }
|
||||||
|
& .\build\KSwitcherChatProfileTests.exe
|
||||||
|
if ($LASTEXITCODE) { throw 'Chat profile tests failed' }
|
||||||
& $compiler @common tests/screenshot_ui.cpp build/core.o build/platform.o build/ocr.o build/screenshot-res.o @libs -static -s -o build/KSwitcherScreenshotUITests.exe
|
& $compiler @common tests/screenshot_ui.cpp build/core.o build/platform.o build/ocr.o build/screenshot-res.o @libs -static -s -o build/KSwitcherScreenshotUITests.exe
|
||||||
if ($LASTEXITCODE) { throw 'Screenshot UI test build failed' }
|
if ($LASTEXITCODE) { throw 'Screenshot UI test build failed' }
|
||||||
& .\build\KSwitcherScreenshotUITests.exe
|
& .\build\KSwitcherScreenshotUITests.exe
|
||||||
if ($LASTEXITCODE) { throw 'Screenshot UI tests failed' }
|
if ($LASTEXITCODE) { throw 'Screenshot UI tests failed' }
|
||||||
|
& .\build\KSwitcherScreenshotUITests.exe --save-only
|
||||||
|
if ($LASTEXITCODE) { throw 'Screenshot save tests failed' }
|
||||||
$registrationTest = Join-Path (Split-Path $executablePath) 'KSwitcherRegistrationTests.exe'
|
$registrationTest = Join-Path (Split-Path $executablePath) 'KSwitcherRegistrationTests.exe'
|
||||||
try {
|
try {
|
||||||
& $compiler @common tests/screenshot_registration.cpp build/core.o build/platform.o @libs -static '-Wl,--gc-sections' -s -o $registrationTest
|
& $compiler @common tests/screenshot_registration.cpp build/core.o build/platform.o @libs -static '-Wl,--gc-sections' -s -o $registrationTest
|
||||||
@@ -70,16 +98,43 @@ try {
|
|||||||
& "$env:SystemRoot\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -ExecutionPolicy Bypass -File tests/update_progress.ps1
|
& "$env:SystemRoot\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -ExecutionPolicy Bypass -File tests/update_progress.ps1
|
||||||
if ($LASTEXITCODE) { throw 'Updater progress UI tests failed' }
|
if ($LASTEXITCODE) { throw 'Updater progress UI tests failed' }
|
||||||
}
|
}
|
||||||
|
if ($Far) {
|
||||||
|
& $compiler @common tests/far_snippets.cpp build/core.o build/platform.o build/autostart.o build/autocorrect.o build/storage.o build/sync.o build/ocr.o build/richtext.o build/update.o build/screenshot.o build/screenshot_launcher.o build/screenshot_activation.o build/screenshot_notifications.o build/app.o build/configuration.o build/ui.o build/screenshot-res.o @libs -mwindows -municode -static -s -o build/KSwitcherFarSnippetTests.exe
|
||||||
|
if ($LASTEXITCODE) { throw 'Far snippet test build failed' }
|
||||||
|
$fixture = Start-Process -FilePath (Join-Path $outDir 'KSwitcherFarSnippetTests.exe') -WindowStyle Hidden -Wait -PassThru
|
||||||
|
Get-Content -LiteralPath (Join-Path $outDir 'far-snippets.log')
|
||||||
|
if ($fixture.ExitCode) { throw 'Far snippet tests failed' }
|
||||||
|
}
|
||||||
if ($Integration) {
|
if ($Integration) {
|
||||||
& $compiler @common tests/integration.cpp build/core.o build/platform.o build/autostart.o build/autocorrect.o build/storage.o build/ocr.o build/richtext.o build/update.o build/screenshot.o build/screenshot_launcher.o build/screenshot_activation.o build/screenshot_notifications.o build/app.o build/configuration.o build/ui.o build/screenshot-res.o @libs -static -s -o build/KSwitcherIntegration.exe
|
$historyFixture = Join-Path (Resolve-Path build) ('history-host-fixture-' + [guid]::NewGuid().ToString('N'))
|
||||||
|
New-Item -ItemType Directory $historyFixture | Out-Null
|
||||||
|
Copy-Item $executablePath,(Join-Path (Split-Path $executablePath) 'KSwitcher.Screenshot.exe') -Destination $historyFixture
|
||||||
|
Set-Content (Join-Path $historyFixture '.local-dev') 'Isolated history integration test'
|
||||||
|
$historyTest = Join-Path $historyFixture 'KSwitcherHistoryHostTests.exe'
|
||||||
|
& $compiler @common tests/history_host.cpp build/core.o build/platform.o build/storage.o build/ocr.o @libs -lpsapi -static -s -o $historyTest
|
||||||
|
if ($LASTEXITCODE) { throw 'History host test build failed' }
|
||||||
|
& $historyTest
|
||||||
|
if ($LASTEXITCODE) { throw 'History host tests failed' }
|
||||||
|
$snapshotTest = Join-Path (Split-Path $executablePath) 'KSwitcherClipboardSnapshotTests.exe'
|
||||||
|
& $compiler @common tests/clipboard_snapshot.cpp build/core.o build/platform.o build/storage.o build/ocr.o @libs -lpsapi -static -s -o $snapshotTest
|
||||||
|
if ($LASTEXITCODE) { throw 'Clipboard snapshot test build failed' }
|
||||||
|
& $snapshotTest
|
||||||
|
if ($LASTEXITCODE) { throw 'Clipboard snapshot tests failed' }
|
||||||
|
$captureTest = Join-Path (Split-Path $executablePath) 'KSwitcherImageCaptureTests.exe'
|
||||||
|
& $compiler @common tests/image_capture.cpp build/core.o build/platform.o build/storage.o build/ocr.o @libs -static -s -o $captureTest
|
||||||
|
if ($LASTEXITCODE) { throw 'Image capture test build failed' }
|
||||||
|
& $captureTest
|
||||||
|
if ($LASTEXITCODE) { throw 'Image capture tests failed' }
|
||||||
|
& $compiler @common tests/integration.cpp build/core.o build/platform.o build/autostart.o build/autocorrect.o build/storage.o build/sync.o build/ocr.o build/richtext.o build/update.o build/screenshot.o build/screenshot_launcher.o build/screenshot_activation.o build/screenshot_notifications.o build/app.o build/configuration.o build/ui.o build/screenshot-res.o @libs -static -s -o build/KSwitcherIntegration.exe
|
||||||
if ($LASTEXITCODE) { throw 'Integration test build failed' }
|
if ($LASTEXITCODE) { throw 'Integration test build failed' }
|
||||||
& .\build\KSwitcherIntegration.exe
|
& .\build\KSwitcherIntegration.exe
|
||||||
if ($LASTEXITCODE) { throw 'Integration tests failed' }
|
if ($LASTEXITCODE) { throw 'Integration tests failed' }
|
||||||
}
|
}
|
||||||
if ($Ocr) {
|
if ($Ocr) {
|
||||||
& $compiler @common tests/ocr.cpp build/core.o build/platform.o build/autostart.o build/autocorrect.o build/storage.o build/ocr.o build/richtext.o build/update.o build/screenshot.o build/screenshot_launcher.o build/screenshot_activation.o build/screenshot_notifications.o build/app.o build/configuration.o build/ui.o build/screenshot-res.o @libs -static -s -o build/KSwitcherOcrTests.exe
|
$ocrTest = Join-Path (Split-Path $executablePath) 'KSwitcherOcrTests.exe'
|
||||||
|
& $compiler @common tests/ocr.cpp build/core.o build/platform.o build/autostart.o build/autocorrect.o build/storage.o build/sync.o build/ocr.o build/richtext.o build/update.o build/screenshot.o build/screenshot_launcher.o build/screenshot_activation.o build/screenshot_notifications.o build/app.o build/configuration.o build/ui.o build/screenshot-res.o @libs -static -s -o $ocrTest
|
||||||
if ($LASTEXITCODE) { throw 'OCR test build failed' }
|
if ($LASTEXITCODE) { throw 'OCR test build failed' }
|
||||||
& .\build\KSwitcherOcrTests.exe
|
& $ocrTest
|
||||||
if ($LASTEXITCODE) { throw 'OCR tests failed' }
|
if ($LASTEXITCODE) { throw 'OCR tests failed' }
|
||||||
}
|
}
|
||||||
foreach ($folder in @('build/dictionaries','build/release/dictionaries','build/staged/dictionaries')) {
|
foreach ($folder in @('build/dictionaries','build/release/dictionaries','build/staged/dictionaries')) {
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ replace counts with original frequency ranks, sort lexically. Reproduce with
|
|||||||
hashes. The lists contain word forms from subtitles, not a complete spelling
|
hashes. The lists contain word forms from subtitles, not a complete spelling
|
||||||
or grammar dictionary. Recognition can miss names, jargon and uncommon forms.
|
or grammar dictionary. Recognition can miss names, jargon and uncommon forms.
|
||||||
|
|
||||||
Supplemental Ukrainian vocabulary: `реліз`. These additions use rank 50001,
|
Supplemental Ukrainian vocabulary: `реліз`, `поточні`. These additions use rank 50001,
|
||||||
after the upstream 50k list, rather than claiming a measured corpus frequency.
|
after the upstream 50k list, rather than claiming a measured corpus frequency.
|
||||||
They are included with the default unlimited rank setting and recorded in sources.json.
|
They are included with the default unlimited rank setting and recorded in sources.json.
|
||||||
|
|
||||||
|
|||||||
@@ -9,11 +9,12 @@
|
|||||||
"uk": {
|
"uk": {
|
||||||
"source": "https://raw.githubusercontent.com/hermitdave/FrequencyWords/525f9b560de45753a5ea01069454e72e9aa541c6/content/2016/uk/uk_50k.txt",
|
"source": "https://raw.githubusercontent.com/hermitdave/FrequencyWords/525f9b560de45753a5ea01069454e72e9aa541c6/content/2016/uk/uk_50k.txt",
|
||||||
"sourceSha256": "9548b79a608d33f39c5546037a69117d679730b1fda08dd0ce67c043dbf3335a",
|
"sourceSha256": "9548b79a608d33f39c5546037a69117d679730b1fda08dd0ce67c043dbf3335a",
|
||||||
"words": 42550,
|
"words": 42551,
|
||||||
"bytes": 898227,
|
"bytes": 898248,
|
||||||
"sha256": "c94605e6be676d2d64f89a3bc16f92b9128f9977d226a97b103cf22a3e6835e3",
|
"sha256": "caeb097749d4afc84b68ad96b3d7dfb6a6569561cd32ccce0bee94a13b43ba86",
|
||||||
"supplementalWords": {
|
"supplementalWords": {
|
||||||
"\u0440\u0435\u043b\u0456\u0437": 50001
|
"\u0440\u0435\u043b\u0456\u0437": 50001,
|
||||||
|
"\u043f\u043e\u0442\u043e\u0447\u043d\u0456": 50001
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"ru": {
|
"ru": {
|
||||||
|
|||||||
@@ -27337,6 +27337,7 @@
|
|||||||
поторопись 9062
|
поторопись 9062
|
||||||
поторопитесь 20656
|
поторопитесь 20656
|
||||||
поторопиться 15390
|
поторопиться 15390
|
||||||
|
поточні 50001
|
||||||
потрапив 4168
|
потрапив 4168
|
||||||
потрапила 7383
|
потрапила 7383
|
||||||
потрапили 6631
|
потрапили 6631
|
||||||
|
|||||||
+15
-2
@@ -10,8 +10,12 @@ Copy-Item -LiteralPath (Join-Path $root 'LICENSE') -Destination $destination
|
|||||||
Copy-Item -LiteralPath (Join-Path $root 'vendor\json-LICENSE.txt') -Destination $destination
|
Copy-Item -LiteralPath (Join-Path $root 'vendor\json-LICENSE.txt') -Destination $destination
|
||||||
Copy-Item -LiteralPath (Join-Path $root 'README.md') -Destination $destination
|
Copy-Item -LiteralPath (Join-Path $root 'README.md') -Destination $destination
|
||||||
Copy-Item -LiteralPath (Join-Path $root 'dictionaries') -Destination $destination -Recurse -Force
|
Copy-Item -LiteralPath (Join-Path $root 'dictionaries') -Destination $destination -Recurse -Force
|
||||||
|
New-Item -ItemType Directory -Force (Join-Path $destination 'tools') | Out-Null
|
||||||
|
Copy-Item -LiteralPath (Join-Path $root 'resources\portable-tools-README.txt') -Destination (Join-Path $destination 'tools\README.txt') -Force
|
||||||
|
Copy-Item -LiteralPath (Join-Path $root 'build\release\tools\StayHere.exe') -Destination (Join-Path $destination 'tools\StayHere.exe') -Force
|
||||||
|
Copy-Item -LiteralPath (Join-Path $root 'utilities\StayHere\README.md') -Destination (Join-Path $destination 'tools\StayHere-README.md') -Force
|
||||||
# Enumerate the distributable files explicitly; do not include a user's data directory.
|
# Enumerate the distributable files explicitly; do not include a user's data directory.
|
||||||
$files = @('KSwitcher.exe','KSwitcher.Config.exe','KSwitcher.Screenshot.exe','LICENSE','json-LICENSE.txt','README.md','dictionaries') | ForEach-Object { Join-Path $destination $_ }
|
$files = @('KSwitcher.exe','KSwitcher.Config.exe','KSwitcher.Screenshot.exe','LICENSE','json-LICENSE.txt','README.md','dictionaries','tools\README.txt','tools\StayHere.exe','tools\StayHere-README.md') | ForEach-Object { Join-Path $destination $_ }
|
||||||
$entries = foreach ($path in $files) {
|
$entries = foreach ($path in $files) {
|
||||||
foreach ($file in @(Get-ChildItem -LiteralPath $path -File -Recurse)) {
|
foreach ($file in @(Get-ChildItem -LiteralPath $path -File -Recurse)) {
|
||||||
@{path=$file.FullName.Substring($destination.Length+1).Replace('\','/'); size=$file.Length; sha256=(Get-FileHash -LiteralPath $file.FullName -Algorithm SHA256).Hash.ToLowerInvariant()}
|
@{path=$file.FullName.Substring($destination.Length+1).Replace('\','/'); size=$file.Length; sha256=(Get-FileHash -LiteralPath $file.FullName -Algorithm SHA256).Hash.ToLowerInvariant()}
|
||||||
@@ -22,7 +26,16 @@ $manifest=Join-Path $destination 'release-files.json'
|
|||||||
@{schema=1; version=$version; files=@($entries)} | ConvertTo-Json -Depth 4 | Set-Content -LiteralPath $manifest -Encoding utf8
|
@{schema=1; version=$version; files=@($entries)} | ConvertTo-Json -Depth 4 | Set-Content -LiteralPath $manifest -Encoding utf8
|
||||||
$files += $manifest
|
$files += $manifest
|
||||||
$archive = Join-Path $root 'dist\KSwitcher-win-x64.zip'
|
$archive = Join-Path $root 'dist\KSwitcher-win-x64.zip'
|
||||||
Compress-Archive -LiteralPath $files -DestinationPath $archive -Force
|
# Archive only manifest-listed files, preserving relative paths. Never sweep up
|
||||||
|
# personal utilities or leftover developer files from the staging directory.
|
||||||
|
Add-Type -AssemblyName System.IO.Compression.FileSystem
|
||||||
|
$stream = [IO.File]::Open($archive,[IO.FileMode]::Create)
|
||||||
|
$zip = [IO.Compression.ZipArchive]::new($stream,[IO.Compression.ZipArchiveMode]::Create)
|
||||||
|
try {
|
||||||
|
foreach ($name in @($entries | ForEach-Object { $_.path }) + @('release-files.json')) {
|
||||||
|
[IO.Compression.ZipFileExtensions]::CreateEntryFromFile($zip,(Join-Path $destination $name),$name,[IO.Compression.CompressionLevel]::Optimal) | Out-Null
|
||||||
|
}
|
||||||
|
} finally { $zip.Dispose(); $stream.Dispose() }
|
||||||
Get-FileHash -LiteralPath $archive -Algorithm SHA256
|
Get-FileHash -LiteralPath $archive -Algorithm SHA256
|
||||||
if ($PublishRelease) {
|
if ($PublishRelease) {
|
||||||
$release = Join-Path $root 'Release'
|
$release = Join-Path $root 'Release'
|
||||||
|
|||||||
+3
-3
@@ -9,8 +9,8 @@ IDC_SCREENSHOT_PENCIL CURSOR "icons/lucide/pencil.cur"
|
|||||||
1 RT_MANIFEST "app.manifest"
|
1 RT_MANIFEST "app.manifest"
|
||||||
201 RCDATA "update.ps1"
|
201 RCDATA "update.ps1"
|
||||||
1 VERSIONINFO
|
1 VERSIONINFO
|
||||||
FILEVERSION 0,6,22,0
|
FILEVERSION 0,6,53,0
|
||||||
PRODUCTVERSION 0,6,22,0
|
PRODUCTVERSION 0,6,53,0
|
||||||
FILEOS VOS_NT_WINDOWS32
|
FILEOS VOS_NT_WINDOWS32
|
||||||
FILETYPE VFT_APP
|
FILETYPE VFT_APP
|
||||||
BEGIN
|
BEGIN
|
||||||
@@ -20,7 +20,7 @@ BEGIN
|
|||||||
BEGIN
|
BEGIN
|
||||||
VALUE "FileDescription", "KSwitcher — native keyboard and clipboard utility"
|
VALUE "FileDescription", "KSwitcher — native keyboard and clipboard utility"
|
||||||
VALUE "ProductName", "KSwitcher"
|
VALUE "ProductName", "KSwitcher"
|
||||||
VALUE "FileVersion", "0.6.22"
|
VALUE "FileVersion", "0.6.53"
|
||||||
END
|
END
|
||||||
END
|
END
|
||||||
BLOCK "VarFileInfo"
|
BLOCK "VarFileInfo"
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
KSwitcher portable utilities
|
||||||
|
|
||||||
|
Put your trusted portable .exe utilities directly in this tools folder,
|
||||||
|
beside this README.txt. Right-click the KSwitcher tray icon and open Tools.
|
||||||
|
For example: tools/StayHere.exe appears as Tools > StayHere.
|
||||||
|
|
||||||
|
The list refreshes each time the tray menu opens. Subfolders and shortcuts
|
||||||
|
are not listed. Utilities start only when you choose them, with this folder
|
||||||
|
as their working directory. Closing KSwitcher does not close a utility.
|
||||||
|
|
||||||
|
StayHere.exe is bundled. Choose Tools > StayHere to start it; it starts
|
||||||
|
enabled, prevents automatic sleep, and sends F15 after 3 minutes of inactivity.
|
||||||
|
Left-click its tray icon to pause/resume; right-click for Exit. See StayHere-README.md.
|
||||||
|
It does not start automatically with KSwitcher or bypass Windows locking.
|
||||||
|
|
||||||
|
Add other utilities separately. Updates preserve your own files in this folder;
|
||||||
|
bundled StayHere.exe and documentation may be refreshed. Utilities are not
|
||||||
|
transferred by settings synchronization.
|
||||||
+605
-69
File diff suppressed because it is too large.
Load diff
@@ -2,6 +2,8 @@
|
|||||||
#include "autocorrect.h"
|
#include "autocorrect.h"
|
||||||
#include "storage.h"
|
#include "storage.h"
|
||||||
#include "update.h"
|
#include "update.h"
|
||||||
|
#include "sync.h"
|
||||||
|
#include "chat_context.h"
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
#include <condition_variable>
|
#include <condition_variable>
|
||||||
#include <deque>
|
#include <deque>
|
||||||
@@ -32,6 +34,11 @@ class App
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
HWND window{}, historyWindow{}, settingsWindow{}, snippetsWindow{};
|
HWND window{}, historyWindow{}, settingsWindow{}, snippetsWindow{};
|
||||||
|
HWND historyService{}; // Non-null only in the short-lived history UI process.
|
||||||
|
bool isolateHistory{};
|
||||||
|
unsigned historyEntryWindows{};
|
||||||
|
std::wstring historySelection, historyTop, historyQuery;
|
||||||
|
bool historyPinnedOnly{};
|
||||||
HINSTANCE instance{};
|
HINSTANCE instance{};
|
||||||
std::filesystem::path data;
|
std::filesystem::path data;
|
||||||
std::vector<Layout> layouts;
|
std::vector<Layout> layouts;
|
||||||
@@ -54,7 +61,7 @@ class App
|
|||||||
bool smoke{};
|
bool smoke{};
|
||||||
int startCommand{};
|
int startCommand{};
|
||||||
std::wstring updateStartupEvent;
|
std::wstring updateStartupEvent;
|
||||||
App(HINSTANCE, bool = false, const std::filesystem::path &dataRoot = {});
|
App(HINSTANCE, bool = false, const std::filesystem::path &dataRoot = {}, HWND historyService = nullptr);
|
||||||
~App();
|
~App();
|
||||||
int execute();
|
int execute();
|
||||||
void dispatch(int);
|
void dispatch(int);
|
||||||
@@ -71,6 +78,11 @@ class App
|
|||||||
void applySettings(const Settings &);
|
void applySettings(const Settings &);
|
||||||
void reloadLayouts();
|
void reloadLayouts();
|
||||||
void clearHistory();
|
void clearHistory();
|
||||||
|
void openHistoryProcess();
|
||||||
|
void refreshHistoryProcess();
|
||||||
|
void remoteHistory(const char *action, const std::wstring &id = {}, bool plain = false);
|
||||||
|
LRESULT historyRequest(HWND, const COPYDATASTRUCT &);
|
||||||
|
void saveHistoryView(const std::wstring &, const std::wstring &, const std::wstring &, bool);
|
||||||
void clearLog(bool previous);
|
void clearLog(bool previous);
|
||||||
void setHotkeyCapture(HWND);
|
void setHotkeyCapture(HWND);
|
||||||
bool isHotkey(DWORD, UINT);
|
bool isHotkey(DWORD, UINT);
|
||||||
@@ -78,15 +90,21 @@ class App
|
|||||||
bool handleKeyboard(const KBDLLHOOKSTRUCT &, bool down, UINT modifiers);
|
bool handleKeyboard(const KBDLLHOOKSTRUCT &, bool down, UINT modifiers);
|
||||||
void resetInput();
|
void resetInput();
|
||||||
void checkUpdate(bool interactive, bool install = false, const std::wstring &version = {});
|
void checkUpdate(bool interactive, bool install = false, const std::wstring &version = {});
|
||||||
|
std::wstring syncCommand(int action = 0, const std::vector<SyncChoice> &choices = {});
|
||||||
|
Bytes syncConflictData();
|
||||||
|
void pollSync();
|
||||||
static App *current;
|
static App *current;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend struct InputRegressionAccess;
|
friend struct InputRegressionAccess;
|
||||||
|
void releaseIdleMemory(ULONGLONG now);
|
||||||
HHOOK keyboardHook{}, mouseHook{};
|
HHOOK keyboardHook{}, mouseHook{};
|
||||||
|
HANDLE historyProcess{};
|
||||||
std::mutex jobsMutex;
|
std::mutex jobsMutex;
|
||||||
std::condition_variable jobsReady;
|
std::condition_variable jobsReady;
|
||||||
std::deque<std::function<void()>> jobs;
|
std::deque<std::function<void()>> jobs;
|
||||||
std::thread worker;
|
std::thread worker;
|
||||||
|
HANDLE notificationRegistration{};
|
||||||
std::thread historySearchWorker;
|
std::thread historySearchWorker;
|
||||||
std::condition_variable historySearchReady;
|
std::condition_variable historySearchReady;
|
||||||
std::function<void()> pendingHistorySearch;
|
std::function<void()> pendingHistorySearch;
|
||||||
@@ -96,6 +114,16 @@ class App
|
|||||||
Settings historyOcrSettings;
|
Settings historyOcrSettings;
|
||||||
void scheduleHistoryOcr(const Settings &);
|
void scheduleHistoryOcr(const Settings &);
|
||||||
std::thread updateWorker;
|
std::thread updateWorker;
|
||||||
|
std::thread syncWorker;
|
||||||
|
std::atomic<bool> syncDone{false};
|
||||||
|
bool syncRunning{};
|
||||||
|
ULONGLONG nextSync{}, syncRetryAfter{};
|
||||||
|
SyncResult syncResult;
|
||||||
|
SyncConfig syncConnection;
|
||||||
|
SyncConfig conflictConnection;
|
||||||
|
std::vector<SyncConflict> pendingSyncConflicts;
|
||||||
|
Bytes syncSnapshot;
|
||||||
|
std::wstring syncStatus = L"Not connected.";
|
||||||
bool updateRunning{}, installingUpdate{};
|
bool updateRunning{}, installingUpdate{};
|
||||||
std::wstring availableUpdate, notifiedUpdate;
|
std::wstring availableUpdate, notifiedUpdate;
|
||||||
bool (*updateNotifier)(const std::wstring &){};
|
bool (*updateNotifier)(const std::wstring &){};
|
||||||
@@ -107,6 +135,11 @@ class App
|
|||||||
int previousAttemptCommand{}, repeatAttempts{};
|
int previousAttemptCommand{}, repeatAttempts{};
|
||||||
std::vector<std::pair<int, Hotkey>> hookBindings;
|
std::vector<std::pair<int, Hotkey>> hookBindings;
|
||||||
HotkeyHook hotkeyHook;
|
HotkeyHook hotkeyHook;
|
||||||
|
ChatSwitchHook chatSwitchHook;
|
||||||
|
HWND chatWindow{};
|
||||||
|
std::wstring activeChat, activeChatTitle;
|
||||||
|
void refreshChatContext();
|
||||||
|
void switchChatLayout(bool reverse);
|
||||||
HWND typingTarget{};
|
HWND typingTarget{};
|
||||||
bool autoPending{};
|
bool autoPending{};
|
||||||
int snippetPending = -1;
|
int snippetPending = -1;
|
||||||
@@ -116,6 +149,7 @@ class App
|
|||||||
void replayTyping();
|
void replayTyping();
|
||||||
static LRESULT CALLBACK windowProc(HWND, UINT, WPARAM, LPARAM);
|
static LRESULT CALLBACK windowProc(HWND, UINT, WPARAM, LPARAM);
|
||||||
static LRESULT CALLBACK keyProc(int, WPARAM, LPARAM);
|
static LRESULT CALLBACK keyProc(int, WPARAM, LPARAM);
|
||||||
|
static LRESULT keyboardAfterHooks(int, WPARAM, LPARAM, LRESULT);
|
||||||
static LRESULT CALLBACK mouseProc(int, WPARAM, LPARAM);
|
static LRESULT CALLBACK mouseProc(int, WPARAM, LPARAM);
|
||||||
};
|
};
|
||||||
void showHistory(App &, bool visible = true);
|
void showHistory(App &, bool visible = true);
|
||||||
|
|||||||
@@ -0,0 +1,100 @@
|
|||||||
|
// History UI has no clipboard listener or hooks. The resident remains the only writer.
|
||||||
|
namespace {
|
||||||
|
constexpr ULONG_PTR HistoryRequest = 0x4b530200;
|
||||||
|
constexpr UINT HistoryHostShow = WM_APP + 71, HistoryHostRefresh = WM_APP + 72;
|
||||||
|
constexpr wchar_t HistoryHostClass[] = L"KSwitcher.HistoryHost";
|
||||||
|
using HistoryJson = nlohmann::json;
|
||||||
|
HWND historyController(HANDLE process)
|
||||||
|
{
|
||||||
|
if (!process || WaitForSingleObject(process, 0) == WAIT_OBJECT_0) return nullptr;
|
||||||
|
auto window = FindWindowW(HistoryHostClass, nullptr);
|
||||||
|
DWORD pid{}; GetWindowThreadProcessId(window, &pid);
|
||||||
|
return pid == GetProcessId(process) ? window : nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void App::openHistoryProcess()
|
||||||
|
{
|
||||||
|
auto foreground = GetForegroundWindow();
|
||||||
|
if (foreground != window && foreground != historyWindow) pasteTarget = foreground;
|
||||||
|
if (historyProcess && WaitForSingleObject(historyProcess, 0) == WAIT_OBJECT_0) {
|
||||||
|
CloseHandle(historyProcess); historyProcess = nullptr; historyWindow = nullptr;
|
||||||
|
}
|
||||||
|
if (historyProcess) {
|
||||||
|
if (auto host = historyController(historyProcess)) {
|
||||||
|
AllowSetForegroundWindow(GetProcessId(historyProcess));
|
||||||
|
PostMessageW(host, HistoryHostShow, 0, 0);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
auto path = executable();
|
||||||
|
auto command = L"\"" + path + L"\" --history-host=" + std::to_wstring(reinterpret_cast<uintptr_t>(window));
|
||||||
|
STARTUPINFOW startup{sizeof(startup)};
|
||||||
|
startup.dwFlags = STARTF_USESHOWWINDOW; startup.wShowWindow = SW_HIDE;
|
||||||
|
PROCESS_INFORMATION child{};
|
||||||
|
if (!CreateProcessW(path.c_str(), command.data(), nullptr, nullptr, FALSE, CREATE_NO_WINDOW,
|
||||||
|
nullptr, std::filesystem::path(path).parent_path().c_str(), &startup, &child))
|
||||||
|
throw std::runtime_error("Cannot start clipboard history window");
|
||||||
|
CloseHandle(child.hThread);
|
||||||
|
historyProcess = child.hProcess;
|
||||||
|
AllowSetForegroundWindow(child.dwProcessId);
|
||||||
|
}
|
||||||
|
void App::refreshHistoryProcess()
|
||||||
|
{
|
||||||
|
if (auto host = historyController(historyProcess)) PostMessageW(host, HistoryHostRefresh, 0, 0);
|
||||||
|
}
|
||||||
|
void App::remoteHistory(const char *action, const std::wstring &id, bool plain)
|
||||||
|
{
|
||||||
|
if (!historyService || !configurationPeer(historyService, L"KSwitcher.exe"))
|
||||||
|
throw std::runtime_error("KSwitcher has stopped. Reopen clipboard history.");
|
||||||
|
auto text = HistoryJson{{"action", action}, {"id", utf8(id)}, {"plain", plain}}.dump();
|
||||||
|
if (std::string_view(action) == "paste") {
|
||||||
|
DWORD residentPid{}; GetWindowThreadProcessId(historyService, &residentPid);
|
||||||
|
AllowSetForegroundWindow(residentPid);
|
||||||
|
}
|
||||||
|
COPYDATASTRUCT message{HistoryRequest, DWORD(text.size()), text.data()};
|
||||||
|
DWORD_PTR result{};
|
||||||
|
if (!SendMessageTimeoutW(historyService, WM_COPYDATA, reinterpret_cast<WPARAM>(window),
|
||||||
|
reinterpret_cast<LPARAM>(&message), SMTO_ABORTIFHUNG | SMTO_ERRORONEXIT,
|
||||||
|
15000, &result) || result != 1)
|
||||||
|
throw std::runtime_error("KSwitcher could not complete the history request. Reopen history and retry.");
|
||||||
|
}
|
||||||
|
LRESULT App::historyRequest(HWND sender, const COPYDATASTRUCT &message)
|
||||||
|
{
|
||||||
|
DWORD pid{}; GetWindowThreadProcessId(sender, &pid);
|
||||||
|
if (!historyProcess || pid != GetProcessId(historyProcess) ||
|
||||||
|
!configurationPeer(sender, L"KSwitcher.exe") || message.cbData > 4096 ||
|
||||||
|
!message.cbData || !message.lpData || installingUpdate) return FALSE;
|
||||||
|
try {
|
||||||
|
const auto *first = static_cast<const char *>(message.lpData);
|
||||||
|
auto job = HistoryJson::parse(first, first + message.cbData);
|
||||||
|
auto action = job.at("action").get<std::string>();
|
||||||
|
auto id = wide(job.at("id").get<std::string>());
|
||||||
|
if (id.size() > 128) return FALSE;
|
||||||
|
if (action == "ready") {
|
||||||
|
auto ui = reinterpret_cast<HWND>(uintptr_t(std::stoull(id)));
|
||||||
|
DWORD uiPid{}; GetWindowThreadProcessId(ui, &uiPid);
|
||||||
|
wchar_t name[64]{}; GetClassNameW(ui, name, 64);
|
||||||
|
if (uiPid != pid || std::wstring(name) != L"KSwitcher.History") return FALSE;
|
||||||
|
historyWindow = ui;
|
||||||
|
} else if (action == "paste") {
|
||||||
|
if (busy || !history) return FALSE;
|
||||||
|
pasteEntry(id, job.at("plain").get<bool>());
|
||||||
|
} else if (action == "ocr") {
|
||||||
|
if (busy || !history) return FALSE;
|
||||||
|
recognizeEntry(id);
|
||||||
|
} else if (action == "clear") clearHistory();
|
||||||
|
else if (action == "pin" || action == "remove") {
|
||||||
|
if (busy || !history) return FALSE;
|
||||||
|
if (action == "pin") history->pin(id); else history->remove(id);
|
||||||
|
} else return FALSE;
|
||||||
|
return TRUE;
|
||||||
|
} catch (...) { return FALSE; }
|
||||||
|
}
|
||||||
|
void App::saveHistoryView(const std::wstring &selection, const std::wstring &top, const std::wstring &query, bool pinnedOnly)
|
||||||
|
{
|
||||||
|
if (!historyService) return;
|
||||||
|
try {
|
||||||
|
auto text = HistoryJson{{"selection", utf8(selection)}, {"top", utf8(top)}, {"query", utf8(query)}, {"pinnedOnly", pinnedOnly}}.dump();
|
||||||
|
atomicWrite(data / L"history-view.bin", protect(Bytes(text.begin(), text.end())));
|
||||||
|
} catch (...) {} // Closing the UI must still release its process if state cannot be saved.
|
||||||
|
}
|
||||||
@@ -0,0 +1,101 @@
|
|||||||
|
// Included by app.cpp; all App mutations happen on its window thread.
|
||||||
|
Bytes App::syncConflictData()
|
||||||
|
{
|
||||||
|
if (loadSyncConfig(data) != conflictConnection) return encodeSyncConflicts({});
|
||||||
|
return encodeSyncConflicts(pendingSyncConflicts);
|
||||||
|
}
|
||||||
|
std::wstring App::syncCommand(int action, const std::vector<SyncChoice> &choices)
|
||||||
|
{
|
||||||
|
if (action == 0) return syncStatus;
|
||||||
|
if (syncRunning) return L"Synchronization is already running.";
|
||||||
|
auto c = loadSyncConfig(data);
|
||||||
|
if (!c.enabled) return syncStatus = L"Synchronization is disabled.";
|
||||||
|
validateSyncConfig(c);
|
||||||
|
if (action == 4 && (c != conflictConnection || choices.empty()))
|
||||||
|
throw std::runtime_error("Connection changed or no choices selected. Sync again.");
|
||||||
|
if (busy) return L"Wait for the current text operation to finish.";
|
||||||
|
syncRetryAfter = 0; // Explicit retries may bypass the automatic error backoff.
|
||||||
|
if (syncWorker.joinable()) syncWorker.join();
|
||||||
|
syncConnection = c;
|
||||||
|
syncSnapshot = encodeSettings(settings);
|
||||||
|
auto snapshot = settings;
|
||||||
|
auto availableLayouts = layouts;
|
||||||
|
syncRunning = true;
|
||||||
|
syncDone = false;
|
||||||
|
syncStatus = L"Connecting to OpenBao...";
|
||||||
|
nextSync = GetTickCount64() + SyncIntervalMs;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
syncWorker = std::thread([this, c, snapshot, availableLayouts, action, choices] {
|
||||||
|
SyncResult result;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
auto provider = makeSyncProvider(c);
|
||||||
|
// An explicit choice also repairs a missing/corrupt local baseline.
|
||||||
|
auto base = action == 1 || action == 4 ? loadSyncBase(data, c) : Bytes{};
|
||||||
|
result = synchronize(*provider, base, sharedSyncSettings(snapshot),
|
||||||
|
action == 2 ? SyncAction::Download : action == 3 ? SyncAction::Upload : SyncAction::Automatic,
|
||||||
|
[&](const Bytes &b) { restoreSyncSettings(b, snapshot, availableLayouts, c.keepLocalLayouts); }, choices,
|
||||||
|
c.keepLocalLayouts);
|
||||||
|
if (result.success && c.keepLocalLayouts)
|
||||||
|
result.status += L" Partial sync: this PC's layouts and their shortcuts were kept; server layouts were preserved.";
|
||||||
|
}
|
||||||
|
catch (const nlohmann::json::exception &) { result.status = L"Invalid sync data or server response."; }
|
||||||
|
catch (const std::exception &e) { result.status = wide(e.what()); }
|
||||||
|
syncResult = std::move(result);
|
||||||
|
syncDone.store(true);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
catch (...) { syncRunning = false; Bytes().swap(syncSnapshot); syncResult = {}; throw; }
|
||||||
|
return syncStatus;
|
||||||
|
}
|
||||||
|
void App::pollSync()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (syncRunning && syncDone.load())
|
||||||
|
{
|
||||||
|
if (busy) return;
|
||||||
|
syncWorker.join();
|
||||||
|
// Own completed payloads locally so every return/exception releases them.
|
||||||
|
auto result = std::exchange(syncResult, SyncResult{});
|
||||||
|
auto snapshot = std::exchange(syncSnapshot, Bytes{});
|
||||||
|
syncRunning = false;
|
||||||
|
syncDone = false;
|
||||||
|
syncStatus = result.status;
|
||||||
|
if (result.success)
|
||||||
|
{
|
||||||
|
if (loadSyncConfig(data) != syncConnection || encodeSettings(settings) != snapshot)
|
||||||
|
{
|
||||||
|
syncStatus = L"Local settings or connection changed during sync. Checking again shortly.";
|
||||||
|
nextSync = GetTickCount64() + 2000;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
auto next = restoreSyncSettings(result.settings, settings, layouts, syncConnection.keepLocalLayouts);
|
||||||
|
if (encodeSettings(next) != snapshot)
|
||||||
|
{
|
||||||
|
atomicWrite(data / L"settings-before-sync.bin", protect(snapshot));
|
||||||
|
applySettings(next);
|
||||||
|
}
|
||||||
|
saveSyncBase(data, syncConnection, result.base.empty() ? result.settings : result.base);
|
||||||
|
pendingSyncConflicts = std::move(result.conflicts);
|
||||||
|
conflictConnection = syncConnection;
|
||||||
|
SYSTEMTIME time{}; GetLocalTime(&time);
|
||||||
|
wchar_t stamp[32]{};
|
||||||
|
swprintf(stamp, std::size(stamp), L" (%02u:%02u:%02u)", time.wHour, time.wMinute, time.wSecond);
|
||||||
|
syncStatus += stamp;
|
||||||
|
}
|
||||||
|
// Back off after errors (including bad credentials) instead of repeatedly
|
||||||
|
// hitting userpass lockout. The explicit Sync button remains available.
|
||||||
|
syncRetryAfter = result.success ? 0 : GetTickCount64() + 15 * 60000;
|
||||||
|
nextSync = result.success ? GetTickCount64() + SyncIntervalMs : syncRetryAfter;
|
||||||
|
}
|
||||||
|
if (!syncRunning && GetTickCount64() >= nextSync)
|
||||||
|
{
|
||||||
|
nextSync = GetTickCount64() + SyncIntervalMs;
|
||||||
|
if (loadSyncConfig(data).enabled) syncCommand(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (const nlohmann::json::exception &) { syncStatus = L"Invalid local sync configuration or cached profile."; nextSync = GetTickCount64() + SyncIntervalMs; }
|
||||||
|
catch (const std::exception &e) { syncStatus = wide(e.what()); nextSync = GetTickCount64() + SyncIntervalMs; }
|
||||||
|
}
|
||||||
+185
-42
@@ -42,82 +42,160 @@ bool safeAutoWord(const std::wstring &word, int minimumLength)
|
|||||||
auto small = lower(word);
|
auto small = lower(word);
|
||||||
return word == small || (word.substr(1) == small.substr(1) && word != upper(word));
|
return word == small || (word.substr(1) == small.substr(1) && word != upper(word));
|
||||||
}
|
}
|
||||||
std::string_view AutoCorrector::Dictionary::word(size_t index) const
|
namespace {
|
||||||
|
constexpr size_t DictionaryBlockWords = 32;
|
||||||
|
}
|
||||||
|
std::string_view AutoCorrector::Dictionary::word(size_t block) const
|
||||||
{
|
{
|
||||||
auto start = offsets[index];
|
size_t start = offsets[block];
|
||||||
auto end = bytes.find('\t', start);
|
// Every block starts with a complete word (zero shared prefix).
|
||||||
return std::string_view(bytes).substr(start, end - start);
|
size_t length = static_cast<unsigned char>(bytes[start++]) & 15;
|
||||||
|
if (length == 15) length = static_cast<unsigned char>(bytes[start++]);
|
||||||
|
return std::string_view(bytes).substr(start, length);
|
||||||
}
|
}
|
||||||
AutoCorrector::Dictionary::Dictionary(const std::filesystem::path &path)
|
AutoCorrector::Dictionary::Dictionary(const std::filesystem::path &path)
|
||||||
{
|
{
|
||||||
auto raw = readFile(path, 2 * 1024 * 1024);
|
const auto raw = readFile(path, 2 * 1024 * 1024);
|
||||||
bytes.assign(raw.begin(), raw.end());
|
const std::string_view source(reinterpret_cast<const char *>(raw.data()), raw.size());
|
||||||
for (size_t start = 0; start < bytes.size();)
|
std::vector<uint32_t> lines;
|
||||||
|
lines.reserve(std::count(source.begin(), source.end(), '\n') + 1);
|
||||||
|
for (size_t start = 0; start < source.size();)
|
||||||
{
|
{
|
||||||
auto end = bytes.find('\n', start);
|
auto end = source.find('\n', start);
|
||||||
if (end == bytes.npos)
|
if (end == source.npos) end = source.size();
|
||||||
end = bytes.size();
|
auto tab = source.find('\t', start);
|
||||||
auto tab = bytes.find('\t', start);
|
if (tab == source.npos || tab >= end || tab == start || tab - start > 160)
|
||||||
if (tab == bytes.npos || tab >= end || tab == start || tab - start > 160)
|
|
||||||
throw std::runtime_error("Invalid auto-correction dictionary");
|
throw std::runtime_error("Invalid auto-correction dictionary");
|
||||||
int rank{};
|
int rank{};
|
||||||
auto rankEnd = end > tab + 1 && bytes[end - 1] == '\r' ? end - 1 : end;
|
auto rankEnd = end > tab + 1 && source[end - 1] == '\r' ? end - 1 : end;
|
||||||
auto parse = std::from_chars(bytes.data() + tab + 1, bytes.data() + rankEnd, rank);
|
auto parse = std::from_chars(source.data() + tab + 1, source.data() + rankEnd, rank);
|
||||||
if (parse.ec != std::errc() || parse.ptr != bytes.data() + rankEnd || rank <= 0)
|
if (parse.ec != std::errc() || parse.ptr != source.data() + rankEnd || rank <= 0)
|
||||||
throw std::runtime_error("Invalid dictionary rank");
|
throw std::runtime_error("Invalid dictionary rank");
|
||||||
offsets.push_back((uint32_t)start);
|
lines.push_back(static_cast<uint32_t>(start));
|
||||||
start = end + 1;
|
start = end + 1;
|
||||||
}
|
}
|
||||||
if (offsets.empty())
|
if (lines.empty()) throw std::runtime_error("Empty auto-correction dictionary");
|
||||||
throw std::runtime_error("Empty auto-correction dictionary");
|
auto entry = [&](uint32_t offset) { return source.substr(offset, source.find('\t', offset) - offset); };
|
||||||
auto entry = [&](uint32_t offset) { return std::string_view(bytes).substr(offset, bytes.find('\t', offset) - offset); };
|
auto frequency = [&](uint32_t offset) {
|
||||||
auto frequency = [&](uint32_t offset)
|
|
||||||
{
|
|
||||||
int rank{};
|
int rank{};
|
||||||
auto start = offset + entry(offset).size() + 1;
|
auto start = offset + entry(offset).size() + 1;
|
||||||
std::from_chars(bytes.data() + start, bytes.data() + bytes.size(), rank);
|
std::from_chars(source.data() + start, source.data() + source.size(), rank);
|
||||||
return rank;
|
return rank;
|
||||||
};
|
};
|
||||||
std::sort(offsets.begin(), offsets.end(), [&](uint32_t a, uint32_t b)
|
std::sort(lines.begin(), lines.end(), [&](uint32_t a, uint32_t b) {
|
||||||
{ return entry(a) == entry(b) ? frequency(a) < frequency(b) : entry(a) < entry(b); });
|
return entry(a) == entry(b) ? frequency(a) < frequency(b) : entry(a) < entry(b);
|
||||||
offsets.erase(std::unique(offsets.begin(), offsets.end(), [&](uint32_t a, uint32_t b)
|
});
|
||||||
{ return entry(a) == entry(b); }), offsets.end());
|
lines.erase(std::unique(lines.begin(), lines.end(), [&](uint32_t a, uint32_t b) {
|
||||||
offsets.shrink_to_fit();
|
return entry(a) == entry(b);
|
||||||
bytes.shrink_to_fit();
|
}), lines.end());
|
||||||
|
offsets.reserve((lines.size() + DictionaryBlockWords - 1) / DictionaryBlockWords);
|
||||||
|
std::string_view previous;
|
||||||
|
// Allocate the packed payload exactly once. Geometric growth and a final
|
||||||
|
// shrink otherwise leave discarded buffers in the resident process heap.
|
||||||
|
size_t packedSize = 0;
|
||||||
|
for (size_t i = 0; i < lines.size(); ++i)
|
||||||
|
{
|
||||||
|
auto current = entry(lines[i]);
|
||||||
|
size_t prefix = 0;
|
||||||
|
if (i % DictionaryBlockWords != 0)
|
||||||
|
while (prefix < std::min(previous.size(), current.size()) && previous[prefix] == current[prefix]) ++prefix;
|
||||||
|
auto suffix = current.size() - prefix;
|
||||||
|
packedSize += 1 + (prefix >= 15) + (suffix >= 15) + suffix + 2;
|
||||||
|
auto rank = static_cast<uint32_t>(frequency(lines[i]));
|
||||||
|
if (rank >= 65535)
|
||||||
|
do { ++packedSize; rank >>= 7; } while (rank);
|
||||||
|
previous = current;
|
||||||
|
}
|
||||||
|
bytes.reserve(packedSize);
|
||||||
|
previous = {};
|
||||||
|
for (size_t i = 0; i < lines.size(); ++i)
|
||||||
|
{
|
||||||
|
auto current = entry(lines[i]);
|
||||||
|
size_t prefix = 0;
|
||||||
|
if (i % DictionaryBlockWords == 0)
|
||||||
|
offsets.push_back(static_cast<uint32_t>(bytes.size()));
|
||||||
|
else
|
||||||
|
while (prefix < std::min(previous.size(), current.size()) && previous[prefix] == current[prefix]) ++prefix;
|
||||||
|
size_t suffix = current.size() - prefix;
|
||||||
|
bytes.push_back(static_cast<char>((std::min(prefix, size_t(15)) << 4) | std::min(suffix, size_t(15))));
|
||||||
|
if (prefix >= 15) bytes.push_back(static_cast<char>(prefix));
|
||||||
|
if (suffix >= 15) bytes.push_back(static_cast<char>(suffix));
|
||||||
|
bytes.append(current.substr(prefix));
|
||||||
|
auto rank = static_cast<uint32_t>(frequency(lines[i]));
|
||||||
|
auto shortRank = std::min(rank, uint32_t(65535));
|
||||||
|
bytes.push_back(static_cast<char>(shortRank & 255));
|
||||||
|
bytes.push_back(static_cast<char>(shortRank >> 8));
|
||||||
|
if (rank >= 65535)
|
||||||
|
do {
|
||||||
|
auto next = rank & 127;
|
||||||
|
rank >>= 7;
|
||||||
|
bytes.push_back(static_cast<char>(next | (rank ? 128 : 0)));
|
||||||
|
} while (rank);
|
||||||
|
previous = current;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
int AutoCorrector::Dictionary::rank(const std::wstring &text) const
|
int AutoCorrector::Dictionary::rank(const std::wstring &text) const
|
||||||
{
|
{
|
||||||
auto key = utf8(lower(text));
|
auto key = utf8(lower(text));
|
||||||
size_t begin = 0, end = offsets.size();
|
size_t begin = 0, end = offsets.size();
|
||||||
|
// Find the last block whose first word is <= the search key.
|
||||||
while (begin < end)
|
while (begin < end)
|
||||||
{
|
{
|
||||||
auto mid = begin + (end - begin) / 2;
|
auto mid = begin + (end - begin) / 2;
|
||||||
if (word(mid) < key)
|
if (word(mid) <= key) begin = mid + 1;
|
||||||
begin = mid + 1;
|
else end = mid;
|
||||||
else
|
}
|
||||||
end = mid;
|
if (!begin) return 0;
|
||||||
|
size_t block = begin - 1;
|
||||||
|
size_t at = offsets[block];
|
||||||
|
const size_t limit = begin < offsets.size() ? offsets[begin] : bytes.size();
|
||||||
|
char decoded[160]; // The loader validates lengths; lookup never allocates a decoded word.
|
||||||
|
while (at < limit)
|
||||||
|
{
|
||||||
|
auto lengths = static_cast<unsigned char>(bytes[at++]);
|
||||||
|
size_t prefix = lengths >> 4, suffix = lengths & 15;
|
||||||
|
if (prefix == 15) prefix = static_cast<unsigned char>(bytes[at++]);
|
||||||
|
if (suffix == 15) suffix = static_cast<unsigned char>(bytes[at++]);
|
||||||
|
memcpy(decoded + prefix, bytes.data() + at, suffix);
|
||||||
|
at += suffix;
|
||||||
|
uint32_t rank = static_cast<unsigned char>(bytes[at]) |
|
||||||
|
(uint32_t(static_cast<unsigned char>(bytes[at + 1])) << 8);
|
||||||
|
at += 2;
|
||||||
|
if (rank == 65535) {
|
||||||
|
rank = 0;
|
||||||
|
uint32_t shift = 0;
|
||||||
|
unsigned char part;
|
||||||
|
do {
|
||||||
|
part = static_cast<unsigned char>(bytes[at++]);
|
||||||
|
rank |= uint32_t(part & 127) << shift;
|
||||||
|
shift += 7;
|
||||||
|
} while (part & 128);
|
||||||
|
}
|
||||||
|
auto compared = std::string_view(decoded, size_t(prefix) + suffix).compare(key);
|
||||||
|
if (compared == 0) return static_cast<int>(rank);
|
||||||
|
if (compared > 0) return 0;
|
||||||
}
|
}
|
||||||
if (begin == offsets.size() || word(begin) != key)
|
|
||||||
return 0;
|
return 0;
|
||||||
auto start = offsets[begin] + word(begin).size() + 1;
|
|
||||||
int rank{};
|
|
||||||
std::from_chars(bytes.data() + start, bytes.data() + bytes.size(), rank);
|
|
||||||
return rank;
|
|
||||||
}
|
}
|
||||||
void AutoCorrector::configure(const std::filesystem::path &folder, const std::vector<std::wstring> &wanted)
|
void AutoCorrector::configure(const std::filesystem::path &folder, const std::vector<std::wstring> &wanted)
|
||||||
{
|
{
|
||||||
if (languages == wanted)
|
if (languages == wanted)
|
||||||
return;
|
return;
|
||||||
std::map<std::wstring, Dictionary> next;
|
std::map<std::wstring, std::shared_ptr<const Dictionary>> next;
|
||||||
for (auto &lang : wanted)
|
for (auto &lang : wanted)
|
||||||
{
|
{
|
||||||
if (lang != L"en" && lang != L"uk" && lang != L"ru")
|
if (lang != L"en" && lang != L"uk" && lang != L"ru")
|
||||||
throw std::runtime_error("Unsupported dictionary language");
|
throw std::runtime_error("Unsupported dictionary language");
|
||||||
next.emplace(lang, Dictionary(folder / (lang + L".txt")));
|
next.emplace(lang, std::make_shared<const Dictionary>(folder / (lang + L".txt")));
|
||||||
}
|
}
|
||||||
dictionaries = std::move(next);
|
dictionaries = std::move(next);
|
||||||
languages = wanted;
|
languages = wanted;
|
||||||
}
|
}
|
||||||
|
void AutoCorrector::shareDictionaries(const AutoCorrector &source)
|
||||||
|
{
|
||||||
|
dictionaries = source.dictionaries;
|
||||||
|
languages = source.languages;
|
||||||
|
}
|
||||||
void AutoCorrector::reject(std::wstring word, const Settings &settings)
|
void AutoCorrector::reject(std::wstring word, const Settings &settings)
|
||||||
{
|
{
|
||||||
while (!word.empty() && openingDelimiter(word.front(), settings))
|
while (!word.empty() && openingDelimiter(word.front(), settings))
|
||||||
@@ -132,7 +210,7 @@ size_t AutoCorrector::memoryBytes() const
|
|||||||
{
|
{
|
||||||
size_t bytes = 0;
|
size_t bytes = 0;
|
||||||
for (auto &[language, d] : dictionaries)
|
for (auto &[language, d] : dictionaries)
|
||||||
bytes += d.bytes.capacity() + d.offsets.capacity() * sizeof(uint32_t);
|
bytes += d->bytes.capacity() + d->offsets.capacity() * sizeof(uint32_t);
|
||||||
return bytes;
|
return bytes;
|
||||||
}
|
}
|
||||||
std::optional<AutoSuggestion> AutoCorrector::suggest(const std::wstring &typed, int source,
|
std::optional<AutoSuggestion> AutoCorrector::suggest(const std::wstring &typed, int source,
|
||||||
@@ -164,6 +242,24 @@ std::optional<AutoSuggestion> AutoCorrector::suggest(const std::wstring &typed,
|
|||||||
auto sourceLanguage = layoutLanguage(layouts[source]);
|
auto sourceLanguage = layoutLanguage(layouts[source]);
|
||||||
if (!dictionaries.contains(sourceLanguage))
|
if (!dictionaries.contains(sourceLanguage))
|
||||||
return {};
|
return {};
|
||||||
|
const std::wstring alphabet = sourceLanguage == L"en" ? L"abcdefghijklmnopqrstuvwxyz" :
|
||||||
|
sourceLanguage == L"uk" ? L"абвгґдеєжзиіїйклмнопрстуфхцчшщьюя" : L"абвгдеёжзийклмнопрстуфхцчшщъыьэюя";
|
||||||
|
auto small = lower(word);
|
||||||
|
bool sameLanguage = safeAutoWord(word, settings.autoMinLength) &&
|
||||||
|
small.find_first_not_of(alphabet) == small.npos &&
|
||||||
|
std::find(settings.cycle.begin(), settings.cycle.end(), layouts[source].id) != settings.cycle.end();
|
||||||
|
auto sameLayout = [&](std::wstring text)
|
||||||
|
{
|
||||||
|
if (word != small) text[0] = upper(text.substr(0, 1))[0];
|
||||||
|
return AutoSuggestion{source, source, prefix + text + suffix};
|
||||||
|
};
|
||||||
|
if (settings.autoReplace && sameLanguage)
|
||||||
|
{
|
||||||
|
auto replacement = settings.autoReplacements.find(small);
|
||||||
|
if (replacement != settings.autoReplacements.end() &&
|
||||||
|
replacement->second.find_first_not_of(alphabet + L" ") == small.npos)
|
||||||
|
return sameLayout(replacement->second);
|
||||||
|
}
|
||||||
auto personal = [&](const std::wstring &language, const std::wstring &candidate)
|
auto personal = [&](const std::wstring &language, const std::wstring &candidate)
|
||||||
{
|
{
|
||||||
auto found = settings.autoWords.find(language);
|
auto found = settings.autoWords.find(language);
|
||||||
@@ -173,7 +269,7 @@ std::optional<AutoSuggestion> AutoCorrector::suggest(const std::wstring &typed,
|
|||||||
};
|
};
|
||||||
// Valid words from either selected language are never changed.
|
// Valid words from either selected language are never changed.
|
||||||
for (auto &[language, d] : dictionaries)
|
for (auto &[language, d] : dictionaries)
|
||||||
if (d.rank(word) || personal(language, word))
|
if (d->rank(word) || personal(language, word))
|
||||||
return {};
|
return {};
|
||||||
std::optional<AutoSuggestion> candidate;
|
std::optional<AutoSuggestion> candidate;
|
||||||
std::optional<std::wstring> matchedText;
|
std::optional<std::wstring> matchedText;
|
||||||
@@ -193,7 +289,7 @@ std::optional<AutoSuggestion> AutoCorrector::suggest(const std::wstring &typed,
|
|||||||
auto converted = convert(word, layouts[source], layouts[i], true);
|
auto converted = convert(word, layouts[source], layouts[i], true);
|
||||||
if (converted == word || !safeAutoWord(converted, settings.autoMinLength))
|
if (converted == word || !safeAutoWord(converted, settings.autoMinLength))
|
||||||
continue;
|
continue;
|
||||||
int rank = personal(dictionary->first, converted) ? 1 : dictionary->second.rank(converted);
|
int rank = personal(dictionary->first, converted) ? 1 : dictionary->second->rank(converted);
|
||||||
if (!rank)
|
if (!rank)
|
||||||
continue;
|
continue;
|
||||||
if (matchedText && *matchedText != converted)
|
if (matchedText && *matchedText != converted)
|
||||||
@@ -203,7 +299,54 @@ std::optional<AutoSuggestion> AutoCorrector::suggest(const std::wstring &typed,
|
|||||||
(!candidate || priority(i) < priority(candidate->target)))
|
(!candidate || priority(i) < priority(candidate->target)))
|
||||||
candidate = AutoSuggestion{source, i, prefix + converted + suffix};
|
candidate = AutoSuggestion{source, i, prefix + converted + suffix};
|
||||||
}
|
}
|
||||||
|
if (candidate || matchedText || !settings.autoTypos || !sameLanguage || word.size() < 4)
|
||||||
return candidate;
|
return candidate;
|
||||||
|
// Generate only single edits. Stop at a second distinct dictionary hit,
|
||||||
|
// including rare hits: frequency limits must never hide ambiguity.
|
||||||
|
std::wstring found;
|
||||||
|
int foundRank = 0;
|
||||||
|
std::set<std::wstring> personalTargets;
|
||||||
|
if (auto it = settings.autoWords.find(sourceLanguage); it != settings.autoWords.end())
|
||||||
|
for (const auto &text : it->second) personalTargets.insert(lower(text));
|
||||||
|
auto consider = [&](const std::wstring &text)
|
||||||
|
{
|
||||||
|
if (text == small || text == found || text.size() < 4 || text.size() > 32) return true;
|
||||||
|
int rank = personalTargets.contains(text) ? 1 : dictionaries.at(sourceLanguage)->rank(text);
|
||||||
|
if (!rank) return true;
|
||||||
|
if (!found.empty()) return false;
|
||||||
|
found = text;
|
||||||
|
foundRank = rank;
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
for (size_t i = 0; i < small.size(); ++i)
|
||||||
|
{
|
||||||
|
auto text = small;
|
||||||
|
text.erase(i, 1);
|
||||||
|
if (!consider(text)) return {};
|
||||||
|
if (i + 1 < small.size())
|
||||||
|
{
|
||||||
|
text = small;
|
||||||
|
std::swap(text[i], text[i + 1]);
|
||||||
|
if (!consider(text)) return {};
|
||||||
|
}
|
||||||
|
for (wchar_t c : alphabet)
|
||||||
|
{
|
||||||
|
text = small;
|
||||||
|
text[i] = c;
|
||||||
|
if (!consider(text)) return {};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (small.size() < 32)
|
||||||
|
for (size_t i = 0; i <= small.size(); ++i)
|
||||||
|
for (wchar_t c : alphabet)
|
||||||
|
{
|
||||||
|
auto text = small;
|
||||||
|
text.insert(i, 1, c);
|
||||||
|
if (!consider(text)) return {};
|
||||||
|
}
|
||||||
|
if (!found.empty() && (settings.autoMaxRank == 0 || foundRank <= settings.autoMaxRank))
|
||||||
|
return sameLayout(found);
|
||||||
|
return {};
|
||||||
}
|
}
|
||||||
int matchAutoInput(const Run &run, const std::wstring &text, const std::vector<Layout> &layouts,
|
int matchAutoInput(const Run &run, const std::wstring &text, const std::vector<Layout> &layouts,
|
||||||
const Layout &physical, const Settings &settings)
|
const Layout &physical, const Settings &settings)
|
||||||
|
|||||||
+9
-1
@@ -1,6 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "platform.h"
|
#include "platform.h"
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#include <memory>
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <string_view>
|
#include <string_view>
|
||||||
namespace ks
|
namespace ks
|
||||||
@@ -18,23 +19,30 @@ int matchAutoInput(const Run &, const std::wstring &, const std::vector<Layout>
|
|||||||
bool autoCorrectionAllowed(HWND, const Settings &);
|
bool autoCorrectionAllowed(HWND, const Settings &);
|
||||||
class AutoCorrector
|
class AutoCorrector
|
||||||
{
|
{
|
||||||
|
friend struct AutoCorrectorRegressionAccess;
|
||||||
struct Dictionary
|
struct Dictionary
|
||||||
{
|
{
|
||||||
|
// Front-coded UTF-8 words in independently searchable blocks of 32.
|
||||||
|
// Prefix/suffix lengths share a byte (15 escapes to a full byte length).
|
||||||
|
// Ranks use two bytes; 65535 escapes to a varint for larger custom ranks.
|
||||||
std::string bytes;
|
std::string bytes;
|
||||||
std::vector<uint32_t> offsets;
|
std::vector<uint32_t> offsets;
|
||||||
std::string_view word(size_t) const;
|
std::string_view word(size_t) const;
|
||||||
explicit Dictionary(const std::filesystem::path &);
|
explicit Dictionary(const std::filesystem::path &);
|
||||||
int rank(const std::wstring &) const;
|
int rank(const std::wstring &) const;
|
||||||
};
|
};
|
||||||
std::map<std::wstring, Dictionary> dictionaries;
|
std::map<std::wstring, std::shared_ptr<const Dictionary>> dictionaries;
|
||||||
std::vector<std::wstring> languages;
|
std::vector<std::wstring> languages;
|
||||||
std::set<std::wstring> rejected;
|
std::set<std::wstring> rejected;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void configure(const std::filesystem::path &, const std::vector<std::wstring> &);
|
void configure(const std::filesystem::path &, const std::vector<std::wstring> &);
|
||||||
|
// Share immutable dictionary storage, keeping each consumer's undo rejections private.
|
||||||
|
void shareDictionaries(const AutoCorrector &);
|
||||||
std::optional<AutoSuggestion> suggest(const std::wstring &, int source, const std::vector<Layout> &,
|
std::optional<AutoSuggestion> suggest(const std::wstring &, int source, const std::vector<Layout> &,
|
||||||
const Settings &) const;
|
const Settings &) const;
|
||||||
void reject(std::wstring word, const Settings & = {});
|
void reject(std::wstring word, const Settings & = {});
|
||||||
|
// Referenced dictionary payload, including shared storage (do not sum across consumers).
|
||||||
size_t memoryBytes() const;
|
size_t memoryBytes() const;
|
||||||
};
|
};
|
||||||
} // namespace ks
|
} // namespace ks
|
||||||
@@ -0,0 +1,143 @@
|
|||||||
|
// Chrome Telegram Web integration: native accessibility, no OCR or polling timer.
|
||||||
|
#include "chat_context.h"
|
||||||
|
#include <uiautomation.h>
|
||||||
|
#include <atomic>
|
||||||
|
#include <thread>
|
||||||
|
namespace ks {
|
||||||
|
namespace {
|
||||||
|
template<class T> struct BrowserCom {
|
||||||
|
T *p{}; ~BrowserCom(){if(p)p->Release();}
|
||||||
|
T** out(){return &p;} T* operator->(){return p;}
|
||||||
|
};
|
||||||
|
std::wstring browserString(IUIAutomationElement* e, PROPERTYID id) {
|
||||||
|
VARIANT v;VariantInit(&v);std::wstring s;
|
||||||
|
if(SUCCEEDED(e->GetCurrentPropertyValue(id,&v)) && v.vt==VT_BSTR && v.bstrVal) s.assign(v.bstrVal,SysStringLen(v.bstrVal));
|
||||||
|
VariantClear(&v);return s;
|
||||||
|
}
|
||||||
|
struct ChromeElements { BrowserCom<IUIAutomationElement> address,document,header; int addresses{},documents{}; };
|
||||||
|
void findChromeElements(IUIAutomationTreeWalker* walker,IUIAutomationElement* e,ChromeElements& found,int depth,int& budget) {
|
||||||
|
if(depth>12 || --budget<0)return;
|
||||||
|
CONTROLTYPEID type{};BOOL offscreen=TRUE;e->get_CurrentControlType(&type);e->get_CurrentIsOffscreen(&offscreen);
|
||||||
|
if(type==UIA_DocumentControlTypeId){
|
||||||
|
if(!offscreen && browserString(e,UIA_AutomationIdPropertyId)==L"RootWebArea"){
|
||||||
|
if(++found.documents==1){e->AddRef();found.document.p=e;}}
|
||||||
|
return; // Never traverse message content.
|
||||||
|
}
|
||||||
|
if(type==UIA_EditControlTypeId && !offscreen && browserString(e,UIA_ClassNamePropertyId)==L"OmniboxViewViews"){
|
||||||
|
if(++found.addresses==1){e->AddRef();found.address.p=e;}}
|
||||||
|
BrowserCom<IUIAutomationElement> child;walker->GetFirstChildElement(e,child.out());
|
||||||
|
while(child.p && budget>0){findChromeElements(walker,child.p,found,depth+1,budget);BrowserCom<IUIAutomationElement> next;walker->GetNextSiblingElement(child.p,next.out());child.p->Release();child.p=next.p;next.p=nullptr;}
|
||||||
|
}
|
||||||
|
IUIAutomationElement* chromeHeader(IUIAutomationTreeWalker* walker,IUIAutomationElement* document) {
|
||||||
|
// Web K's center pane is separate from its chat list and message history.
|
||||||
|
std::function<IUIAutomationElement*(IUIAutomationElement*,int)> center;
|
||||||
|
center=[&](IUIAutomationElement* e,int depth)->IUIAutomationElement* {
|
||||||
|
if(depth>3)return nullptr;
|
||||||
|
if(browserString(e,UIA_AutomationIdPropertyId)==L"column-center"){e->AddRef();return e;}
|
||||||
|
auto id=browserString(e,UIA_AutomationIdPropertyId);if(id==L"column-left"||id==L"column-right")return nullptr;
|
||||||
|
BrowserCom<IUIAutomationElement> c;walker->GetFirstChildElement(e,c.out());int limit=12;
|
||||||
|
while(c.p && --limit>0){if(auto result=center(c.p,depth+1))return result;BrowserCom<IUIAutomationElement> next;walker->GetNextSiblingElement(c.p,next.out());c.p->Release();c.p=next.p;next.p=nullptr;}return nullptr;
|
||||||
|
};
|
||||||
|
BrowserCom<IUIAutomationElement> pane;pane.p=center(document,0);if(!pane.p)return nullptr;
|
||||||
|
BrowserCom<IUIAutomationElement> header;walker->GetFirstChildElement(pane.p,header.out());if(!header.p)return nullptr;
|
||||||
|
BrowserCom<IUIAutomationElement> c;walker->GetFirstChildElement(header.p,c.out());int limit=16,buttons=0;IUIAutomationElement* title{};
|
||||||
|
while(c.p && --limit>0){CONTROLTYPEID type{};c->get_CurrentControlType(&type);if(type==UIA_ButtonControlTypeId)++buttons;
|
||||||
|
if(type==UIA_TextControlTypeId && !title){title=c.p;title->AddRef();}
|
||||||
|
BrowserCom<IUIAutomationElement> next;walker->GetNextSiblingElement(c.p,next.out());c.p->Release();c.p=next.p;next.p=nullptr;}
|
||||||
|
if(buttons<2 && title){title->Release();title=nullptr;}return title;
|
||||||
|
}
|
||||||
|
std::wstring chromeTitleKey(IUIAutomationElement* header){
|
||||||
|
if(!header)return {};
|
||||||
|
auto name=browserString(header,UIA_NamePropertyId);
|
||||||
|
if(name.empty()||name.size()>512||name.find_first_of(L"\r\n")!=name.npos)return {};
|
||||||
|
return L"telegram-web\n"+name;
|
||||||
|
}
|
||||||
|
std::wstring chromeSnapshot(IUIAutomation* uia,HWND window,ChromeElements& found) {
|
||||||
|
if(!IsWindow(window)||IsIconic(window)||lower(processName(window))!=L"chrome")return {};
|
||||||
|
BrowserCom<IUIAutomationElement> root;BrowserCom<IUIAutomationTreeWalker> walker;
|
||||||
|
if(FAILED(uia->ElementFromHandle(window,root.out()))||!root.p||FAILED(uia->get_ControlViewWalker(walker.out())))return {};
|
||||||
|
int budget=250;findChromeElements(walker.p,root.p,found,0,budget);
|
||||||
|
if(found.addresses!=1||found.documents!=1)return {};
|
||||||
|
auto address=telegramWebKey(browserString(found.address.p,UIA_ValueValuePropertyId));
|
||||||
|
auto document=telegramWebKey(browserString(found.document.p,UIA_ValueValuePropertyId));
|
||||||
|
BOOL editing=FALSE;found.address->get_CurrentHasKeyboardFocus(&editing);
|
||||||
|
if(editing || address.empty() || address!=document)return {};
|
||||||
|
found.header.p=chromeHeader(walker.p,found.document.p);
|
||||||
|
return chromeTitleKey(found.header.p);
|
||||||
|
}
|
||||||
|
std::mutex browserMutex;
|
||||||
|
HWND browserWindow{};std::wstring browserKey;
|
||||||
|
std::atomic<DWORD> browserThreadId{};
|
||||||
|
std::atomic<bool> browserPending{}, browserStopping{};
|
||||||
|
std::thread browserThread;
|
||||||
|
void invalidateBrowser(){std::lock_guard lock(browserMutex);browserKey.clear();}
|
||||||
|
void requestBrowser(){invalidateBrowser();auto id=browserThreadId.load();if(id && !browserPending.exchange(true))PostThreadMessageW(id,WM_APP+61,0,0);}
|
||||||
|
void CALLBACK browserForeground(HWINEVENTHOOK,DWORD,HWND,LONG,LONG,DWORD,DWORD){requestBrowser();}
|
||||||
|
class BrowserChanged final: public IUIAutomationPropertyChangedEventHandler {
|
||||||
|
std::atomic<ULONG> refs{1};
|
||||||
|
public:
|
||||||
|
HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid,void** out) override {if(!out)return E_POINTER;*out=nullptr;if(iid==IID_IUnknown||iid==IID_IUIAutomationPropertyChangedEventHandler){*out=static_cast<IUIAutomationPropertyChangedEventHandler*>(this);AddRef();return S_OK;}return E_NOINTERFACE;}
|
||||||
|
ULONG STDMETHODCALLTYPE AddRef() override{return ++refs;}
|
||||||
|
ULONG STDMETHODCALLTYPE Release() override{auto n=--refs;if(!n)delete this;return n;}
|
||||||
|
HRESULT STDMETHODCALLTYPE HandlePropertyChangedEvent(IUIAutomationElement*,PROPERTYID,VARIANT) override {requestBrowser();return S_OK;}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
std::wstring readChromeChat(HWND window) {
|
||||||
|
auto hr=CoInitializeEx(nullptr,COINIT_MULTITHREADED);
|
||||||
|
struct Apartment{bool own;~Apartment(){if(own)CoUninitialize();}} apartment{SUCCEEDED(hr)};
|
||||||
|
BrowserCom<IUIAutomation2> uia;
|
||||||
|
if(FAILED(CoCreateInstance(CLSID_CUIAutomation8,nullptr,CLSCTX_INPROC_SERVER,IID_IUIAutomation2,(void**)uia.out())))return {};
|
||||||
|
uia->put_ConnectionTimeout(150);uia->put_TransactionTimeout(150);
|
||||||
|
ChromeElements elements;return chromeSnapshot(uia.p,window,elements);
|
||||||
|
}
|
||||||
|
std::wstring cachedChromeChat(HWND window){std::lock_guard lock(browserMutex);return window==browserWindow?browserKey:L"";}
|
||||||
|
void startBrowserChatMonitor(){
|
||||||
|
if(browserThread.joinable())return;
|
||||||
|
browserStopping=false;
|
||||||
|
browserThread=std::thread([] {
|
||||||
|
CoInitializeEx(nullptr,COINIT_MULTITHREADED);MSG message{};PeekMessageW(&message,nullptr,0,0,PM_NOREMOVE);
|
||||||
|
browserThreadId=GetCurrentThreadId();
|
||||||
|
auto foreground=SetWinEventHook(EVENT_SYSTEM_FOREGROUND,EVENT_SYSTEM_FOREGROUND,nullptr,browserForeground,0,0,WINEVENT_OUTOFCONTEXT);
|
||||||
|
// Focus changes cover tab selection and entering/leaving the address bar.
|
||||||
|
auto focus=SetWinEventHook(EVENT_OBJECT_FOCUS,EVENT_OBJECT_FOCUS,nullptr,browserForeground,0,0,WINEVENT_OUTOFCONTEXT);
|
||||||
|
BrowserCom<IUIAutomation2> uia;CoCreateInstance(CLSID_CUIAutomation8,nullptr,CLSCTX_INPROC_SERVER,IID_IUIAutomation2,(void**)uia.out());
|
||||||
|
BrowserCom<IUIAutomationElement> address,document,header;BrowserCom<BrowserChanged> handler;handler.p=new BrowserChanged;
|
||||||
|
if(uia.p){uia->put_ConnectionTimeout(150);uia->put_TransactionTimeout(150);}
|
||||||
|
requestBrowser();
|
||||||
|
if(browserStopping)PostThreadMessageW(GetCurrentThreadId(),WM_QUIT,0,0);
|
||||||
|
while(GetMessageW(&message,nullptr,0,0)>0){
|
||||||
|
if(message.message!=WM_APP+61){TranslateMessage(&message);DispatchMessageW(&message);continue;}
|
||||||
|
browserPending=false;
|
||||||
|
if(!uia.p)continue;
|
||||||
|
if(address.p){uia->RemovePropertyChangedEventHandler(address.p,handler.p);address.p->Release();address.p=nullptr;}
|
||||||
|
if(document.p){uia->RemovePropertyChangedEventHandler(document.p,handler.p);document.p->Release();document.p=nullptr;}
|
||||||
|
if(header.p){uia->RemovePropertyChangedEventHandler(header.p,handler.p);header.p->Release();header.p=nullptr;}
|
||||||
|
auto window=GetForegroundWindow();ChromeElements elements;auto key=chromeSnapshot(uia.p,window,elements);
|
||||||
|
PROPERTYID properties[]={UIA_ValueValuePropertyId};
|
||||||
|
bool subscribed=elements.address.p && elements.document.p;
|
||||||
|
if(subscribed){address.p=elements.address.p;elements.address.p=nullptr;document.p=elements.document.p;elements.document.p=nullptr;
|
||||||
|
subscribed=SUCCEEDED(uia->AddPropertyChangedEventHandlerNativeArray(address.p,TreeScope_Element,nullptr,handler.p,properties,1));
|
||||||
|
subscribed=SUCCEEDED(uia->AddPropertyChangedEventHandlerNativeArray(document.p,TreeScope_Element,nullptr,handler.p,properties,1)) && subscribed;
|
||||||
|
if(elements.header.p){header.p=elements.header.p;elements.header.p=nullptr;PROPERTYID nameProperty=UIA_NamePropertyId;
|
||||||
|
subscribed=SUCCEEDED(uia->AddPropertyChangedEventHandlerNativeArray(header.p,TreeScope_Element,nullptr,handler.p,&nameProperty,1)) && subscribed;}
|
||||||
|
// Close the read/subscribe race without scanning the content tree.
|
||||||
|
key=telegramWebKey(browserString(address.p,UIA_ValueValuePropertyId));
|
||||||
|
if(key.empty() || key!=telegramWebKey(browserString(document.p,UIA_ValueValuePropertyId)))key.clear();
|
||||||
|
else key=chromeTitleKey(header.p);
|
||||||
|
BOOL editing=FALSE;address->get_CurrentHasKeyboardFocus(&editing);if(editing)key.clear();
|
||||||
|
}
|
||||||
|
std::lock_guard lock(browserMutex);browserWindow=window;browserKey=subscribed && !browserPending && window==GetForegroundWindow()?key:L"";
|
||||||
|
}
|
||||||
|
browserThreadId=0;
|
||||||
|
if(foreground)UnhookWinEvent(foreground);
|
||||||
|
if(focus)UnhookWinEvent(focus);
|
||||||
|
if(uia.p){if(header.p)uia->RemovePropertyChangedEventHandler(header.p,handler.p);if(address.p)uia->RemovePropertyChangedEventHandler(address.p,handler.p);if(document.p)uia->RemovePropertyChangedEventHandler(document.p,handler.p);}
|
||||||
|
invalidateBrowser();
|
||||||
|
// COM objects release before uninitializing the apartment below.
|
||||||
|
if(header.p){header.p->Release();header.p=nullptr;}
|
||||||
|
if(address.p){address.p->Release();address.p=nullptr;}if(document.p){document.p->Release();document.p=nullptr;}
|
||||||
|
if(uia.p){uia.p->Release();uia.p=nullptr;}CoUninitialize();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
void stopBrowserChatMonitor(){browserStopping=true;auto id=browserThreadId.load();if(id)PostThreadMessageW(id,WM_QUIT,0,0);if(browserThread.joinable())browserThread.join();browserPending=false;}
|
||||||
|
}
|
||||||
@@ -0,0 +1,119 @@
|
|||||||
|
|||||||