通过使用 PS 的 [动作] 与 [批处理] 功能可以解决掉很多日常重复执行的任务,包括批量魔术棒工具的操作。不过,今天我试试用另一种方式来解决这个问题。
通过使用 Python ,先记录鼠标在屏幕中的轨迹与点击事件(使用魔术棒工具在画布中选中白底并删除),再一遍遍重现上述操作,就能够实现批量扣图。
此功能需要两个.py程序,一个是记录,一个是执行。
1、记录鼠标的移动与点击操作,并写入至本地 txt 文件中:
import pyautogui
import time
from pynput import mouse
from pynput.mouse import Button
import threading
MymouseX = []
MymouseY = []
time.sleep(4)
def on_move(x, y):
print('Pointer moved to {o}'.format((x,y)))
def on_click(x, y , button, pressed):
if pressed:
#print('{0} Pressed at {1} at {2}'.format(button_name, x, y))
MymouseX.append(10086)
MymouseY.append(10086)
with open("MouseX.txt", "w") as f:
f.write(str(MymouseX))
with open("MouseY.txt", "w") as f:
f.write(str(MymouseY))
def my