Files
geely-kaipiao/keep-awake.js
T
2026-07-13 20:25:24 +08:00

37 lines
946 B
JavaScript

const { execSync } = require('child_process');
const path = require('path');
const SCRIPT = path.join(__dirname, 'send-move.ps1');
const PS = `powershell -NoProfile -ExecutionPolicy Bypass -File "${SCRIPT}"`;
function moveMouse(dx) {
execSync(`${PS} ${dx}`, { windowsHide: true });
}
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
async function main() {
console.log('已启动防息屏,每 15 秒触发真实鼠标事件(SendInput)。Ctrl+C 停止。\n');
process.on('SIGINT', () => {
console.log('\n已停止。');
process.exit(0);
});
let tick = 0;
while (true) {
tick++;
moveMouse(1);
console.log(`【${tick}】→ 右移 1 像素 (SendInput)`);
await sleep(14000);
moveMouse(-1);
console.log(`【${tick}】← 移回原位 (SendInput)`);
await sleep(1000);
}
}
main().catch((err) => {
console.error('出错:', err.message);
process.exit(1);
});