win32 gui .FindWindow не возвращает правильные значения - PullRequest
1 голос
/ 10 апреля 2020

Поэтому я всегда использовал этот код, чтобы найти положение / размеры окна, и сегодня я попытался найти окно Memu (эмулятор android).

Этот код:

def print_memu_position():
    hwnd = win32gui.FindWindow(None, "MEmu")
    left, top, right, bottom = win32gui.GetWindowRect(hwnd)
    print "topleft_xy = {},{}".format(left, top)
    print "bottomright_xy = {},{}".format(right, bottom)
    print "width = {}".format(right-left)
    print "height = {}".format(bottom-top)

печатает:

topleft_xy = 3635,881
bottomright_xy = 3714,925
width = 79
height = 44

, что не правильно, окно Memu 574x982

Я использую 3 экрана, но это не должно быть проблемой, потому что когда я использую этот код, чтобы найти что-то еще, Высор например, что зеркально отображает экран телефона на вашем компьютере, я получаю правильные результаты.

Вот что было найдено визуально:

enter image description here

Есть идеи как решить проблему? Спасибо

РЕДАКТИРОВАТЬ:

этот код находит MEmu hwnd

def printMemuHwnd():

    def winEnumHandler(hwnd, ctx):
        if win32gui.IsWindowVisible(hwnd):
            if win32gui.GetWindowText(hwnd) == "MEmu":
                print (hex(hwnd), win32gui.GetWindowText(hwnd))
                left, top, right, bottom = win32gui.GetWindowRect(hwnd)
                print "topleft_xy = {},{}".format(left, top)
                print "bottomright_xy = {},{}".format(right, bottom)
                print "width = {}".format(right - left)
                print "height = {}".format(bottom - top)

    win32gui.EnumWindows(winEnumHandler, None)

и с GetForegroundWindow() я получаю правильный размер.

так почему не будет hwnd = win32gui.FindWindow(None, "MEmu") работать?

...