python批量实现栅格数据相减_Python + PS 实现批量扣图

通过使用 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
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值