当前位置: 首页>>代码示例>>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;未经允许,请勿转载。