python截图+识别+操作鼠标键盘

1、windows python截屏
安装组件:
pip install PyQt5 -i https://pypi.douban.com/simple
pip install pywin32 -i https://pypi.douban.com/simple
 
代码:
from PyQt5.QtWidgets import QApplication
from PyQt5.QtGui import *
import win32gui
import sys
 
hwnd = win32gui.FindWindow(None, 'C:\Windows\System32\cmd.exe')
app = QApplication(sys.argv)
screen = QApplication.primaryScreen()
img = screen.grabWindow(hwnd).toImage()
img.save("screenshot.jpg")
 
 
方法二:区域截图
pip install pynput -i https://pypi.douban.com/simple
 
====================================
2、裁剪图片
 
====================================
3、识别图片里的文字
安装组件:
pip install Pillow -i https://pypi.douban.com/simple
pip3 install pytesseract -i https://pypi.douban.com/simple
 
安装tesseract-ocr
https://digi.bib.uni-mannheim.de/tesseract/tesseract-ocr-w32-setup-v5.0.0-alpha.20191010.exe
https://digi.bib.uni-mannheim.de/tesseract/tesseract-ocr-w64-setup-v5.0.0-alpha.20191010.exe
 
 
简体字识别包:https://raw.githubusercontent.com/tesseract-ocr/tessdata/4.00/chi_sim.traineddata
繁体字识别包:https://github.com/tesseract-ocr/tessdata/raw/4.0/chi_tra.traineddata
或者直接我的百度云盘:链接:tesseract 密码:tmdm
 
=====================================
4、操作鼠标键盘
pip install pyautogui -i https://pypi.douban.com/simple
 
5、安装chromedriver 支持
pip install selenium -i https://pypi.douban.com/simple
pip install chromedriver -i https://pypi.douban.com/simple
 
selenium
http://selenium-release.storage.googleapis.com/index.html
Chrome Driver:
http://chromedriver.storage.googleapis.com/index.html

你可能感兴趣的:(python,图像识别)