惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Hugging Face - Blog
Hugging Face - Blog
C
Cybersecurity and Infrastructure Security Agency CISA
G
Google Developers Blog
The Cloudflare Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
The GitHub Blog
The GitHub Blog
TaoSecurity Blog
TaoSecurity Blog
V
Visual Studio Blog
D
DataBreaches.Net
人人都是产品经理
人人都是产品经理
博客园 - Franky
S
Security @ Cisco Blogs
Hacker News - Newest:
Hacker News - Newest: "LLM"
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
C
Cyber Attacks, Cyber Crime and Cyber Security
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
H
Hackread – Cybersecurity News, Data Breaches, AI and More
腾讯CDC
T
Troy Hunt's Blog
B
Blog RSS Feed
A
About on SuperTechFans
IT之家
IT之家
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
J
Java Code Geeks
S
Securelist
T
Threatpost
SecWiki News
SecWiki News
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Y
Y Combinator Blog
Blog — PlanetScale
Blog — PlanetScale
aimingoo的专栏
aimingoo的专栏
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Forbes - Security
Forbes - Security
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
D
Docker
N
News and Events Feed by Topic
Schneier on Security
Schneier on Security
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
月光博客
月光博客
C
CXSECURITY Database RSS Feed - CXSecurity.com
罗磊的独立博客
H
Hacker News: Front Page
N
News and Events Feed by Topic
N
Netflix TechBlog - Medium
AWS News Blog
AWS News Blog
P
Privacy International News Feed
Scott Helme
Scott Helme
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
V
Vulnerabilities – Threatpost
The Register - Security
The Register - Security

博客园 - 数字冰块

VS2005 中文版的翻译 - 数字冰块 - 博客园 Requirements Analysis with 'pseud-Formal' Method 微软亚洲研究院夏令营记 软件学院学习体验之三 关于权限模型 .netcpu?!见过了吗? 着手准备开源桌面 Blog 软件 一定要记住:Page.IsPostBack 不能忘。。。 软件学院学习体验之二 VS.NET 服务器资源管理器、Smartphone 模拟器中的程序调试、虚拟网卡、Smartphone 设备上的程序调试及其他。 软件学院学习体验之一 啥叫“Functional Programming ”??? 一个奇怪的问题 什么是高质量的代码? C#中的析构函数 关于.NET异步调用的初步总结 毕业了。。。 两年以后重读了一篇文章,写了点东西。 微软的宣传图片
关于使用 EnumWindows 枚举应用程序窗口的技巧
数字冰块 · 2006-01-26 · via 博客园 - 数字冰块

最近在写一个 Alt-Tab 替换程序,需要枚举可切换的应用程序窗口。枚举窗口一般使用的是 EnumWindows 函数

BOOL EnumWindows(
       WNDENUMPROC lpEnumFunc,
    LPARAM lParam
);

但是光是使用这个函数并不能得到我们最需要的窗口,它枚举出的窗口有点“多”,包含隐藏的,包含带有子窗体属性的,包含只出现在任务栏通知区域的。。。等等。因而需要有一些过滤条件。我在 Google 上找了很久都没有一个满意的答案,只能自己用 Spy++ 观察一些窗口做了个过滤规则,经过过滤的就是“可显示、可激活、可切换”的窗口。过滤规则请见代码注释。

BOOL CALLBACK EnumWindowsProc(HWND hwnd,LPARAM lParam)
{
    
//窗口是否可视
    if (!IsWindowVisible(hwnd))
        
return TRUE;

    
//窗口是否可激活
    if (!IsWindowEnabled(hwnd))
        
return TRUE;

    
//窗口是否 WS_POPUP 与 WS_CAPTION 共存
        //一些可切换的窗体同时具有 WS_POPUP 与 WS_CAPTION,因而有 WS_POPUP 却无 WS_CAPTION 的应被过滤
    
//据 Spy++ 观察,符合如 OneNote TrayIcon 等程序可通过此方式过滤
    LONG gwl_style = GetWindowLong(hwnd,GWL_STYLE);
    
if ((gwl_style & WS_POPUP) && !(gwl_style & WS_CAPTION))
        
return TRUE;

    
//窗口是否具有父窗口?
    HWND hParent = (HWND)GetWindowLong(hwnd,GWL_HWNDPARENT);
    
//父窗口是否可激活?
    
//据 Spy++ 观察,如“运行”对话框等被应列入列表的程序有一个隐藏的,具有 WS_DISABLED 的父窗口
    if (IsWindowEnabled(hParent))
        
return TRUE;
    
//父窗口是否可视?
    if (IsWindowVisible(hParent))
        
return TRUE;

    
//一个非常奇怪的问题在于,任务栏 Shell_TrayWnd 符合上述过滤条件但是无法被过滤。
        //因而在这里单独列出。
    TCHAR szClassName[MAX_LOADSTRING];
    GetClassName(hwnd,szClassName,MAX_LOADSTRING);
    
if (!wcscmp(szClassName,L"Shell_TrayWnd"))
        
return TRUE;
..........
..........略