检查是否选中了任务栏按钮 [英] Checking whether taskbar button is selected

查看:55
本文介绍了检查是否选中了任务栏按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于任务栏中具有相应按钮的任何活动窗口,属于活动窗口的此按钮将突出显示为活动窗口。有没有一种程序可以判断任务栏按钮是否突出显示的方法?例如,如果我打开
开始菜单突出显示开始菜单按钮,有没有办法以编程方式检测它。

With any active window that has a corresponding button in the taskbar, this button belonging to the active window is highlighted as the windows active. Is there a way programmatically one can tell if a taskbar button is highlighted? For example if I open the start menu the start menu button is highlighted, is there a way of detecting this programmatically.

我知道我可以查看活动的窗口并得到各种各样的信息,但我正在考虑(可能是开始菜单是任务栏上的按钮1:

I know I can look at the window that is active and get all sorts of information but I am thinking along the lines of (presumably the start menu is  button 1 on the taskbar:

如果任务栏按钮1被选中然后返回true

If taskbar button 1 is selected then returned true

如果选中任务栏按钮  2则返回true

If taskbar button 2 is selected then returned true

代码应该工作,无论哪个按钮在哪里,因此按钮2可以是Windows资源管理器的实例或Internet Explorer的实例作为示例。
$


谢谢。

the code should work irrespective of what button is where, so button 2 could be an instance of Windows Explorer or an instance of Internet Explorer as an example.

Thanks.

推荐答案


ITaskbarList
界面是我可以使用的唯一可用于Windows任务栏的API。它没有提供任何获取信息的功能从任务栏,但允许修改任务栏。要修改任务栏,您需要
才能将顶部窗口应用到该任务栏。因此,要确定活动按钮,您必须识别活动的顶级窗口(如果有)。

The ITaskbarList interface is the only API available to work with the taskbar in Windows that I'm aware of. It does not provide any functionality for getting information from the taskbar but rather allows modifying the task bar. To modify the taskbar you have to have the top window to apply it to. So to determine the active button you'd have to identify the active top-level window, if any. 

当然,任务栏本身就是一个窗口,其上的按钮是子窗口所以你也可以通过shell窗口找到任务栏窗口,然后枚举它的子项,直到找到"active"为"active"。按钮。从来没有试过,所以我不能说
需要多少代码或工作量,或者即使它可以工作。

Of course the taskbar is a window itself and the buttons on it are children so you could also find the taskbar window via the shell window and then enumerate its children until you found the "active" button. Never tried it though so I cannot say how much code or effort it would take or even if it would work.

Michael Taylor

http: //www.michaeltaylorp3.net

Michael Taylor
http://www.michaeltaylorp3.net


这篇关于检查是否选中了任务栏按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆