-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathwatchmouse.js
36 lines (33 loc) · 926 Bytes
/
watchmouse.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/*
* scripts/watchmouse.js: part of the "win32-displayconfig" Node package.
* See the COPYRIGHT file at the top-level directory of this distribution.
*/
"use strict";
const robotjs = require("robotjs");
const { VerticalRefreshRateContext } = require("../index");
const ctx = new VerticalRefreshRateContext();
let didShutdown = false;
let outstanding = 0;
setTimeout(() => {
ctx.close();
didShutdown = true;
console.log(`Shutting down with ${outstanding} outstanding`);
}, 60 * 1000);
const pollInterval = setInterval(async () => {
outstanding++;
if (didShutdown) {
clearInterval(pollInterval);
outstanding--;
return;
}
const pos = robotjs.getMousePos();
const refreshRate = await ctx.findVerticalRefreshRateForDisplayPoint(
pos.x,
pos.y
);
console.log(
`Refresh rate for position ${pos.x}, ${
pos.y
}: ${refreshRate} with ${outstanding--} outstanding`
);
}, 250);