高级农民
- 积分
- 2458
- 大米
- 颗
- 鳄梨
- 个
- 水井
- 尺
- 蓝莓
- 颗
- 萝卜
- 根
- 小米
- 粒
- 学分
- 个
- 注册时间
- 2016-10-6
- 最后登录
- 1970-1-1
|
四年以前疫情期间给公司mac写了一个很简单的script,专门负责移动鼠标的。我直接把源代码贴在这。好久没用过了,可能有bug,但是大概就是这么个意思吧。
----------keep_active.py-----------.google и
import pyautogui
import time
import os
import psutil. ----
. 1point 3 acres
pid_log_file = os.path.dirname(os.path.realpath(__file__)) + '/keep_active_pid.txt'
if os.path.exists(pid_log_file): . 1point 3acres
with open(pid_log_file, 'r') as f:
line = f.readline()
if line and line != '\n':
curr_pid = int(line)
if psutil.pid_exists(curr_pid):
print('Another keep_active process is running.')
exit(0)
with open(pid_log_file, 'w+') as f:
pid = str(os.getpid())
print('New keep_active process created. PID: {}'.format(pid))
f.write(pid). From 1point 3acres bbs
x0 = -1. Χ
y0 = -1. 1point3acres
while True:
x1, y1 = pyautogui.position() ..
if x0 == x1 and y0 == y1:
pyautogui.moveTo(x1+1, y1+1)
. 1point3acres pyautogui.moveTo(x1, y1)
x0 = x1
y0 = y1
time.sleep(300) ..
--------------EOF------------------
. check 1point3acres for more.
---------launch_keep_active.command--------. From 1point 3acres bbs
#!/bin/bash
FILENAME="keep_active.py"
. 1point3acres.com
DIR=`dirname $0`
echo $DIR
nohup python3 $DIR/$FILENAME &
exit 0. 1point 3acres
---------------EOF-------------- |
|