From e1f1d874ef63b8db27d7f7d4b0ecebd707a4d064 Mon Sep 17 00:00:00 2001 From: Daniel Bulant Date: Thu, 9 Jul 2020 10:21:31 +0200 Subject: [PATCH] Initial commit --- index.ts | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 index.ts diff --git a/index.ts b/index.ts new file mode 100644 index 0000000..f238292 --- /dev/null +++ b/index.ts @@ -0,0 +1,43 @@ +import AutoPilot from 'https://deno.land/x/autopilot/mod.ts'; +import { parse } from "https://deno.land/std/flags/mod.ts"; + +const args = parse(Deno.args, { + alias: { + interval: "i", + start: "s", + stop: "p" + }, + default: { + interval: 300000 + } +}); + +const pilot = new AutoPilot(); + +pilot.notify("Do not sleep", "Do not sleep is now running!"); + +var last = { + x: 0, + y: 0 +}; + +var lastUpdate = Date.now(); +var wasActive = false; + +setInterval(() =>{ + if((new Date).getHours() < args.start || (new Date).getHours() > args.stop) { + if(wasActive) pilot.notify("Do not sleep", "Do not sleep is now paused"); + wasActive = false; + return; + } + wasActive = true; + var pos = pilot.mousePosition(); + if(pos.x !== last.x && pos.y !== last.y) { + lastUpdate = Date.now(); + } else { + if(Date.now() - lastUpdate > args.interval) { // 5minutes + pilot.moveMouse(pos.x + 1, pos.y + 1); + pilot.notify("Do not sleep", "Your mouse was moved just now."); + } + } +}, 10000); \ No newline at end of file