import win32gui
import pyautogui
hwnd = 窗口句柄
def windows_point(hwnd):
# 获取已知窗口句柄的窗口屏幕的左上点坐标和右下点坐标
post =win32gui.GetWindowRect(hwnd)
x1 = post[0]
y1 = post[1]
x2 = post[2]
y2 = post[3]
return x1,y1,x2,y2
def get_windows_point(hwnd,name):
# 在整个屏幕上找图(中心点),并和窗口屏幕相运算,得到窗口中相对坐标
post = win32gui.GetWindowRect(hwnd)
x1 = post[0]
y1 = post[1]
image = pyautogui.locateCenterOnScreen(f'path/{name}.PNG', confidence=0.9)
x = image[0]-x1
y = image[1]-y1
return x,y
def get_windows_conter_point_and_click(hwnd,click_num):
# 获取已知窗口句柄的窗口屏幕在整个屏幕上中心点的坐标位置,并点击设置次数
post = win32gui.GetWindowRect(hwnd)
x1 = post[0]
y1 = post[1]
x2 = post[2]
y2 = post[3]
x3 = int(x1+(x2-x1)/2)
y3 = int(y1+(y2-y1)/2)
pyautogui.click(x3,y3,click_num)
暂时一些小想法,如有大佬能够优化,请一起在评论区交流交流,谢谢!
3856

被折叠的 条评论
为什么被折叠?



