0

I have a small calculation system that will be installed in multiple PCs. Those PCs have a program installed in them and this program is always open (but minimized).

I need to get the value of a 'RadioButton' in this program but I can't access it!

I've tried to get an API for this application but the company developed it refused to co-operate. I've got a crazy idea, you can refer to my question regarding this idea Click It and the last thing is to get the cache for the button but I think this is going to work with WebApplications only!

Any help would be Great! =) .. And btw I decided to build my application as web application but then I changed my mind to build it as a WinForms because of the screenshot. But if I got a better and a more clean solution I'd go back to WebApp

Community
  • 1
  • 1
Mazen Elkashef
  • 3,430
  • 6
  • 44
  • 72

1 Answers1

1

Screen grabbing is not a good option. You should be able to use FindWindow based methods to get hold of the radio button if the app uses windowed controls. If not then UI Automation may very well be able to get the value of the radio button. Whatever it's usually possible to read UI state out of another application with methods like this, and much easier than screen scraping.

David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490
  • Well David, I think you're trying to give me awesome news! =) .. but I don't have a clue about UI, Windows APIs and stuff so let me do my research and if you have more clarification on how to use this method to find a specific program/process and then access it's RadioButton. I think it's a WinForm application although I'm not sure, But we can try and error! =D but for now a sample code or more details will be great. anyway I'll research and if you have anything to add that would be great! – Mazen Elkashef Oct 09 '11 at 21:06
  • There are a gazillion examples of FindWindow automation on Stack Overflow alone. The first thing you need to do is use Spy++ or similar to understand whether or not this app uses a window for the radio button. If so then it will be easy to get home from there. – David Heffernan Oct 09 '11 at 21:08
  • Note: the window title will be like this "Program Name - Variable - Variable" – Mazen Elkashef Oct 09 '11 at 21:10
  • You typically want to know the window class and have an idea of the form of the caption. Then you can use `FindWindow` or `EnumWindows` to get the top-level window. Then you can dig deeper. But first of all you need to use Spy++ to learn about the make-up of the target app. – David Heffernan Oct 09 '11 at 21:12
  • !!! WOW!!! lool I might sound crazy but I never heard about this tool! man isn't it AWESOME! .. I still can't find the RadioButton! and maybe they blocked or that's not possible I just have to look? .. but it's a WinForm i think since Spy++ detected it and I can see ALL KIND OF INFO about the app controls and markup xD! .. This is really great, I wish if i can +10! :D:D – Mazen Elkashef Oct 09 '11 at 21:18
  • Can you see any child windows of the form? If not then it may well be a WPF app. They don't use child windows but they are also susceptible to UI Automation. – David Heffernan Oct 09 '11 at 21:25
  • Well it's a simple application. It's all in a one form and a couple of tabs. and I can see the control classes as System.Windows.Forms so I think it's a WinForms App. and I found the controls that I'm search for. but what would be the next step to actually access those values ? and is it possible to edit or I can only read them? I mean managed spy would let me change properties and see it reflect on the application! – Mazen Elkashef Oct 09 '11 at 21:44
  • For a .net app UI automation may be easier than EnumWindows. But I personally don't know about UI Automation. – David Heffernan Oct 09 '11 at 21:51
  • so what exactly is FindWindow() ? is it UI ir EnumWindow or what ? I just need some guidance and I'll do all the research :) .. You've provided a perfect way to solve the problem. so I'll mark it as an answer but if you have any further comments or guides for the way to access those properties please add them it will help a lot! I've never dealt with this UI stuff! – Mazen Elkashef Oct 09 '11 at 21:59
  • 1
    FindWindow and EnumWindows are raw win32 apis. Need to pinvoke them. If I were you I would google UIautomation and look for a tutorial on that. – David Heffernan Oct 09 '11 at 22:00
  • 1
    Will do that (Y) You've been more than a great help. have a good night David. – Mazen Elkashef Oct 09 '11 at 22:26
  • Hay David. I've been trying since you answered my question to get some tutorials on UI Automation or Win32 and it's been a disappointment. If you have the time to check my questions that would be great because I'm really lost here and I can't find a good tutorial to help me with the UI Automation for WinForms http://stackoverflow.com/questions/7707113/another-one-about-win32-vs-ui-automation http://stackoverflow.com/questions/7723742/my-first-use-for-ui-automation-i-need-to-access-a-button-control-in-a-running-w – Mazen Elkashef Oct 12 '11 at 02:04