不息屏
This commit is contained in:
parent
887b68d259
commit
3d8fd41127
43
keep-awake.js
Normal file
43
keep-awake.js
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
const { execSync } = require('child_process');
|
||||||
|
|
||||||
|
const POWER_SHELL = 'powershell -NoProfile -Command';
|
||||||
|
|
||||||
|
function getMousePos() {
|
||||||
|
const cmd = `${POWER_SHELL} "Add-Type -AssemblyName System.Windows.Forms; [System.Windows.Forms.Cursor]::Position"`;
|
||||||
|
const output = execSync(cmd, { windowsHide: true }).toString();
|
||||||
|
const match = output.match(/X=(\d+).*Y=(\d+)/);
|
||||||
|
if (!match) throw new Error('Failed to get mouse position');
|
||||||
|
return { x: parseInt(match[1], 10), y: parseInt(match[2], 10) };
|
||||||
|
}
|
||||||
|
|
||||||
|
function setMousePos(x, y) {
|
||||||
|
const cmd = `${POWER_SHELL} "Add-Type -AssemblyName System.Windows.Forms; [System.Windows.Forms.Cursor]::Position = New-Object System.Drawing.Point(${x}, ${y})"`;
|
||||||
|
execSync(cmd, { windowsHide: true });
|
||||||
|
}
|
||||||
|
|
||||||
|
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
||||||
|
|
||||||
|
async function main() {
|
||||||
|
console.log('已启动防息屏,每 15 秒移动鼠标 1 像素再移回原位。Ctrl+C 停止。\n');
|
||||||
|
let moving = false;
|
||||||
|
|
||||||
|
process.on('SIGINT', () => {
|
||||||
|
console.log('\n已停止。');
|
||||||
|
process.exit(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
const orig = getMousePos();
|
||||||
|
setMousePos(orig.x + 1, orig.y);
|
||||||
|
console.log(`→ 右移 1 像素 (${orig.x}, ${orig.y}) → (${orig.x + 1}, ${orig.y})`);
|
||||||
|
await sleep(14000);
|
||||||
|
setMousePos(orig.x, orig.y);
|
||||||
|
console.log(`← 移回原位 (${orig.x + 1}, ${orig.y}) → (${orig.x}, ${orig.y})`);
|
||||||
|
await sleep(1000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
main().catch((err) => {
|
||||||
|
console.error('出错:', err.message);
|
||||||
|
process.exit(1);
|
||||||
|
});
|
||||||
@ -1,4 +1,5 @@
|
|||||||
[proxy]
|
[proxy]
|
||||||
|
|
||||||
# 目标服务器配置
|
# 目标服务器配置
|
||||||
# 协议支持: http, https
|
# 协议支持: http, https
|
||||||
# protocol = https
|
# protocol = https
|
||||||
@ -13,4 +14,4 @@ target_port = 443
|
|||||||
# 另一个备用配置
|
# 另一个备用配置
|
||||||
# protocol = http
|
# protocol = http
|
||||||
# target_host = 192.168.1.100
|
# target_host = 192.168.1.100
|
||||||
# target_port = 8080
|
# target_port = 8080
|
||||||
@ -4,6 +4,7 @@ import sys
|
|||||||
import configparser
|
import configparser
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
|
||||||
def load_config(config_path='config.ini'):
|
def load_config(config_path='config.ini'):
|
||||||
"""加载配置文件"""
|
"""加载配置文件"""
|
||||||
config = configparser.ConfigParser()
|
config = configparser.ConfigParser()
|
||||||
@ -43,6 +44,7 @@ def load_config(config_path='config.ini'):
|
|||||||
|
|
||||||
def handle_request(sock, target_host, target_port):
|
def handle_request(sock, target_host, target_port):
|
||||||
"""处理从A设备收到的请求,转发到目标网站"""
|
"""处理从A设备收到的请求,转发到目标网站"""
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# 接收来自A设备的请求
|
# 接收来自A设备的请求
|
||||||
request = b""
|
request = b""
|
||||||
@ -102,8 +104,10 @@ def connect_to_a_device(a_host, a_port, target_host, target_port):
|
|||||||
time.sleep(3)
|
time.sleep(3)
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|
||||||
# 加载配置
|
# 加载配置
|
||||||
config = load_config()
|
config = load_config()
|
||||||
|
|
||||||
|
|
||||||
# 解析命令行参数
|
# 解析命令行参数
|
||||||
if len(sys.argv) < 3:
|
if len(sys.argv) < 3:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user