0

Let's say there is an application which uses CreateWindow/CreateWindowEx with a custom class name, different then button edit etc. I want to be able to find this controls, so i can send them messages using SendMessage. I tried to use FindWindowEx but it is failed to find them. (It's simply returns, not finding any controls at all). How can i find this type of custom controls? I was thinking about bruteforcing with GetDlgItem but i don't think it is gonna work very well. So i guess the only possible way here is to inject dll inside the target process, hook CreateWindow/CreateWindowEx to find those controls IDC, so i can later write them down, and use with GetDlgItem? Is there any simpler solution? I already tried MSAA and UI Automatiation using the tools from win sdk (Inspector). The window i want to automatiate is basically firefox popup modal dialog with MozillaDialogClass. Here the screenshot of this window with Inspector running on it: link

EDIT:

So basically the issue is: MSAA/UI Automatiation components Fails to find the controls inside the dialog that i showed above. I tried both and also tried spy++ it too fails to find the buttons, textboxes, checkboxes inside tihs dialog. Thats why i tried to find them using plain winapi FindWindow + FindWindowEx . But same, no success!

Vladislav
  • 135
  • 2
  • 11
  • Have you seen ***[this post](http://stackoverflow.com/a/4705096/645128)***? – ryyker May 25 '15 at 14:34
  • @ryyker Hello. The problem is, i cannot find those button identificators in spy++/winspy or any other ui inspecting application. The problem is that i need to find them, but i cannot find them from my application, using msa/autimatiaon/findwindowex – Vladislav May 25 '15 at 15:03
  • @ryyker that's why i was thinking about dll injection, and hooking `CreateWindow`/`CreateWindowEx`. Also is there any other ways to create controls natively or any gui control must always be created using this two winapi functions? – Vladislav May 25 '15 at 15:05
  • If you are using `CreateWindow/CreateWindowEx` in your application, then handles will be issued upon success. Can you not just keep track of those handles. The same is true for any controls that you create. – ryyker May 25 '15 at 15:11
  • @ryyker the problem is that i do not know, its not my application, its a firefox engine window. I do not have the source code. You can see it on the screenshot in my main post. I really do not know winapi well, but i assume those controls are created using winapi, so they probably should use one those two functions, right? – Vladislav May 25 '15 at 15:18
  • If this is not your application, why do you seem to know, that the application uses `CreateWindowEx` to create its custom controls? For all we know, the application could use [windowless controls](http://blogs.msdn.com/b/oldnewthing/archive/2005/02/11/371042.aspx). Why don't you continue using [UI Automation](https://msdn.microsoft.com/en-us/library/windows/desktop/ee684009.aspx)? Your question lacks a proper rationale, why you dismissed the Right Way™ to go about this. – IInspectable May 25 '15 at 17:22
  • @IInspectable because UI Automation cannot find the child controls of this window. I checked in inspector and in the c# code. I attached the screen, there you can see, it only can find the window and the title control. – Vladislav May 25 '15 at 17:35
  • @IInspectable about `CreateWindow` i do not know if that is true, i just think that its the only way to create native windows controls. I dismissed the right way, because it does not work. I also checked the MSAA, it too, fails to find the controls inside this window. – Vladislav May 25 '15 at 17:36
  • 1
    If Spy++ cannot see child windows, then there are no child windows. If UI Automation cannot find items either, then the application simply doesn't want to be automated. Nothing you can do about. – IInspectable May 25 '15 at 17:58
  • @IInspectable so there is no way to bypass it with dll injection? I don't like to give up just like that :) – Vladislav May 25 '15 at 17:59
  • If there are no native controls, you cannot use any of the available options to automate them. If UI Automation isn't supported, then there's nothing you can do. Of course you can fully reverse engineer the target application, so that you can safely inject code, that performs the automation on your behalf. You'll have to decide, whether this is worth the effort to you. – IInspectable May 25 '15 at 18:03
  • @IInspectable i will first try and look inside with the hook first, to see if they are actually created using the functions mentioned above. I mean i can do this more dirty way, since the buttons are in static places, i can probably send the WM_ button click message using `PostMessage` api with certain coordinates, to imitate the clicks, but sometimes i need to parse the text from those windows. – Vladislav May 25 '15 at 18:14
  • 2
    Again, if Spy++ can't see child windows, then there are no child windows. No need to go to lengths and install hooks. You have a GUI that implements windowless controls. There is absolutely nothing you can do about it, unless the application implements the interfaces required to make UI Automation work. Since neither appears to be a successful approach, you may as well spend your time more efficiently on something else. – IInspectable May 25 '15 at 18:17

0 Answers0