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


Python win32gui.IsWindowVisible方法代碼示例

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


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

示例1: GetHwnds

# 需要導入模塊: import win32gui [as 別名]
# 或者: from win32gui import IsWindowVisible [as 別名]
def GetHwnds(pid = None, processName = None):
    if pid:
        pass
    elif processName:
        pids = GetPids(processName = processName)
        if pids:
            pid = pids[0]
        else:
            return False
    else:
        return False

    def callback(hwnd, hwnds):
        if IsWindowVisible(hwnd):
            _, result = GetWindowThreadProcessId(hwnd)
            if result == pid:
                hwnds.append(hwnd)
        return True

    from win32gui import EnumWindows, IsWindowVisible
    from win32process import GetWindowThreadProcessId
    hwnds = []
    EnumWindows(callback, hwnds)
    return hwnds 
開發者ID:EventGhost,項目名稱:EventGhost,代碼行數:26,代碼來源:Utils.py

示例2: HwndHasChildren

# 需要導入模塊: import win32gui [as 別名]
# 或者: from win32gui import IsWindowVisible [as 別名]
def HwndHasChildren(hWnd, invisible):
    """
    Return True if the window 'hwnd' has children.
    If 'invisible' is False, don't take invisible windows into account.
    """
    data = [False]
    if invisible:
        def EnumFunc(hWndChild, lParam):
            data[0] = True
            return False
    else:
        def EnumFunc(hWndChild, lParam):
            if IsWindowVisible(hWndChild):
                data[0] = True
                return False
            return True
    EnumChildWindows(hWnd, ENUM_CHILD_PROC(EnumFunc), 0)
    return data[0] 
開發者ID:EventGhost,項目名稱:EventGhost,代碼行數:20,代碼來源:Utils.py

示例3: GetWindowState

# 需要導入模塊: import win32gui [as 別名]
# 或者: from win32gui import IsWindowVisible [as 別名]
def GetWindowState(self):
        hWnd = Find_MPC()
        if not hWnd:
            return -1
        else:
            hWnd = hWnd[0]
        if not IsWindowVisible(hWnd):
            return 0
        state = GetWindowPlacement(hWnd)[1]
        border = GetWindowLong(hWnd, GWL_EXSTYLE) & WS_EX_WINDOWEDGE
        if border:
            return state
        rect = GetWindowRect(hWnd)
        mons = EnumDisplayMonitors()
        fullscreen = False
        for mon in mons:
            if rect == mon[2]:
                fullscreen = True
                break
        if fullscreen:
            return 4
        return state
#=============================================================================== 
開發者ID:EventGhost,項目名稱:EventGhost,代碼行數:25,代碼來源:__init__.py

示例4: get_hwnds_for_pid

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

示例5: enum_window_callback

# 需要導入模塊: import win32gui [as 別名]
# 或者: from win32gui import IsWindowVisible [as 別名]
def enum_window_callback(hwnd, pid):
    tid, current_pid = win32process.GetWindowThreadProcessId(hwnd)
    if pid == current_pid and win32gui.IsWindowVisible(hwnd):
        win32gui.SetForegroundWindow(hwnd)
        l("window activated") 
開發者ID:xulusjb,項目名稱:PUBG,代碼行數:7,代碼來源:main.py

示例6: set_window_coordinates

# 需要導入模塊: import win32gui [as 別名]
# 或者: from win32gui import IsWindowVisible [as 別名]
def set_window_coordinates(hwnd, window_info):
    if win32gui.IsWindowVisible(hwnd):
        if WINDOW_SUBSTRING in win32gui.GetWindowText(hwnd):
            rect = win32gui.GetWindowRect(hwnd)
            x = rect[0]
            y = rect[1]
            w = rect[2] - x
            h = rect[3] - y
            window_info['x'] = x
            window_info['y'] = y
            window_info['width'] = w
            window_info['height'] = h
            window_info['name'] = win32gui.GetWindowText(hwnd)
            win32gui.SetForegroundWindow(hwnd) 
開發者ID:maaaxim,項目名稱:bot,代碼行數:16,代碼來源:functions.py

示例7: __init__

# 需要導入模塊: import win32gui [as 別名]
# 或者: from win32gui import IsWindowVisible [as 別名]
def __init__(self, window_name=None, exe_file=None, exclude_border=True):
        hwnd = 0

        # first check window_name
        if window_name is not None:
            hwnd = win32gui.FindWindow(None, window_name)
            if hwnd == 0:
                def callback(h, extra):
                    if window_name in win32gui.GetWindowText(h):
                        extra.append(h)
                    return True
                extra = []
                win32gui.EnumWindows(callback, extra)
                if extra: hwnd = extra[0]
            if hwnd == 0:
                raise WindowsAppNotFoundError("Windows Application <%s> not found!" % window_name)

        # check exe_file by checking all processes current running.
        elif exe_file is not None:
            pid = find_process_id(exe_file)
            if pid is not None:
                def callback(h, extra):
                    if win32gui.IsWindowVisible(h) and win32gui.IsWindowEnabled(h):
                        _, p = win32process.GetWindowThreadProcessId(h)
                        if p == pid:
                            extra.append(h)
                        return True
                    return True
                extra = []
                win32gui.EnumWindows(callback, extra)
                #TODO: get main window from all windows.
                if extra: hwnd = extra[0]
            if hwnd == 0:
                raise WindowsAppNotFoundError("Windows Application <%s> is not running!" % exe_file)

        # if window_name & exe_file both are None, use the screen.
        if hwnd == 0:
            hwnd = win32gui.GetDesktopWindow()

        self.hwnd = hwnd
        self.exclude_border = exclude_border 
開發者ID:NetEaseGame,項目名稱:ATX,代碼行數:43,代碼來源:windows.py

示例8: _enumWindows

# 需要導入模塊: import win32gui [as 別名]
# 或者: from win32gui import IsWindowVisible [as 別名]
def _enumWindows(self, hwnd, _):
        """遍曆回調函數"""
        if hwnd == self.myhwnd:
            return  # 防止自己嵌入自己
        if win32gui.IsWindow(hwnd) and win32gui.IsWindowVisible(hwnd) and win32gui.IsWindowEnabled(hwnd):
            phwnd = win32gui.GetParent(hwnd)
            title = win32gui.GetWindowText(hwnd)
            name = win32gui.GetClassName(hwnd)
            self.windowList.addItem(
                '{0}|{1}|\t標題:{2}\t|\t類名:{3}'.format(hwnd, phwnd, title, name)) 
開發者ID:PyQt5,項目名稱:PyQt,代碼行數:12,代碼來源:EmbedWindow.py

示例9: get_all_hwnd

# 需要導入模塊: import win32gui [as 別名]
# 或者: from win32gui import IsWindowVisible [as 別名]
def get_all_hwnd(hwnd, mouse):
    '''
    獲取所有陰陽師窗口
    '''
    if win32gui.IsWindow(hwnd) and win32gui.IsWindowEnabled(hwnd) and win32gui.IsWindowVisible(hwnd):
        if win32gui.GetWindowText(hwnd) == u'陰陽師-網易遊戲':
            hwndlist.append(hwnd) 
開發者ID:AcademicDog,項目名稱:onmyoji_bot,代碼行數:9,代碼來源:explore_dual.py

示例10: get_visibility

# 需要導入模塊: import win32gui [as 別名]
# 或者: from win32gui import IsWindowVisible [as 別名]
def get_visibility( self ):
        return win32gui.IsWindowVisible( self.window_handle ) 
開發者ID:mailpile,項目名稱:gui-o-matic,代碼行數:4,代碼來源:winapi.py

示例11: _getHandleThroughFilename

# 需要導入模塊: import win32gui [as 別名]
# 或者: from win32gui import IsWindowVisible [as 別名]
def _getHandleThroughFilename(self):
        Psapi = ctypes.WinDLL('Psapi.dll')
        EnumProcesses = Psapi.EnumProcesses
        EnumProcesses.restype = ctypes.wintypes.BOOL
        GetProcessImageFileName = Psapi.GetProcessImageFileNameA
        GetProcessImageFileName.restype = ctypes.wintypes.DWORD

        Kernel32 = ctypes.WinDLL('kernel32.dll')
        OpenProcess = Kernel32.OpenProcess
        OpenProcess.restype = ctypes.wintypes.HANDLE
        TerminateProcess = Kernel32.TerminateProcess
        TerminateProcess.restype = ctypes.wintypes.BOOL
        CloseHandle = Kernel32.CloseHandle
        

        MAX_PATH = 260
        PROCESS_TERMINATE = 0x0001
        PROCESS_QUERY_INFORMATION = 0x0400

        count = 32
        while True:
            ProcessIds = (ctypes.wintypes.DWORD*count)()
            cb = ctypes.sizeof(ProcessIds)
            BytesReturned = ctypes.wintypes.DWORD()
            if EnumProcesses(ctypes.byref(ProcessIds), cb, ctypes.byref(BytesReturned)):
                if BytesReturned.value<cb:
                    break
                else:
                    count *= 2
            else:
                raise Exception('Call to EnumProcesses failed')

        for index in range(BytesReturned.value / ctypes.sizeof(ctypes.wintypes.DWORD)):
            ProcessId = ProcessIds[index]
            hProcess = OpenProcess(PROCESS_TERMINATE | PROCESS_QUERY_INFORMATION, False, ProcessId)
            if hProcess:
                ImageFileName = (ctypes.c_char*MAX_PATH)()
                if GetProcessImageFileName(hProcess, ImageFileName, MAX_PATH)>0:
                    filename = os.path.basename(ImageFileName.value)
                    if filename == self.filename:
                        break
                #TerminateProcess(hProcess, 1)
                CloseHandle(hProcess)
                
        def get_hwnds_for_pid(pid):
            def callback (hwnd, hwnds):
                if win32gui.IsWindowVisible (hwnd) and win32gui.IsWindowEnabled (hwnd):
                    _, found_pid = win32process.GetWindowThreadProcessId (hwnd)
                    if found_pid == pid:
                        hwnds.append (hwnd)
                    return True
            hwnds = []
            win32gui.EnumWindows(callback, hwnds)
            return hwnds
        return get_hwnds_for_pid(ProcessId) 
開發者ID:NetEase,項目名稱:airtest,代碼行數:57,代碼來源:windows.py


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