This commit is contained in:
cheney 2026-07-13 20:05:27 +08:00
parent 64f62be356
commit 7081eae1a3

View File

@ -5,8 +5,8 @@ const POWER_SHELL = 'powershell -NoProfile -Command';
function getMousePos() { function getMousePos() {
const cmd = `${POWER_SHELL} "Add-Type -AssemblyName System.Windows.Forms; [System.Windows.Forms.Cursor]::Position"`; const cmd = `${POWER_SHELL} "Add-Type -AssemblyName System.Windows.Forms; [System.Windows.Forms.Cursor]::Position"`;
const output = execSync(cmd, { windowsHide: true }).toString(); const output = execSync(cmd, { windowsHide: true }).toString();
const match = output.match(/X=(\d+).*Y=(\d+)/); const match = output.match(/(\d+)\s+(\d+)\s*$/m);
if (!match) throw new Error('Failed to get mouse position'); if (!match) throw new Error('Failed to get mouse position: ' + output);
return { x: parseInt(match[1], 10), y: parseInt(match[2], 10) }; return { x: parseInt(match[1], 10), y: parseInt(match[2], 10) };
} }
@ -19,7 +19,6 @@ const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
async function main() { async function main() {
console.log('已启动防息屏,每 15 秒移动鼠标 1 像素再移回原位。Ctrl+C 停止。\n'); console.log('已启动防息屏,每 15 秒移动鼠标 1 像素再移回原位。Ctrl+C 停止。\n');
let moving = false;
process.on('SIGINT', () => { process.on('SIGINT', () => {
console.log('\n已停止。'); console.log('\n已停止。');