當前位置: 首頁>>代碼示例>>Python>>正文


Python win32gui.EnumChildWindows方法代碼示例

本文整理匯總了Python中win32gui.EnumChildWindows方法的典型用法代碼示例。如果您正苦於以下問題:Python win32gui.EnumChildWindows方法的具體用法?Python win32gui.EnumChildWindows怎麽用?Python win32gui.EnumChildWindows使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在win32gui的用法示例。


在下文中一共展示了win32gui.EnumChildWindows方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: attach

# 需要導入模塊: import win32gui [as 別名]
# 或者: from win32gui import EnumChildWindows [as 別名]
def attach(self, device):
        if self.device is not None:
            print "Warning: already attached to a device."
            if device is not self.device:
                self.detach()

        handle = device.hwnd
        def callback(hwnd, extra):
            extra.add(hwnd)
            return True
        self.watched_hwnds.add(handle)
        try:
            # EnumChildWindows may crash for windows have no any child.
            # refs: https://mail.python.org/pipermail/python-win32/2005-March/003042.html
            win32gui.EnumChildWindows(handle, callback, self.watched_hwnds)
        except pywintypes.error:
            pass

        self.device = device
        print "attach to device", device 
開發者ID:NetEaseGame,項目名稱:ATX,代碼行數:22,代碼來源:windows.py

示例2: dumpWindows

# 需要導入模塊: import win32gui [as 別名]
# 或者: from win32gui import EnumChildWindows [as 別名]
def dumpWindows(hwnd):
    '''Dump all controls from a window
    
    Useful during development, allowing to you discover the structure of the
    contents of a window, showing the text and class of all contained controls.

    Parameters
    ----------
    hwnd
        The window handle of the top level window to dump.

    Returns
    -------
        all windows

    Usage example::
        
        replaceDialog = findTopWindow(wantedText='Replace')
        pprint.pprint(dumpWindow(replaceDialog))
    '''
    windows = []
    win32gui.EnumChildWindows(hwnd, _windowEnumerationHandler, windows)
    return windows 
開發者ID:ynzheng,項目名稱:pyautotrade_tdx,代碼行數:25,代碼來源:winguiauto.py

示例3: enumCallback

# 需要導入模塊: import win32gui [as 別名]
# 或者: from win32gui import EnumChildWindows [as 別名]
def enumCallback(hwnd, self):
            title = win32gui.GetWindowText(hwnd)

            for name in self.WindowNames:
                if title.find(name) > -1:
                    try:
                        self.FoundWindowEvent.set()

                        if self.CloseWindows:
                            win32gui.PostMessage(hwnd, win32con.WM_CLOSE, 0, 0)
                    except:
                        pass
                else:
                    try:
                        win32gui.EnumChildWindows(hwnd, _WindowWatcher.enumChildCallback, self)
                    except:
                        pass

            return True 
開發者ID:MozillaSecurity,項目名稱:peach,代碼行數:21,代碼來源:gui.py

示例4: enumCallback

# 需要導入模塊: import win32gui [as 別名]
# 或者: from win32gui import EnumChildWindows [as 別名]
def enumCallback(hwnd, args):
            """
            Will get called by win32gui.EnumWindows, once for each
            top level application window.
            """

            proc = args[0]
            windowName = args[1]

            try:
                # Get window title
                title = win32gui.GetWindowText(hwnd)

                # Is this our guy?
                if title.find(windowName) == -1:
                    win32gui.EnumChildWindows(hwnd, FileWriterLauncherGui.enumChildCallback, args)
                    return

                # Send WM_CLOSE message
                win32gui.PostMessage(hwnd, win32con.WM_CLOSE, 0, 0)
            except:
                pass 
開發者ID:MozillaSecurity,項目名稱:peach,代碼行數:24,代碼來源:file.py

示例5: enumCallback

# 需要導入模塊: import win32gui [as 別名]
# 或者: from win32gui import EnumChildWindows [as 別名]
def enumCallback(hwnd, windowName):
            """
            Will get called by win32gui.EnumWindows, once for each
            top level application window.
            """

            try:
                # Get window title
                title = win32gui.GetWindowText(hwnd)

                # Is this our guy?
                if title.find(windowName) == -1:
                    win32gui.EnumChildWindows(hwnd, FileWriterLauncherGui.enumChildCallback, windowName)
                    return

                # Send WM_CLOSE message
                win32gui.PostMessage(hwnd, win32con.WM_CLOSE, 0, 0)
            except:
                pass 
開發者ID:MozillaSecurity,項目名稱:peach,代碼行數:21,代碼來源:process.py

示例6: findSpecifiedWindows

# 需要導入模塊: import win32gui [as 別名]
# 或者: from win32gui import EnumChildWindows [as 別名]
def findSpecifiedWindows(top_hwnd, numChildWindows=70):
    '''
    查找某一窗口下指定數量的子窗口
    :param top_hwnd: 主窗口句柄
    :param numChildWindows: 子窗口數量
    :return:子窗口列表,包括子窗口hwnd, title, className
    '''
    windows = []
    try:
        win32gui.EnumChildWindows(top_hwnd, _windowEnumerationHandler, windows)
    except win32gui.error:
        # No child windows
        return
    for window in windows:
        childHwnd, windowText, windowClass = window
        windowContent = dumpSpecifiedWindow(childHwnd)
        if len(windowContent) == numChildWindows:
            return windowContent
    # 沒有指定數量的句柄
    return 
開發者ID:wangdkchina,項目名稱:pyautotrade_tdx,代碼行數:22,代碼來源:winguiauto.py

示例7: dumpWindows

# 需要導入模塊: import win32gui [as 別名]
# 或者: from win32gui import EnumChildWindows [as 別名]
def dumpWindows(hwnd):
    """Dump all controls from a window

    Useful during development, allowing to you discover the structure of the
    contents of a window, showing the text and class of all contained controls.

    Parameters
    ----------
    hwnd
        The window handle of the top level window to dump.

    Returns
    -------
        all windows

    Usage example::

        replaceDialog = findTopWindow(wantedText='Replace')
        pprint.pprint(dumpWindow(replaceDialog))
    """
    windows = []
    win32gui.EnumChildWindows(hwnd, _windowEnumerationHandler, windows)
    return windows 
開發者ID:drongh,項目名稱:pyAutoTrading,代碼行數:25,代碼來源:winguiauto.py

示例8: findControls

# 需要導入模塊: import win32gui [as 別名]
# 或者: from win32gui import EnumChildWindows [as 別名]
def findControls(topHwnd,
                 wantedText=None,
                 wantedClass=None,
                 selectionFunction=None):
    
    def searchChildWindows(currentHwnd):
        results = []
        childWindows = []
        try:
            win32gui.EnumChildWindows(currentHwnd,
                                      _windowEnumerationHandler,
                                      childWindows)
        except win32gui.error:
            # This seems to mean that the control *cannot* have child windows,
            # i.e. not a container.
            return
        for childHwnd, windowText, windowClass in childWindows:
            descendentMatchingHwnds = searchChildWindows(childHwnd)
            if descendentMatchingHwnds:
                results += descendentMatchingHwnds

            if wantedText and \
               not _normaliseText(wantedText) in _normaliseText(windowText):
                continue
            if wantedClass and \
               not windowClass == wantedClass:
                continue
            if selectionFunction and \
               not selectionFunction(childHwnd):
                continue
            results.append(childHwnd)
        return results

    return searchChildWindows(topHwnd) 
開發者ID:scholi,項目名稱:pySPM,代碼行數:36,代碼來源:win32_helper.py

示例9: dumpWindow

# 需要導入模塊: import win32gui [as 別名]
# 或者: from win32gui import EnumChildWindows [as 別名]
def dumpWindow(hwnd):
    '''Dump all controls from a window into a nested list
    
    Useful during development, allowing to you discover the structure of the
    contents of a window, showing the text and class of all contained controls.

    Parameters
    ----------
    hwnd
        The window handle of the top level window to dump.

    Returns
    -------
    A nested list of controls. Each entry consists of the
    control's hwnd, its text, its class, and its sub-controls, if any.

    Usage example::
        
        replaceDialog = findTopWindow(wantedText='Replace')
        pprint.pprint(dumpWindow(replaceDialog))
    '''
    windows = []
    try:
        win32gui.EnumChildWindows(hwnd, _windowEnumerationHandler, windows)
    except win32gui.error:
        # No child windows
        return
    windows = [list(window) for window in windows]
    for window in windows:
        childHwnd, windowText, windowClass = window
        window_content = dumpWindow(childHwnd)
        if window_content:
            window.append(window_content)
    return windows 
開發者ID:bluestinger,項目名稱:PyAutoTrading,代碼行數:36,代碼來源:winguiauto.py

示例10: foreach_window

# 需要導入模塊: import win32gui [as 別名]
# 或者: from win32gui import EnumChildWindows [as 別名]
def foreach_window(self):
        def callback(hwnd, lparam):
            title = win32gui.GetWindowText(hwnd).lower()

            for window in self.to_close:
                if window in title:
                    win32gui.PostMessage(hwnd, win32con.WM_CLOSE, 0, 0)
                    print "Closed window ({})".format(title)

            for window in self.clicks:
                if window in title:
                    self._windows[hwnd] = {
                        "matches": self.clicks[window],
                        "to_click": [],
                        "buttons": []
                    }
                    try:
                        win32gui.EnumChildWindows(hwnd, self.foreach_child(), hwnd)
                    except:
                        print "EnumChildWindows failed, moving on."

                    for button_toclick in self._windows[hwnd]['to_click']:
                        for button in self._windows[hwnd]['buttons']:
                            if button_toclick in button['text']:
                                win32gui.SetForegroundWindow(button['handle'])
                                win32gui.SendMessage(button['handle'], win32con.BM_CLICK, 0, 0)
                                print "Clicked on button ({} / {})".format(title, button['text'])

                    del self._windows[hwnd]

            return True

        return callback 
開發者ID:certsocietegenerale,項目名稱:fame_modules,代碼行數:35,代碼來源:cutthecrap.py

示例11: findWindow

# 需要導入模塊: import win32gui [as 別名]
# 或者: from win32gui import EnumChildWindows [as 別名]
def findWindow(name='',C='',parent=0):
    R=[]
    def callbck(hwnd, lParam):
        title,c = getInfo(hwnd)
        if (name=='' or title.startswith(name)) and (C=='' or c==C):
            R.append(hwnd)
        return True
    user32.EnumChildWindows(parent,WNDENUMPROC(callbck),42)        
    return R 
開發者ID:scholi,項目名稱:pySPM,代碼行數:11,代碼來源:win32_helper.py


注:本文中的win32gui.EnumChildWindows方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。