Exemplo n.º 1
0
 def child_window_callback(wid, _):
     if "R Console" in win32gui.GetWindowText(wid):
         win32gui.BringWindowToTop(wid)
Exemplo n.º 2
0
def song_info():
    try:
        song_info = win32gui.GetWindowText(getwindow())
    except:
        pass
    return song_info
def enum_win(hwnd, windows_list):
    win_text = win32gui.GetWindowText(hwnd)
    windows_list.append((hwnd, win_text))
Exemplo n.º 4
0
 def winEnumHandler(hwnd, ctx):
     nonlocal handleInfo
     if win32gui.IsWindowVisible(hwnd):
         handleInfo.append((hwnd, win32gui.GetWindowText(hwnd)))
Exemplo n.º 5
0
def all_hwnd(hwnd, mouse):
    hwnd_windows = dict()
    if win32gui.IsWindow(hwnd) and win32gui.IsWindowEnabled(hwnd) and win32gui.IsWindowVisible(hwnd):
        hwnd_windows.update({hwnd: win32gui.GetWindowText(hwnd)})
    return hwnd_windows
Exemplo n.º 6
0
 def enumHandler(self, hwnd, lParam):
     if win32gui.IsWindowVisible(hwnd):
         if 'Tiger64' in win32gui.GetWindowText(hwnd):
             self.hwnd = hwnd
Exemplo n.º 7
0
def get_active_window_title(pid=None):
    _pid = win32gui.GetForegroundWindow() if pid is None else pid
    return unicode(win32gui.GetWindowText(_pid), errors='ignore')
Exemplo n.º 8
0
def callback(hwnd, extra):
    text = win32gui.GetWindowText(hwnd).decode('mbcs').encode('utf-8')
    if (extra['find'] in text):
        extra['hwnd'] = hwnd
        extra['text'] = text
Exemplo n.º 9
0
import win32gui

import time

#time.sleep(1.5)  # 等待  # 增加延迟
time.sleep(1)  # 等待  # 增加延迟
类名 = 'TkTopLevel'
窗口标题 = ""

if len(类名) == 0:
    窗口句柄 = win32gui.FindWindow(None, 窗口标题)
else:  #
    窗口句柄 = win32gui.FindWindow(类名, None)
类名 = win32gui.GetClassName(窗口句柄)
窗口标题 = win32gui.GetWindowText(窗口句柄)

win32gui.ShowWindow(窗口句柄, 11)  # 即使拥有窗口的线程被挂起也会最小化。在从其他线程最小化窗口时才使用这个参数
Exemplo n.º 10
0
def hide_console():
    """Hide the pyclewn console window."""
    hwnd = win32console.GetConsoleWindow()
    if hwnd:
        debug('hiding window %d => %s', hwnd, win32gui.GetWindowText(hwnd))
        win32gui.ShowWindow(hwnd, win32con.SW_HIDE)
Exemplo n.º 11
0
 def get_active_window(self):
     """
     :return: the current working window
     """
     return win32gui.GetWindowText(win32gui.GetForegroundWindow())
Exemplo n.º 12
0
 def get_all_hwnd(hwnd, mouse):
     if win32gui.IsWindow(hwnd) and win32gui.IsWindowEnabled(hwnd) and win32gui.IsWindowVisible(hwnd):
         this_title = win32gui.GetWindowText(hwnd)
         if title == this_title:
             hwnds.append(hwnd)
Exemplo n.º 13
0
def get_window_title(hwnd):
    title = win32gui.GetWindowText(hwnd)
    return title
Exemplo n.º 14
0
 def get_all_hwnd(hwnd, mouse):
     if win32gui.IsWindow(hwnd) and win32gui.IsWindowEnabled(hwnd) and win32gui.IsWindowVisible(hwnd):
         title = win32gui.GetWindowText(hwnd)
         if title:
             window.update({hwnd:title})
Exemplo n.º 15
0
def thead_SetHwndLabel(label1, label2):  #线程函数
    while 1:
        hwnd = option.GetWindowHwnd()
        label1.setText(str(hwnd))
        label2.setText(str(win32gui.GetWindowText(hwnd)))
Exemplo n.º 16
0
def _windowEnumerationHandler(hwnd, resultList):
    '''Pass to win32gui.EnumWindows() to generate list of window handle,
    window text, window class tuples.'''
    resultList.append((hwnd,
                       win32gui.GetWindowText(hwnd),
                       win32gui.GetClassName(hwnd)))
 def enum_windows_callback(hwnd, results):
     if win32gui.IsWindowVisible(hwnd):
         window_title = win32gui.GetWindowText(hwnd)
         if window_title not in WindowsScreenshot.blacklisted_windows:
             windows_list.append(window_title)
Exemplo n.º 18
0
 def _filter(hwnd, regex):
     s = win32gui.GetWindowText(hwnd)
     if regex.match(s):
         pid = win32process.GetWindowThreadProcessId(hwnd)
         pids.append(pid)
Exemplo n.º 19
0
 def _window_enum_callback(self, hwnd, wildcard):
     """Pass to win32gui.EnumWindows() to check all the opened windows"""
     if re.match(wildcard, str(win32gui.GetWindowText(hwnd))) is not None:
         self._handle = hwnd
Exemplo n.º 20
0
    def __get_order_msg(self):
        # 判断窗口是不是提示窗口,是,就返回true
        def win_is_msg(hand):
            text = ""
            sons = []
            win32gui.EnumChildWindows(
                hand, lambda handle, param: param.append(handle), sons)
            for son in sons:
                if win32gui.GetClassName(son) in ["Static", "Button"]:
                    t = get_item_text(son)
                    if t:
                        text = text + t
            return '检测到您正在拷贝数据' in text and "提示" in text and '确定' in text

        #
        # 1. 可以根据 验证码弹窗的 OWNER 句柄 = 父句柄 判断
        # 2. 可以根据 弹出窗口大小判断更快,所以按大小判断
        def call_back(handle, dialog_l):
            _left, _top, _right, _bottom = win32gui.GetWindowRect(handle)
            # (_right - _left == 300) and (_bottom - _top == 195)
            # print(win32gui.GetParent(handle))
            if win32gui.GetClassName(handle) == "#32770" and \
                    win32gui.GetWindow(handle, win32con.GW_OWNER) == self.__parent_trade:
                # if (_right - _left == 362) or (_right - _left == 341):
                #     print(handle)
                #     dialog_l.append(handle)
                if win_is_msg(handle):
                    dialog_l.append(handle)

        # todo
        """ 下单 时不论成功失败,肯定在最后有一个 提示 弹框 """
        while True:
            dialog_list = []
            win32gui.EnumWindows(call_back, dialog_list)
            # 获得 每个 dialog 句柄的子句柄,判断出是 提示 弹出窗

            if len(dialog_list) > 1:
                exit(-1)
            # 如果没有提示信息窗口,而存在委托窗口,判断无误下单后 退出
            if len(dialog_list) == 0:
                time.sleep(0.01)
                continue

            if len(dialog_list) == 1:
                prompt = dialog_list[0]
                prompt_info = {}
                prompt_sons = []
                _left, _top, _right, _bottom = win32gui.GetWindowRect(prompt)
                input_pos = [
                    _left + (_right - _left) * 0.3991,
                    _top + (_bottom - _top) * 0.5504
                ]
                image_pos = [
                    _left + (_right - _left) * 0.6362,
                    _top + (_bottom - _top) * 0.5504
                ]

                win32gui.EnumChildWindows(
                    prompt, lambda handle, param: param.append(handle),
                    prompt_sons)
                for prompt_son in prompt_sons:
                    if win32gui.GetClassName(
                            prompt_son) == 'Static' and pos_in_window_rect(
                                image_pos, win32gui.GetWindowRect(prompt_son)):
                        prompt_info.update(image=prompt_son)
                    elif win32gui.GetClassName(
                            prompt_son) == 'Edit' and pos_in_window_rect(
                                input_pos, win32gui.GetWindowRect(prompt_son)):
                        prompt_info.update(input=prompt_son)
                    txt = win32gui.GetWindowText(prompt_son)
                    if txt == "":
                        txt = get_item_text(prompt_son)
                    elif txt == "确定":
                        prompt_info.update(confirm_btn=prompt_son)

                # 提示  弹出框, 使用ocr识别
                identify_code = ocr_string_from_hwnd(prompt_info["image"],
                                                     expand=10)
                win32gui.SendMessage(prompt_info["input"], win32con.WM_SETTEXT,
                                     None, identify_code)
                win32api.PostMessage(prompt_info["confirm_btn"],
                                     win32con.WM_LBUTTONDOWN, None, None)
                win32api.PostMessage(prompt_info["confirm_btn"],
                                     win32con.WM_LBUTTONUP, None, None)
                return
Exemplo n.º 21
0
 def callback(hWnd, windows):
     if not self.__isRealWindow(hWnd):
         return
     rect = win32gui.GetWindowRect(hWnd)
     windows.update({win32gui.GetWindowText(hWnd): [hWnd, rect]})
Exemplo n.º 22
0
 def call_back(handle, hwnd_list):
     txt = win32gui.GetWindowText(handle)
     if txt and txt == "资金余额":
         hwnd_list.append(win32gui.GetParent(handle))
         return
Exemplo n.º 23
0
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)})
Exemplo n.º 24
0
 def enum_callback(hwnd, results):
     winlist.append((hwnd, win32gui.GetWindowText(hwnd)))
Exemplo n.º 25
0
 def winEnumHandler(hwnd, ctx):
     if win32gui.IsWindowVisible(hwnd):
         print(hex(hwnd), win32gui.GetWindowText(hwnd))
Exemplo n.º 26
0
def GetActiveWindowText():
    hwnd = win32gui.GetForegroundWindow()
    text = win32gui.GetWindowText(hwnd)
    return text
Exemplo n.º 27
0
def window_enumeration_handler(hwnd, top_windows):
    top_windows.append((hwnd, win32gui.GetWindowText(hwnd)))
Exemplo n.º 28
0
def GetWindowText(hwnd, optional=None):
    text = win32gui.GetWindowText(hwnd)
    print(text)
    return 1
Exemplo n.º 29
0
def enumHandler(hwnd, lParam):
    global handle

    if "RetroArch" in win32gui.GetWindowText(hwnd):
        handle = hwnd
Exemplo n.º 30
0
def get_window_name():
    return win32gui.GetWindowText(win32gui.GetForegroundWindow())