Reputation: 8237
I'm developing a piece of software to inset some text in a rich edit of another program the code goes like this:
atlfe = FindWindowEx(wtlsplitterwindow, 0, "atl:0087d7a8" , null);
This is only one line: this works fine, problem is with every release of the program number atl:0087d7a8
changes so i have to use spy++ to get the new one and change it in the code.
The question is, is there is any way I can get that number from code?
By the way I'm using C#, VS2010.
Upvotes: 0
Views: 957
Reputation: 138841
I suggest you use UI Automation instead of raw Windows API. You should start with the UI Spy tool to determine the UI hierarchy of your app, it will be more resilient to change.
See some articles on this subject on SO:
Retrieve current URL from C# windows forms application
How to get the word under the cursor in Windows?
Upvotes: 1
Reputation: 612934
Clearly if the sub-window has not title and its classname is different every time you have but one method remaining.
You are first going to have to find the top level window of this app using either EnumWindows or FindWindowEx, the latter if you can identify it by class name and/or window title.
Once you have the top level window you can walk through the children to locate the sub-window that you are looking for. Presumably you already know the relationships between the top level window and the sub-window you are targetting. In any case Spy++ can tell you this.
Upvotes: 0
Reputation: 12632
If the Title
is always the same, use it instead of class name
atlfe = FindWindowEx(wtlsplitterwindow, 0, null, "Title");
More info on MSDN.
Upvotes: 0
Reputation: 4142
Been a while since I messed with some of these windows API's. I think this may be of value though.
http://msdn.microsoft.com/en-us/magazine/cc163617.aspx
Upvotes: 0