Using GetAltTabInfo?

I can not use GetAltTabInfo. Probably a stupid mistake, but what's wrong with that?

HWND taskSwitcher = FindWindow(L"TaskSwitcherWnd", L"Task Switching");
ALTTABINFO altTabInfo = {};
altTabInfo.cbSize = sizeof(ALTTABINFO);
GetAltTabInfo(taskSwitcher, -1, &altTabInfo, NULL, 0);

I checked that taskSwitcher is a window for switching tasks after calling FindWindow (regardless of whether it is visible or not). All altTabInfo fields remain 0 after calling GetAltTabInfo, with the exception of cbSize, which was set to 40 when assigned sizeof (ALTTABINFO). I am trying to do this on a windows 7 machine.

Alternative methods to extract the number of windows?

thank

Edit: Well, I just realized that I could get some error information. The value of the result of calling GetAltTabInfo is really 0, and GetLastError gives me 1400 (invalid window handle) or 1168 (element not found) if I specify NULL for the hwnd parameter (it was defined as __in_opt). Therefore, I think I'm going through the wrong window. What is correct, if not the one that returns FindWindow (L "TaskSwitcherWnd", L "Task Switching")? MSDN only tells me about the hwnd parameter that "This window should be an application switch window."

+3
source share
3 answers

API Win32. GetAltTabInfo BOOL, GetLastError(), FALSE:

BOOL ok = GetAltTabInfo(hWnd, -1, &altTabInfo, NULL, 0);
if (!ok) {
    int err = GetLastError();
    Log(err);   // Or whatever you use
    return false;
}

, 1400, " ". , EnumWindows(), . , API , Aero. .

+2

, GetAltTabInfo, EnumWindow() . , Alt-Tab...

0

Why is this important, since mokubai knew at https://superuser.com/questions/72946/disable-or-delay-alt-tab-aero-peek-effect-in-windows-7 , you can get the tabbed window of the old alt style even when win 7 aero is activated (left alt + tap right alt + tab (.. I'm not joking !!)). With this window, the visible hwnd parameter in GetAltTabInfo does not matter, and in these circumstances you can still get the Alt tab information.

0
source

Source: https://habr.com/ru/post/1771478/


All Articles