【Python】QQ大家来找茬辅助

辅助环境准备:
1、下载并安装Python3+。(https://www.python.org/ftp/python/3.8.3/python-3.8.3-amd64.exe)
2、安装pywin32、pillow库。(以下都是用的清华大学的pip源安装)

pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pywin32
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pillow

辅助准备:
1、句柄获取代码:

import win32gui

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 getAllhwnds():
    win32gui.EnumWindows(get_all_hwnd, 0)
    return hwnd_title.items()

将上述代码保存到一个txt文本后,将文本名(包括后缀)修改为:getAllhwnd.py

2、图像对比代码

from PIL import ImageGrab
from PIL import ImageChops 

import win32api
import win32gui
import getAllhwnd as gh

hwnd_title = gh.getAllhwnds()
#print(hwnd_title)
for i,j in hwnd_title:
    if "大家来找茬" in j and "辅助" not in j:
        print(i,j)
        hwnd =i
        break

tua = win32gui.GetWindowRect(hwnd)

t1=[tua[0]+93,tua[1]+312,tua[2]-550,tua[3]-170]
t2=[tua[2]-474,tua[1]+312,tua[2]-93,tua[3]-170]

im1=ImageGrab.grab(t1)
im2=ImageGrab.grab(t2)

diff = ImageChops.difference(im1, im2)

diff.show()

将上述代码保存到一个txt文本后,将文本名(包括后缀)修改为:fuzhu.py,并和getAllhwnd.py放在同一目录下。

辅助使用
1、用Python自带的IDLE编辑器打开fuzhu.py。
2、进入QQ大家来找茬找茬界面后,确认找茬图像无遮挡后,选中fuzhu.py编辑器窗体,按F5运行辅助。
3、辅助将生成一张结果图片,98%的差异都能够体现出来。

以上。

你可能感兴趣的:(我的Python朋友,程序人生)