How can I read data from controls on window in a different application?
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?
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.
精彩评论