Python 获取窗口句柄,模拟鼠标点击

Python 获取窗口句柄,模拟鼠标点击

import win32gui
import win32api
import pyautogui
# from pymouse import PyMouse
hwnd_title = {}

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)})


win32gui.EnumWindows(get_all_hwnd, 0)

# m = PyMouse()

for h, t in hwnd_title.items():
    if t :
        print(h, t)
        if t == '米格尔':
            left, top, right, bottom = win32gui.GetWindowRect(h)
            print(left,top,right,bottom)
            pyautogui.click(right-206,bottom-31)

分享到 :
相关推荐

Leave a Reply

Your email address will not be published. Required fields are marked *