Detect Win+Tab Task View

隐身守侯 提交于 2019-12-10 11:49:42

问题


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.

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?


回答1:


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";
}


来源:https://stackoverflow.com/questions/46653985/detect-wintab-task-view

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!