def list_alttab_windows(cls):
"""
Return the list of the windows handles that are currently guessed to be
eligible to the Alt+Tab panel.
Raises a OSError exception on error.
"""
# LPARAM is defined as LONG_PTR (signed type)
if ctypes.sizeof(ctypes.c_long) == ctypes.sizeof(ctypes.c_void_p):
LPARAM = ctypes.c_long
elif ctypes.sizeof(ctypes.c_longlong) == ctypes.sizeof(ctypes.c_void_p):
LPARAM = ctypes.c_longlong
EnumWindowsProc = ctypes.WINFUNCTYPE(
ctypes.c_bool, ctypes.c_void_p, LPARAM)
def _enum_proc(hwnd, lparam):
try:
if cls.is_alttab_window(hwnd):
handles.append(hwnd)
except OSError:
pass
return True
handles = []
ctypes.windll.user32.EnumWindows(EnumWindowsProc(_enum_proc), 0)
return handles
评论列表
文章目录