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


Python win32gui.EnumWindows方法代碼示例

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


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

示例1: get_all_windows

# 需要導入模塊: import win32gui [as 別名]
# 或者: from win32gui import EnumWindows [as 別名]
def get_all_windows(cls):
        def function(handle, argument):
            argument.append(Window(handle))
        argument = []
        win32gui.EnumWindows(function, argument)
        return argument

#    @classmethod
#    def get_window_by_executable(cls, executable):
#        def function(handle, argument):
#            title = windll.user32.GetWindowText(handle)
#            print "title: %r" % title
#        windll.user32.EnumWindows(function, argument)


    #=======================================================================
    # Methods for initialization and introspection. 
開發者ID:t4ngo,項目名稱:dragonfly,代碼行數:19,代碼來源:window.py

示例2: enumCallback

# 需要導入模塊: import win32gui [as 別名]
# 或者: from win32gui import EnumWindows [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

示例3: init

# 需要導入模塊: import win32gui [as 別名]
# 或者: from win32gui import EnumWindows [as 別名]
def init(debug :bool =False) -> Dict[int, Tuple[int, int, int, int]]:
        """Finds the game window and returns its coords."""
        if platform.release() == "10":
            ctypes.windll.shcore.SetProcessDpiAwareness(2)
        else:
            ctypes.windll.user32.SetProcessDPIAware()

        def window_enumeration_handler(hwnd, top_windows):
            """Add window title and ID to array."""
            top_windows.append((hwnd, win32gui.GetWindowText(hwnd)))

        if debug:
            window_name = "debugg"
        else:
            window_name = "play ngu idle"

        top_windows = []
        windows = []
        candidates = {}
        win32gui.EnumWindows(window_enumeration_handler, top_windows)
        windows = [window[0] for window in top_windows if window_name in window[1].lower()]
        for window in windows:
            candidates[window] = Window.winRect(window)
        return candidates 
開發者ID:kujan,項目名稱:NGU-scripts,代碼行數:26,代碼來源:window.py

示例4: raise_mpv

# 需要導入模塊: import win32gui [as 別名]
# 或者: from win32gui import EnumWindows [as 別名]
def raise_mpv():
    # This workaround is madness. Apparently SetForegroundWindow
    # won't work randomly, so I have to call ShowWindow twice.
    # Once to hide the window, and again to successfully raise the window.
    try:
        top_windows = []
        fg_win = win32gui.GetForegroundWindow()
        win32gui.EnumWindows(windowEnumerationHandler, top_windows)
        for i in top_windows:
            if " - mpv" in i[1].lower():
                if i[0] != fg_win:
                    win32gui.ShowWindow(i[0], 6) # Minimize
                    win32gui.ShowWindow(i[0], 9) # Un-minimize
                break

    except Exception:
        print("Could not raise MPV.")
        traceback.print_exc() 
開發者ID:iwalton3,項目名稱:plex-mpv-shim,代碼行數:20,代碼來源:win_utils.py

示例5: enumChildCallback

# 需要導入模塊: import win32gui [as 別名]
# 或者: from win32gui import EnumWindows [as 別名]
def enumChildCallback(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:
                    return

                # Send WM_CLOSE message
                win32gui.PostMessage(hwnd, win32con.WM_CLOSE, 0, 0)

            except:
                pass
            #print sys.exc_info() 
開發者ID:MozillaSecurity,項目名稱:peach,代碼行數:26,代碼來源:file.py

示例6: enumCallback

# 需要導入模塊: import win32gui [as 別名]
# 或者: from win32gui import EnumWindows [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

示例7: enumChildCallback

# 需要導入模塊: import win32gui [as 別名]
# 或者: from win32gui import EnumWindows [as 別名]
def enumChildCallback(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:
                    return

                # Send WM_CLOSE message
                win32gui.PostMessage(hwnd, win32con.WM_CLOSE, 0, 0)

            except:
                pass
            #print sys.exc_info() 
開發者ID:MozillaSecurity,項目名稱:peach,代碼行數:23,代碼來源:process.py

示例8: closeApp

# 需要導入模塊: import win32gui [as 別名]
# 或者: from win32gui import EnumWindows [as 別名]
def closeApp(self, hProcess, title):
            """
            Close Application by window title
            """

            try:
                win32gui.EnumWindows(FileWriterLauncherGui.enumCallback, title)

                if proc is not None:
                    win32event.WaitForSingleObject(hProcess, 5 * 1000)
                    win32api.CloseHandle(hProcess)

                    for pid in self.genChildProcesses(proc):
                        try:
                            handle = win32api.OpenProcess(1, False, pid)
                            win32process.TerminateProcess(handle, -1)
                            win32api.CloseHandle(handle)
                        except:
                            pass

            except:
                pass 
開發者ID:MozillaSecurity,項目名稱:peach,代碼行數:24,代碼來源:process.py

示例9: TestEnumWindows

# 需要導入模塊: import win32gui [as 別名]
# 或者: from win32gui import EnumWindows [as 別名]
def TestEnumWindows():
    windows = []
    classes = {}
    win32gui.EnumWindows(_MyCallback, (windows, classes))
    print "Enumerated a total of %d windows with %d classes" % (len(windows),len(classes))
    if "tooltips_class32" not in classes:
        print "Hrmmmm - I'm very surprised to not find a 'tooltips_class32' class." 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:9,代碼來源:win32gui_demo.py

示例10: kill

# 需要導入模塊: import win32gui [as 別名]
# 或者: from win32gui import EnumWindows [as 別名]
def kill(self, gracePeriod=5000):
        """
        Kill process. Try for an orderly shutdown via WM_CLOSE.  If
        still running after gracePeriod (5 sec. default), terminate.
        """
        win32gui.EnumWindows(self.__close__, 0)
        if self.wait(gracePeriod) != win32event.WAIT_OBJECT_0:
            win32process.TerminateProcess(self.hProcess, 0)
            win32api.Sleep(100) # wait for resources to be released 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:11,代碼來源:winprocess.py

示例11: __close__

# 需要導入模塊: import win32gui [as 別名]
# 或者: from win32gui import EnumWindows [as 別名]
def __close__(self, hwnd, dummy):
        """
        EnumWindows callback - sends WM_CLOSE to any window
        owned by this process.
        """
        TId, PId = win32process.GetWindowThreadProcessId(hwnd)
        if PId == self.PId:
            win32gui.PostMessage(hwnd, win32con.WM_CLOSE, 0, 0) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:10,代碼來源:winprocess.py

示例12: get_all_windows

# 需要導入模塊: import win32gui [as 別名]
# 或者: from win32gui import EnumWindows [as 別名]
def get_all_windows(cls):
        def function(handle, argument):
            argument.append(cls.get_window(handle))
        argument = []
        win32gui.EnumWindows(function, argument)
        return argument 
開發者ID:dictation-toolbox,項目名稱:dragonfly,代碼行數:8,代碼來源:win32_window.py

示例13: get_hwnds_for_pid

# 需要導入模塊: import win32gui [as 別名]
# 或者: from win32gui import EnumWindows [as 別名]
def get_hwnds_for_pid(pid):
    def callback(hwnd, hwnds):
        # if win32gui.IsWindowVisible(hwnd) and win32gui.IsWindowEnabled(hwnd):
        _, found_pid = win32process.GetWindowThreadProcessId(hwnd)
        # print hwnd
        if found_pid == pid:
            hwnds.append(hwnd)
        return True
    hwnds = []
    win32gui.EnumWindows(callback, hwnds)
    return hwnds 
開發者ID:turingsec,項目名稱:marsnake,代碼行數:13,代碼來源:winpty.py

示例14: _windowEnumerationHandler

# 需要導入模塊: import win32gui [as 別名]
# 或者: from win32gui import EnumWindows [as 別名]
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))) 
開發者ID:ynzheng,項目名稱:pyautotrade_tdx,代碼行數:8,代碼來源:winguiauto.py

示例15: activegamewindow

# 需要導入模塊: import win32gui [as 別名]
# 或者: from win32gui import EnumWindows [as 別名]
def activegamewindow():

	gamepid = findgame()
	if gamepid is not None:
		win32gui.EnumWindows(enum_window_callback, gamepid) 
開發者ID:xulusjb,項目名稱:PUBG,代碼行數:7,代碼來源:main.py


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