pu369com

python安装pyautogui时遇到Pillow问题

执行   pip install pyautogui

提示:

Could not find a version that satisfies the requirement Pillow>=6.2.1 (from pyscreeze>=0.1.21->pyautogui) (from versions: none)

补充:先试试 pip install pillow

如不行,看下面

参考:https://www.jianshu.com/p/3de67550cea6     ,首先从

https://www.lfd.uci.edu/~gohlke/pythonlibs/#pillow  下载了 Pillow‑7.1.1‑cp38‑cp38‑win_amd64.whl (我安装的python3.8  win10是64位)

执行:   

pip install e:\downloads\Pillow-7.1.1-cp38-cp38-win_amd64.whl

然后:

pip install pyautogui

成功。

为了输入中文,参考https://www.cnblogs.com/zwc--blog/p/11079986.html

还需要pyperclip 

然后,参考https://www.cnblogs.com/ffrs/p/11358308.html和https://blog.csdn.net/wenq_yang/article/details/82910427 做个测试 

另外,还有pywinauto  参考:https://www.cnblogs.com/baihuitestsoftware/articles/9317368.html

顺便写个小例子:打开计算器,然后运行脚本找计算器窗口,输入1+2=

import pyautogui,time

pyautogui.hotkey('win', 'r')
time.sleep(1)
pyautogui.press('shift')#因为默认中文输入,所以切换输入法为英文状态
pyautogui.typewrite('calc.exe')
pyautogui.press('enter')
time.sleep(3)
pyautogui.press('1')
pyautogui.press('+')
pyautogui.press('2')
pyautogui.press('=')

 补充,考虑输入法的状态控制。后来添加了英文键盘,并设置热键以切换英文输入状态,参考https://jingyan.baidu.com/album/63acb44a7cfea461fdc17e5f.html?picindex=3

识别图片并点击  参考:https://www.cnblogs.com/yunlong-study/p/14447093.html

#!/usr/bin/env python
# -*- coding: utf-8 -*-

import pyautogui
import time


def zan():
    time.sleep(0.5)    # 等待 0.5 秒
    left, top, width, height = pyautogui.locateOnScreen('zan.png')   # 寻找 点赞图片;
    center = pyautogui.center((left, top, width, height))    # 寻找 图片的中心
    pyautogui.click(center)    # 点击
    print('点赞成功!')


while True:
    if pyautogui.locateOnScreen('zan.png'):
        zan()   # 调用点赞函数
    else:
        pyautogui.scroll(-500)    # 本页没有图片后,滚动鼠标;
        print('没有找到目标,屏幕下滚~')

 

posted on 2020-04-07 17:50  pu369com  阅读(2661)  评论(0编辑  收藏  举报

导航