Reputation: 667
Referring to https://github.com/MScholtes/VirtualDesktop/issues/15
I'm looking to do 3 things programmatically, specifically:
I was able to bring up task view by running the following in a command prompt:
explorer shell:::{3080F90E-D7AD-11D9-BD98-0000947B0257}
But is starting a process in C# every single time I need task view the best approach? I prefer a programmatic way of calling some functions etc. I tried the following for activating, but it did nothing
public static readonly Guid CLSID_taskview = new Guid("3080F90E-D7AD-11D9-BD98-0000947B0257");
Activator.CreateInstance(Type.GetTypeFromCLSID(Guids.CLSID_taskview));
Thank you.
Upvotes: 0
Views: 758
Reputation: 2206
I found a way to activate Task View without needing to launch a process:
ShellExecuteA(NULL, "open", "shell:::{3080F90E-D7AD-11D9-BD98-0000947B0257}", NULL, NULL, SW_SHOWDEFAULT);
The same call can be used to deactivate it as well.
To see if the Task View is open, it looks like you can get a handle to the current foreground window and check its class name, like so:
bool IsTaskViewOpen() {
WCHAR className[100];
HWND foreground = GetForegroundWindow();
if (!foreground) {
return false;
}
GetClassName(foreground, className, 100);
return wcscmp(className, L"MultitaskingViewFrame") == 0;
}
I haven't tested that function extensively, so I don't know if it works in all cases.
Upvotes: 0