ak5745
asked on
Finding window with partial name
EE,
I'm currently using FindWindow() and FindWindowEx() to find child windows with static names. However, one of the child window's name is dynamic. Actually, the last 3 characters of the string are dynamic - the first 10 or so are static.
I've done my searching and have seen examples of EnumWindows() of EnumChildWindows() doing the trick, but all were in C++. Anyone have a C# version?
Also, is there a way to use FindWindowEx() to do this instead?
Thanks!
I'm currently using FindWindow() and FindWindowEx() to find child windows with static names. However, one of the child window's name is dynamic. Actually, the last 3 characters of the string are dynamic - the first 10 or so are static.
I've done my searching and have seen examples of EnumWindows() of EnumChildWindows() doing the trick, but all were in C++. Anyone have a C# version?
Also, is there a way to use FindWindowEx() to do this instead?
Thanks!
ASKER
The window belongs to another application. And yes, I am searching using the title string - all the child windows at the level I'm interested in have the same class name (I'm using Spy++ for that info).
All I'm doing with FindWindow is search for the main window, then use those results as an argument (parent) to FindWindowEX. I'll do that all the way down to the level where the child window I need resides. At that point, I'm stuck. I have the child windows parent, and its class name, but am unable to grab that specific window due to the partially dynamic title.
You're thinking GetWindowText might work for me?
All I'm doing with FindWindow is search for the main window, then use those results as an argument (parent) to FindWindowEX. I'll do that all the way down to the level where the child window I need resides. At that point, I'm stuck. I have the child windows parent, and its class name, but am unable to grab that specific window due to the partially dynamic title.
You're thinking GetWindowText might work for me?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Correcting:
Dear god, my english is just getting worse from time to time!
and use GetWindowText on their handles
It's basically the same as using EnumChildWindows
Dear god, my english is just getting worse from time to time!
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
sergiobg57:
GetWindowText works great. As you said, I chopped off the dynamic part of the handle and just searched for it.
Idle_Mind:
Never thought of using SendMessage and sending the GetText message. Thanks for the class!
GetWindowText works great. As you said, I chopped off the dynamic part of the handle and just searched for it.
Idle_Mind:
Never thought of using SendMessage and sending the GetText message. Thanks for the class!
In fact, even findWindows should do the trick.
Are you looking for windows using Title String or Class Name?
If the windows is yours, you should be able to get the class name, and use recursively GetWindowText in order to find your window.
Anyway, i don't develop using C#, i do using C++ but if you post the part of your source where you use the FindWindow, i might be able to code the EnumChildWindows callback after seeing some junk of code which uses WINAPIs from this language.