不息屏
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]
|
||||
|
||||
# 目标服务器配置
|
||||
# 协议支持: http, https
|
||||
# protocol = https
|
||||
|
||||
@ -4,6 +4,7 @@ import sys
|
||||
import configparser
|
||||
import os
|
||||
|
||||
|
||||
def load_config(config_path='config.ini'):
|
||||
"""加载配置文件"""
|
||||
config = configparser.ConfigParser()
|
||||
@ -43,6 +44,7 @@ def load_config(config_path='config.ini'):
|
||||
|
||||
def handle_request(sock, target_host, target_port):
|
||||
"""处理从A设备收到的请求,转发到目标网站"""
|
||||
|
||||
try:
|
||||
# 接收来自A设备的请求
|
||||
request = b""
|
||||
@ -102,9 +104,11 @@ def connect_to_a_device(a_host, a_port, target_host, target_port):
|
||||
time.sleep(3)
|
||||
|
||||
def main():
|
||||
|
||||
# 加载配置
|
||||
config = load_config()
|
||||
|
||||
|
||||
# 解析命令行参数
|
||||
if len(sys.argv) < 3:
|
||||
print("用法: python proxy_client.py <A设备IP> <A设备端口>")
|
||||
|
||||
Loading…
Reference in New Issue
Block a user