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

分享到 :

Leave a Reply

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