Beispiel #1
0
 def child_window_callback(wid, _):
     if "R Console" in win32gui.GetWindowText(wid):
         win32gui.BringWindowToTop(wid)
Beispiel #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))
Beispiel #4
0
 def winEnumHandler(hwnd, ctx):
     nonlocal handleInfo
     if win32gui.IsWindowVisible(hwnd):
         handleInfo.append((hwnd, win32gui.GetWindowText(hwnd)))
Beispiel #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
Beispiel #6
0
 def enumHandler(self, hwnd, lParam):
     if win32gui.IsWindowVisible(hwnd):
         if 'Tiger64' in win32gui.GetWindowText(hwnd):
             self.hwnd = hwnd
Beispiel #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')
Beispiel #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
Beispiel #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)  # 即使拥有窗口的线程被挂起也会最小化。在从其他线程最小化窗口时才使用这个参数
Beispiel #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)
Beispiel #11
0
 def get_active_window(self):
     """
     :return: the current working window
     """
     return win32gui.GetWindowText(win32gui.GetForegroundWindow())
Beispiel #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)
Beispiel #13
0
def get_window_title(hwnd):
    title = win32gui.GetWindowText(hwnd)
    return title
Beispiel #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})
Beispiel #15
0
def thead_SetHwndLabel(label1, label2):  #线程函数
    while 1:
        hwnd = option.GetWindowHwnd()
        label1.setText(str(hwnd))
        label2.setText(str(win32gui.GetWindowText(hwnd)))
Beispiel #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)
Beispiel #18
0
 def _filter(hwnd, regex):
     s = win32gui.GetWindowText(hwnd)
     if regex.match(s):
         pid = win32process.GetWindowThreadProcessId(hwnd)
         pids.append(pid)
 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
Beispiel #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
Beispiel #21
0
 def callback(hWnd, windows):
     if not self.__isRealWindow(hWnd):
         return
     rect = win32gui.GetWindowRect(hWnd)
     windows.update({win32gui.GetWindowText(hWnd): [hWnd, rect]})
Beispiel #22
0
 def call_back(handle, hwnd_list):
     txt = win32gui.GetWindowText(handle)
     if txt and txt == "资金余额":
         hwnd_list.append(win32gui.GetParent(handle))
         return
Beispiel #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)})
Beispiel #24
0
 def enum_callback(hwnd, results):
     winlist.append((hwnd, win32gui.GetWindowText(hwnd)))
Beispiel #25
0
 def winEnumHandler(hwnd, ctx):
     if win32gui.IsWindowVisible(hwnd):
         print(hex(hwnd), win32gui.GetWindowText(hwnd))
Beispiel #26
0
def GetActiveWindowText():
    hwnd = win32gui.GetForegroundWindow()
    text = win32gui.GetWindowText(hwnd)
    return text
Beispiel #27
0
def window_enumeration_handler(hwnd, top_windows):
    top_windows.append((hwnd, win32gui.GetWindowText(hwnd)))
Beispiel #28
0
def GetWindowText(hwnd, optional=None):
    text = win32gui.GetWindowText(hwnd)
    print(text)
    return 1
Beispiel #29
0
def enumHandler(hwnd, lParam):
    global handle

    if "RetroArch" in win32gui.GetWindowText(hwnd):
        handle = hwnd
Beispiel #30
0
def get_window_name():
    return win32gui.GetWindowText(win32gui.GetForegroundWindow())