Is there a way to check for a certain window being open? Like in that list of things under the applications tab in the task manager. Being able to scan through that list and looking for a certain window would be wonderful.
You can take a snapshot of all processes and then iterate through them to find your process by name. I recently made a small anti-cheat by using this. Though it wasn't affective sense you simply need to change the name of the process of the hook or hack used, it used the windows functions to take a snapshot of the processes and upload them to the server which then stores them into a variable and prints them to an INI (only file storage the script supported. If you noticed it's UnrealScript).
A couple questions though. One, I'm looking for a window on a different program, and it's a child window of that program and doesn't actually get it's own place in the task manager, which I did not notice until a little bit ago. Will FindWindow still work if that's the case?
Two, is there any way to find the name of the window if the source code is not available to me? If so, how?
Since it's a child window, you'll need to use EnumChildWindows() to find it. That API function needs a parent's window handle though, so use EnumWindows() to go through top level windows, using GetWindowThreadProcessId() to get a process ID. To check if it's the process you're looking for, you can open the process with OpenProcess(), and call EnumProcessModules() just once to get a module from it so that you can call GetModuleBaseName() for the path of the '.exe' for comparison.
If you know the window's name and class, or the parent window, then FindWindowEx() should work, otherwise I don't know if there's an easier way to do what you're talking about or not, best regards.
yeah, sorry, windows doesn't really make things easy. Keep in mind that even with the above method, when you're enumerating the child windows, you'll have to have some way to identify the child window. It is very difficult to communicate with programs that you don't have source code for, but one thing to consider; I don't know if there is a way to do it, but if you can manage to get the class/title information ( perhaps using GetClassName(), and GetWindowText() ) from the window you are looking for only once, that's all you need, you should be able to use FindWindowEx() after that to look for the window (i think you will still need the parent's window handle though).
If you haven't already, make sure you look at the MSDN documentation on these functions, that should clear up how to use them and there are remarks at the bottom that often contain information about common pitfalls/concerns about using certain functions. http://msdn.microsoft.com/en-us/library/default.aspx
Thank you for your help. This is wonderful information and I'm still working on getting it all working together but so far it seems it will work as I want it to. Eventually xD. Thanks again.