Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/41.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/google-chrome/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js 如何使用节点模块从electron应用程序获取空闲时间?_Node.js_Electron - Fatal编程技术网

Node.js 如何使用节点模块从electron应用程序获取空闲时间?

Node.js 如何使用节点模块从electron应用程序获取空闲时间?,node.js,electron,Node.js,Electron,我想使用节点模块在我的electron应用程序上获得空闲时间, 例如,使用此模块: 如何将此模型与main.js electron文件集成以从主窗口读取空闲时间? 请帮助我。如果您想在electron应用程序中使用节点系统空闲时间,请执行以下步骤: 使用以下命令安装节点: npm安装--保存@paulcbetts/系统空闲时间 或者,如果您正在使用,请运行: 纱线添加@paulcbetts/系统空闲时间 用法,在节点JS应用程序中,将其导入为: var systemIdleTime=requir

我想使用节点模块在我的electron应用程序上获得空闲时间, 例如,使用此模块: 如何将此模型与main.js electron文件集成以从主窗口读取空闲时间?
请帮助我。

如果您想在electron应用程序中使用节点系统空闲时间,请执行以下步骤:

  • 使用以下命令安装节点:

    npm安装--保存@paulcbetts/系统空闲时间

    或者,如果您正在使用,请运行:

    纱线添加@paulcbetts/系统空闲时间

  • 用法,在节点JS应用程序中,将其导入为:

    var systemIdleTime=require(“@paulcbetts/system idle time”)

    然后可以使用它调用:
    systemIdleTime.getIdleTime()

    方法
    getIdleTime
    将以毫秒为单位返回系统空闲时间

  • 在Electron中的用法,如果您正在构建Electron应用程序,则需要 使用Electron版本的Node.js重新构建插件。 您可以使用来构建应用程序

    npm安装--保存dev-electron-rebuild

    然后使用以下内容重新构建插件:

    /node\u modules/.bin/electron rebuild


  • 这就是我从中得出的结论


    集成模块是什么意思?你到底需要什么?例如,您是否已经使用npm安装了它?我想在我的electron应用程序中使用nodejs模块来获得鼠标和键盘的空闲时间(读取我应用程序中的时间而不是终端中的时间),例如:mainWindow.once('ready-to-show',function(){//在此处运行节点模块,并在主窗口mainWindow.show();})中读取结果;
    const {powerMonitor} = require('electron'); 
    const idle = powerMonitor.getSystemIdleTime() // it returns in seconds when I am writing this
    console.log('Current System Idle Time - ', idle);