Reputation: 3673
I have to write an application that observes another application and extracts information from the window. What is the best way to access windows from other applications and get data from their controls?
Upvotes: 5
Views: 7485
Reputation: 244682
You'll need to P/Invoke the FindWindow
and FindWindowEx
functions to retrieve a handle to the other application's parent window and child controls.
Then you will need to use something like GetWindowText
to access the text for a particular control.
Visit pinvoke.net for the definitions you'll need to call these functions from C#.
Be warned that this is not a completely straightforward pursuit. You should stop to consider whether you really have a good reason for wanting to do this, and if your goal couldn't be achieved in a simpler way.
Upvotes: 4