@aabuhijleh/forcefocus 中文文档教程

发布于 5年前 浏览 27 项目主页 更新于 3年前

forcefocus

允许您从 Windows 中的其他窗口窃取焦点的节点模块。

npmNpmVersionNpmLicenseAppVeyor 分支Travis (.org) branch

Microsoft 更改了 SetFocus() 仅允许应用程序将焦点授予其他窗口(如果它当前持有焦点)。 如果没有焦点的应用程序试图获取它,任务栏将只是闪烁而不是聚焦窗口。 这些改动很可能是为了提升用户体验,让用户不会因为重点应用的突然切换而受到干扰。

该模块绕过了 SetFocus() 中的限制并允许任何窗口窃取焦点。

它在其他平台上重用了 Electron 内置的焦点。

Installation

通过运行安装 forcefocus

$ npm install --save forcefocus

win、mac 和 linux 的本机二进制文件是在安装模块时预先构建和下载的。

Documentation

forcefocus.focusWindow(window)

种类forcefocus
的静态方法 总结:强制关注窗口
访问: public

ParamTypeDescription
windowBrowserWindowWindow to focus

Example

const forceFocus = require('forcefocus');
const currentWindow = require('electron').remote.getCurrentWindow();

forceFocus.focusWindow(currentWindow);

Example application

Example application gif

示例应用程序位于 /example/ 目录,通过运行启动它:

$ npm run example

Contribute

随时为这个模块做贡献。

在提交 PR 之前,请确保 linter 运行时没有任何警告:

$ npm run lint

License

该项目已获得 Apache 2.0 许可。

forcefocus

Node module that allows you to steal focus from other windows in Windows.

npmNpmVersionNpmLicenseAppVeyor branchTravis (.org) branch

Microsoft changed the implementation of SetFocus() to only allow an app to grant focus to other windows if it currenly holds the focus. If an app that does not have the focus tries to take it, the taskbar will just flash rather than focusing the window. These changes was probably done to improve the user experience, so users would not be disturbed by the focused application suddenly switching.

This module circumvents the restrictions in SetFocus() and allows any window to steal the focus.

It reuses the Electron built-in focus on other platforms.

Installation

Install forcefocus by running:

$ npm install --save forcefocus

Native binaries for win, mac and linux are prebuilt and downloaded when the module is installed.

Documentation

forcefocus.focusWindow(window)

Kind: static method of forcefocus
Summary: Force focus on a Window
Access: public

ParamTypeDescription
windowBrowserWindowWindow to focus

Example

const forceFocus = require('forcefocus');
const currentWindow = require('electron').remote.getCurrentWindow();

forceFocus.focusWindow(currentWindow);

Example application

Example application gif

An example application is located in the /example/ dir, start it by running:

$ npm run example

Contribute

Feel free to contribute to this module.

Before submitting a PR, please make sure that the linter runs without any warning:

$ npm run lint

License

The project is licensed under the Apache 2.0 license.

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文