This change improves the stability of Keyman for Windows by monitoring
the health of the low level keyboard hook. If keyman.exe is unresponsive
at any time, Windows can silently uninstall its low level keyboard hook,
which results in (at least) two problems:
* Keyman's hotkeys stop working
* A modifier key can become stuck, if it was pressed around the time
Keyman became unresponsive.
The most common scenario in which Keyman can become unresponsive is high
system load, e.g. rendering graphics, videoconference calls, compiling
software.
Restarting Keyman always resolved both of these two issues in the past,
but with this patch, I hope that this will no longer be necessary.
A related 'fakefreeze' project is not included in this cherry-pick; see
PR #15179 for this.
Logging has been updated; look for "LowLevelHookWatchDog" in the log for
related events.
One final small change in keyman32.cpp, as I refactored the
WH_KEYBOARD_LL hook installation/uninstallation, was to always clear out
hook variables when uninstalling a hook, because if the hook fails to
uninstall, there's really nothing we can do about it anyway, and we
probably shouldn't be trying again.
Fixes: #8064
Cherry-pick-of: #15179
Test-bot: skip
Build-bot: skip
Fixes: #14342
The Windows system level keyboard hotkeys controlled in
registry have sometimes been incorrectly written as
a DWORD datatype. There 106 events in sentry for just
July. When opening the Windows setting dialog and the registry
has DWORDS it will show unassinged in the dialog if apply
is pressed it will convert the keys to REG_SZ.
This fix follows a similar pattern it will check the data
type of the registry key if it is DWORD it will remove it
and add a new key of the same name as REG_SZ and set it to
the unassigned value.
Fixes: KEYMAN-WINDOWS-4NK
This was flagged years ago as a potential performance hotspot: each
locale is loaded at process start for any kmcomapi-involved process,
which takes quite a long time. This refactor moves the locale
enumeration out of kmcomapi and into the build process, so we have a
static list of locales put into locale/index.xml.
This includes a minor breaking change to Keyman Engine API on Windows:
`MessageFromID(id, locale)` now only allows the three ids
SKUILanguageName, SKUILanguageNameWithEnglish, and SKLanguageCode, for
performance reasons. At this point, only SKUILanguageNameWithEnglish is
actually used anywhere in Keyman, and it is unlikely that any other
consumers are requesting alternate IDs.
Fixes: #14787
Build-bot: skip release:windows
Change Keyman shortcuts to standard Windows shortcuts, rather than
advertised shortcuts, to work around a problem with advertised shortcuts,
elevated custom actions, and non-admin users, as described in #14791.
The problem is related to advertised shortcuts in Windows Installer. When
you have an advertised shortcut, the first use of the shortcut triggers a
repair to prepare the app for use in the new user's context. And now, with
Aug 2025 Windows security patch KB5063878, tweaked in Sep 2025, this
triggers an elevation dialog, which the non-admin user cannot work around.
This means that the shortcuts will be regular Windows shortcut files rather
than advertised shortcuts, and are added to
`%ProgramData%\Microsoft\Windows\Start Menu\Programs\Keyman for Windows`
(so, available for all users on that machine, but will not follow a user
across machines).
* DISABLEADVTSHORTCUTS: https://learn.microsoft.com/en-us/windows/win32/msi/disableadvtshortcuts
* Shortcut advertisement: https://learn.microsoft.com/en-us/windows/win32/msi/advertisement
Relates-to: #14809Fixes: #14791
Cherry-pick-of: #14814
Build-bot: skip release:windows
When determining whether to move to the update available the
ucrsUpdateReady is now taken into account, not just the wucSuccess
flag. All the cases that check if there is Keyman installer file in
the metadata now check for this, and this was the original intent.
A two new function HasKeymanInstallFileUpdate and
CheckMetaDataForUpdate have been added to aid this check.
or stale. This commit adds a precondition check when entering the
Download state. It checks to see if the cache.json file still exists
then it checks if there are packages or installer files to download.
This will also check the version with ucrsUpdateReady, so if the
installed version is already newer it will not attempt the download.
If the check fails it will removed any cached files and return to
the idle state and check for updates.
Fixes: #13767
Before we only skipped the handlekmshell checks if we
were in installing state and the FMode was related to
upgrading or installing the keyboard packages. However
like as seen in 13984 if an upgraded is started from the
standalone installer the statemachine state could be
in UpdateAvailable instead of the Installing State.
Due to this limitation we will skip handlekmshell when in
these FModes in any state.
Fixes: #13770
If configuration is set to not automatically downloadupdates
and then from the configuration tab the check for update button is
clicked. If an update is found the upgrade statemachine is now in
state UpdateAvailable. If a updated keyman installer file is then
download direclty from keyman.com. Then installed by running the self
installer then on firstrun the statemachine will still be in the
UpdateState. This is should be fine, but it will be good to breadcrumb
incase we start to see some crashes on firstrun with this interaction.
The setup executable could modify the registry state directly but it is
cleaner to have the one master of the registry state value.
Fixes: #13771
The state machine method for Exiting a a state was overiding
the Delphi system Exit. This meant that any intended early returns
inside TState method where actually just calling the State.Exit
method then continuing execution within the method.
Fixes: 13831
Be more precise by matching the file name in the cache.json file
with the downloaded file in the cache folder. This will mean any
older installation versions that were not correctly cleaned up will
not be installed.
fixes#13831
Removed the redundant thread check guard on load modifer. Added guard
to reading the option. Also fixed some formating. and made the load
modifier private.
Fixes: #13440
This refactors the cached of the right modifier key used in hotkeys
option. In the lowlevelhook you couldn't reset the cached value.
It is now part of the hotkeys class which is more logical encapsulation
the logic assocaited with the hotkeys.
The scroll bar was also not working correctly for display content.
Different options where explored but the best was to make the outer
update content block a "display: block" instead of using flex.