[BREAKGLASS] Append-only mirror of github.com/signalapp/windows-dummy-keystroke
Go to file
Scott Nonnenberg 905685eef1 v1.0.0
2023-08-07 16:56:18 -07:00
.gitignore Initial commit 2022-12-11 12:01:15 -08:00
binding.gyp binding.gyp: Only build on windows 2023-07-26 17:27:17 -07:00
functions.cc Remove MyObject and unnecessary comments 2023-08-07 16:02:48 -07:00
functions.h Remove MyObject and unnecessary comments 2023-08-07 16:02:48 -07:00
index.d.ts Initial commit 2022-12-11 12:01:15 -08:00
index.js Initial commit 2022-12-11 12:01:15 -08:00
LICENSE Initial commit 2022-12-11 12:01:15 -08:00
NativeExtension.cc Remove MyObject and unnecessary comments 2023-08-07 16:02:48 -07:00
package-lock.json Initial commit 2022-12-11 12:01:15 -08:00
package.json v1.0.0 2023-08-07 16:56:18 -07:00
README.md Initial commit 2022-12-11 12:01:15 -08:00

Windows Dummy Keystroke

This package exports sendDummyKeystroke(), which will send a generic key down/up event on Windows.

But why?

This is a workaround for an issue with Windows Notifications. Normally you can call the native AllowSetForegroundWindow method to permit another application to take foreground focus. But when an app is started from a Windows notification activation, this call fails with ERROR_ACCESS_DENIED. One of a list of conditions has to be met for the call to succeed.

Sending a key press event satisfies this check and lets AllowSetForegroundWindow succeed.

This is useful for letting a second instance of a program activate the original instance. In Electron, you would call this before calling requestSingleInstanceLock(), as this can call AllowSetForegroundWindow for the initial instance.

This workaround was used by Chromium to solve a foreground focus issue, and is adapted here for use with Node.