检测Win + Tab任务视图 [英] Detect Win+Tab Task View

查看:131
本文介绍了检测Win + Tab任务视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Windows 10上,您可以按 Win + Tab 来获取所有窗口的任务视图"视图.我正在尝试检查是否在任何给定时间都处于活动状态.我尝试使用带有WH_KEYBOARD_LL的低级键盘挂钩,但这仅允许我检测按键,而不是在切换台处于活动状态时.我已经看过Windows DWM API,也没有找到其他任何东西.

On Windows 10, you can press Win+Tab to get a "Task View" view of all your windows. I'm trying to check if this is active at any given time. I have tried using a Low Level Keyboard Hook with WH_KEYBOARD_LL but this only allows me to detect the keypress, not if the switcher is active. I've looked at the Windows DWM API and haven't found anything else either.

我也尝试过使用EnumWindows()EnumChildWindows(GetDesktopWindow(), ...),但在显示和隐藏任务视图之间没有发现任何输出差异.

I have also tried using EnumWindows() and EnumChildWindows(GetDesktopWindow(), ...) and did not find any difference in the output between having the task view shown and hidden.

是否有任何准确的方法来检测是否正在显示?

Is there any accurate method to detect if this is being shown?

推荐答案

这是一个与我的Windows版本(1709内部版本16299.125)非常一致的解决方案,不需要调用:

Here's a solution that works very consistently with my version of Windows (1709 build 16299.125) and doesn't require the processor-heavy approach of a call to EnumChildWindows:

bool isTaskView() {
    //Get foreground window's name
    HWND fgWindow = GetForegroundWindow();
    TCHAR windowName[MAX_PATH] = L"";
    GetWindowText(fgWindow, windowName, MAX_PATH);
    //Compare with magic string name of Task View's window
    std::wstring nameStr(windowName);
    return nameStr == L"Task View";
}

这篇关于检测Win + Tab任务视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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