python 梦幻西游_tensorflow实践:梦幻西游人物弹窗识别(二)

由上一篇的思路我们可以定义以下的具体实现步骤本篇将围绕窗口捕获、屏幕截图、截图切分讲述screen.py代码环境描述C:\Users\SF>verMicrosoft Windows [版本 10.0.18363.720]C:\Users\SF>python --versionPython 3.7.6启动方式 多标签版分辨率 800x600界面风格 暖风窗口截图主要是使用...
摘要由CSDN通过智能技术生成

由上一篇的思路我们可以定义以下的具体实现步骤

7fbac0530d0ce8a78beb74aa7a0b1242.png

本篇将围绕窗口捕获、屏幕截图、截图切分讲述screen.py代码

环境描述C:\Users\SF>ver

Microsoft Windows [版本 10.0.18363.720]

C:\Users\SF>python --version

Python 3.7.6

启动方式 多标签版

分辨率 800x600

界面风格 暖风

a3bfa25f1ecd93f38374807650e5633c.png

edc14b027293a30d6e015f1054879268.png

窗口截图

主要是使用了PyQt5进行截图

hwnd_title = dict()

def get_all_hwnd(hwnd,mouse):

if win32gui.IsWindow(hwnd) and win32gui.IsWindowEnabled(hwnd) and win32gui.IsWindowVisible(hwnd):

hwnd_title.update({hwnd:win32gui.GetWindowText(hwnd)})

def shot():

win32gui.EnumWindows(get_all_hwnd, 0)

mhxy_title = ''

for h,t in hwnd_title.items():

if t.startswith('梦幻西游 ONLINE'):

mhxy_title = t

print(mhxy_title)

hwnd = win32gui.FindWindow(None, mhxy_title)

app = QApplication(sys.argv)

desktop_id = app.desktop().winId()

screen= QApplication.primaryScreen()

img_desk = screen.grabWindow(desktop_id).toImage()

img_sc = screen.grabWindow(hwnd).toImage()

img_desk.save(img_desktop_path)

img_sc.save(img_sc_path)

print(f'img_desktop save to -> {os.path.abspath(img_desktop_path)}')

print(f'img_mhxy save to -> {os.path.abspath(img_sc_path)}')

if mhxy_title == '':

print('mhxy not start')

return False

return True

于是我们在路径

images

|- desktop.jpg

|- mhxy.jpg

得到一张全屏截图以及一张梦幻的窗口截图

截图切分

得到屏幕截图后,我

  • 10
    点赞
  • 43
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值