Ejemplo n.º 1
0
def get_target_position_hwnd(target_mouse_position_x, target_mouse_position_y):
    """
    get hwnd value what the target position's program
    :param target_mouse_position_x: target mouse position x
    :param target_mouse_position_y: target mouse position y
    :return:
    """
    data = []

    def callback(hwnd, param):
        (left, top, right, bottom) = GetWindowRect(hwnd)
        if target_mouse_position_x > right or target_mouse_position_x < left:
            return
        if target_mouse_position_y > bottom or target_mouse_position_y < top:
            return
        data.append(hwnd)

    EnumWindows(callback, None)
    for hwnd in data:
        window_text = GetWindowText(hwnd)
        if not window_text or window_text.strip() == '':
            continue
        if not IsWindowVisible(hwnd):
            continue
        return hwnd
Ejemplo n.º 2
0
def try1():
    window_list = get_ordered_window()
    for hwnd in window_list:
        (left, top, right, bottom) = GetWindowRect(hwnd)
        if left <= 0 and top <= 0 and right <= 0 and bottom <= 0:
            continue
        window_text = GetWindowText(hwnd)
        if not window_text or window_text.strip() == '':
            continue
        if target_value_x > right or target_value_x < left:
            continue
        if target_value_y > bottom or target_value_y < top:
            continue
        if not IsWindowVisible(hwnd):
            continue
        print(window_text)
        print(left, top, right, bottom)
        print("-------------------------------------")
Ejemplo n.º 3
0
def get_target_position_window():
    data = []

    def callback(hwnd, param):
        (left, top, right, bottom) = GetWindowRect(hwnd)
        if target_value_x > right or target_value_x < left:
            return
        if target_value_y > bottom or target_value_y < top:
            return
        data.append(hwnd)

    EnumWindows(callback, None)
    target_hwnd = None
    for hwnd in data:
        window_text = GetWindowText(hwnd)
        if not window_text or window_text.strip() == '':
            continue
        if not IsWindowVisible(hwnd):
            continue
        target_hwnd = hwnd
        break
    window_text = GetWindowText(target_hwnd)
    print(window_text)