I've been looking into FindWindow and have created the following code to illustrate:
Code:
#include <iostream>
#include <windows.h>
using namespace std;
int main()
{
if (FindWindow("Windows Task Manager", 0)) //This doesn't work
{
cout << "\n" << "Windows Task Manager \t found" << endl;
}
else
{
cout << "\n" << "Windows Task Manager \t not found" << endl;
}
if (FindWindow("Calculator", 0)) //This doesn't work
{
cout << "\n" << "Calculator \t\t found" << endl;
}
else
{
cout << "\n" << "Calculator \t\t not found" << endl;
}
if (FindWindow("Notepad", 0)) //This works
{
cout << "\n" << "Notepad \t\t found" << endl;
}
else
{
cout << "\n" << "Notepad \t\t not found" << endl;
}
cin.ignore();
cin.get();
return 0;
}
The executable identifies Notepad correctly as being open. If Calculator or Windows Task Manager are open, neither is identified as such. Why doesn't FindWindow work with all of these windows in a consistent manner? Is there a way of picking up the processes instead (calc.exe, notepad.exe and taskmgr.exe)?
I realise that the code isn't particularly sensible (several similar if ... else etc.) but I only created it to demonstrate the point I want to ask.