这是我在评论中的意思:
import win32gui
def enumWindowsProc(hwnd, lParam):
print win32gui.GetWindowText(hwnd)
win32gui.EnumWindows(enumWindowsProc, 0)
下面,我粘贴了整个事情……它在我现在的PC上不起作用,因为我搞砸了安全设置(这是一个XP !!!)我得到了一堆Access拒绝(错误)代码:5)错误,但在这里.
code.py:
#!/usr/bin/env python3
import sys
import os
import traceback
import ctypes
from ctypes import wintypes
import win32con
import win32api
import win32gui
import win32process
def enumWindowsProc(hwnd, lParam):
if (lParam is None) or ((lParam is not None) and (win32process.GetWindowThreadProcessId(hwnd)[1] == lParam)):
text = win32gui.GetWindowText(hwnd)
if text:
wStyle = win32api.GetWindowLong(hwnd, win32con.GWL_STYLE)
if wStyle & win32con.WS_VISIBLE:
print("%08X - %s" % (hwnd, t