Skip to content

Commit

Permalink
fix windows (#2)
Browse files Browse the repository at this point in the history
* fix windows

* print test idle

* return windows idle in seconds

* Version bump 1.1.0
  • Loading branch information
bithavoc authored Nov 17, 2017
1 parent 1f6f884 commit 46e2ee6
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "desktop-idle",
"version": "1.0.0",
"version": "1.1.0",
"main": "index.js",
"license": "MIT",
"description": "Node/Electron module to detect idle desktop user (OSX, Windows and Linux)",
Expand All @@ -27,10 +27,12 @@
"os": [
"windows",
"linux",
"darwin"
"darwin",
"win32"
],
"cpu": [
"x64"
"x64",
"ia32"
],
"engines": {
"node": ">=7.9.0"
Expand Down
12 changes: 6 additions & 6 deletions src/win/idle.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
#include <windows.h>

double desktop_idle_get_time(void) {
LASTINPUTINFO lif;
lif.cbSize = sizeof(lif);
if (!GetLastInputInfo(&lif)) return -1;
uint64_t tickCount = GetTickCount64();
uint32_t IdleTime = (uint32_t)((tickCount - (uint64_t)lif.dwTime));
return static_cast<double>(IdleTime);
LASTINPUTINFO lif;
lif.cbSize = sizeof(lif);
if (!GetLastInputInfo(&lif)) return -1;
uint64_t tickCount = GetTickCount64();
uint32_t IdleTime = (uint32_t)((tickCount - (uint64_t)lif.dwTime));
return static_cast<double>(IdleTime / 1000);
}
1 change: 1 addition & 0 deletions test/main_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ var desktopIdle = require('../');
vows.describe('getIdleTime()').addBatch({
'return value': () => {
var idle = desktopIdle.getIdleTime()
console.log("test idle", idle);
assert.ok(idle > 0, 'should return idle time');
}
}).run();

0 comments on commit 46e2ee6

Please sign in to comment.