第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

過濾后臺進程 PyWin32

過濾后臺進程 PyWin32

楊魅力 2024-01-27 16:07:45
我一直致力于從 EnumWindows 中過濾掉窗口,僅包括最小化或打開到列表的窗口。代碼def winEnumHandler(hwnd, ctx):    title = win32gui.GetWindowText(hwnd)    # Append HWND to list    if win32gui.IsWindowVisible(hwnd) and title != '':        app = ApplicationWindow(hwnd, title)        applications.append(app)def scanApplication():    applications.clear()    win32gui.EnumWindows(winEnumHandler, None)    return applications預期/實際此代碼的問題在于,它無法正確過濾掉通過以下方式找到的一些窗口EnumWindows:例如,目前我在計算機上打開了 Chrome、IDE 和 Discord,并且只期望這些窗口出現(xiàn)在應用程序列表中。但是,我不僅獲得這些窗口,還獲得后臺任務,例如:計算器、郵件、Geforce Overlay 等...這些后臺任務處于活動狀態(tài),但桌面上沒有窗口,也沒有最小化。我怎樣才能過濾掉后臺任務EnumWindows?謝謝閱讀!
查看完整描述

1 回答

?
有只小跳蛙

TA貢獻1824條經(jīng)驗 獲得超8個贊

在做了更多研究后,我遇到了 DWM,DWM 提供了一種可以查找窗口屬性以從中獲取更多信息的方法。其中一個選項稱為斗篷,它可以很好地過濾掉所有窗口中的后臺進程。我的代碼如下。


def winEnumHandler(hwnd, ctx):

? ? # DWM

? ? isCloacked = ctypes.c_int(0)

? ? ctypes.WinDLL("dwmapi").DwmGetWindowAttribute(hwnd, 14, ctypes.byref(isCloacked), ctypes.sizeof(isCloacked))


? ? # Variables

? ? title = win32gui.GetWindowText(hwnd)


? ? # Append HWND to list

? ? if win32gui.IsWindowVisible(hwnd) and title != '' and isCloacked.value == 0:

? ? ? ? app = ApplicationWindow(hwnd, title)

? ? ? ? applications.append(app)

DWM 過濾:此處

從該鏈接獲取更多信息后,最終解決方案顯示了所有真實的窗口:


class TITLEBARINFO(ctypes.Structure):

? ? _fields_ = [("cbSize", ctypes.wintypes.DWORD), ("rcTitleBar", ctypes.wintypes.RECT),

? ? ? ? ? ? ? ? ("rgstate", ctypes.wintypes.DWORD * 6)]



def winEnumHandler(hwnd, ctx):

? ? # Title Info Initialization

? ? title_info = TITLEBARINFO()

? ? title_info.cbSize = ctypes.sizeof(title_info)

? ? ctypes.windll.user32.GetTitleBarInfo(hwnd, ctypes.byref(title_info))


? ? # DWM Cloaked Check

? ? isCloaked = ctypes.c_int(0)

? ? ctypes.WinDLL("dwmapi").DwmGetWindowAttribute(hwnd, 14, ctypes.byref(isCloaked), ctypes.sizeof(isCloaked))


? ? # Variables

? ? title = wg.GetWindowText(hwnd)


? ? # Append HWND to list

? ? if wg.IsWindowVisible(hwnd) and title != '' and isCloaked.value == 0:

? ? ? ? if not (title_info.rgstate[0] & wc.STATE_SYSTEM_INVISIBLE):

? ? ? ? ? ? app = ApplicationWindow(hwnd, title)

? ? ? ? ? ? applications.append(app)

任何簡化請告訴我!謝謝!


查看完整回答
反對 回復 2024-01-27
  • 1 回答
  • 0 關注
  • 194 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網(wǎng)微信公眾號