My goal is to control an application from VB.Net. There is no API, and I do not have the source, only the compiled exe. Is there a way to find the opened application, find a button within the application, click a button and know it was clicked? Is there a way to read the contents of a textbox within the application?
Yes, but you will have to resort to using native api calls such as EnumWindows and EnumChildWindows for example. Take a look here, it is for VB6 but the concept is the same.
yes - with Vista (or Win7, or WS2003 and later) there are "UI Automation" APIs.
There are managed options; System.Windows.Automation is one, shipped with .NET 3.0, as part of WPF... Though System.Windows.Automation was shipped as part of WPF, it does not require that the target app uses WPF.
You can read more:
- the UI Automation blog.
- the MSDN Magazine article - talks about using Powershell with System.Management.Automation.dll (an alternative to System.Windows.Automation).
- Blog post by Samuel Jack - describes using System.Windows.Automation to automate the Paint.NET program (C#).
- CodeProject article #1 shows using UI Automation to test an installer
- CodeProject article #2 provides a basic intro to using System.Windows.Automation
Yes you can, but first it might be easier to use 'AutoIt' as a prototyping script first to find the application, look for the handle of the window of that application, enumerate through that window's child controls, look for that text box specifically and the button...once AutoIt prototype works, then dive into the real coding and it would be possible to use pinvokes to enumerate and find the windows, get the handles of it and perform the automation on it...
Have a look at this sample in C# for this posting here on SO. The OP was trying to access a third party window application, to extract texts and to use that texts within their program...notice how in that given link, 'FindWindow' was used to iterate through the child windows of the main process's window.
Hope this helps, Best regards, Tom.