@signalapp/windows-dummy-keystroke
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

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.

Readme

Keywords

none

Package Sidebar

Install

npm i @signalapp/windows-dummy-keystroke

Weekly Downloads

264

Version

1.0.0

License

none

Unpacked Size

4.03 kB

Total Files

9

Last publish

Collaborators

  • scottnonnenberg-signal
  • jim_signal
  • ehrenkret
  • indutny
  • jrose-signal
  • automated-signal