Automating another app
-
In the name of code reuse, does anyone have pointers to articles that give examples of how to automate another app? Scenario: I'm writing an app that helps me do part of my job much faster. However, I must still manually copy and paste data from an existing .NET app into mine. Therefore, I'm looking for code examples of how to programmatically control the other app the way I would do so manually. Ex: 1) F4, enter data, press enter 2) Copy from fields 3) etc. Most of this I can guess, FindWindow (to locate app's main window), figure out how to send keystrokes, GetWindowText on specific windows, etc. I'm just hoping someone's already done something I can use real quick instead of blowing a few hours stumbling through it. Tom Archer (blog) Program Manager MSDN Online (Windows Vista and Visual C++) MICROSOFT -- modified at 23:47 Monday 27th March, 2006
-
In the name of code reuse, does anyone have pointers to articles that give examples of how to automate another app? Scenario: I'm writing an app that helps me do part of my job much faster. However, I must still manually copy and paste data from an existing .NET app into mine. Therefore, I'm looking for code examples of how to programmatically control the other app the way I would do so manually. Ex: 1) F4, enter data, press enter 2) Copy from fields 3) etc. Most of this I can guess, FindWindow (to locate app's main window), figure out how to send keystrokes, GetWindowText on specific windows, etc. I'm just hoping someone's already done something I can use real quick instead of blowing a few hours stumbling through it. Tom Archer (blog) Program Manager MSDN Online (Windows Vista and Visual C++) MICROSOFT -- modified at 23:47 Monday 27th March, 2006
Tom Archer - MSFT wrote:
Most of this I can guess, FindWindow (to locate app's main window), figure out how to send keystrokes, GetWindowText on specific windows, etc. I'm just hoping someone's already done something I can use real quick instead of blowing a few hours stumbling through it.
Nibu thomas Software Developer
-
Tom Archer - MSFT wrote:
Most of this I can guess, FindWindow (to locate app's main window), figure out how to send keystrokes, GetWindowText on specific windows, etc. I'm just hoping someone's already done something I can use real quick instead of blowing a few hours stumbling through it.
Nibu thomas Software Developer
Thanks Nibu. That gets me the SendKeys bit, but the hardest part is getting the data from other app. Generally, that's not too difficult with a standard Windows app. However, it's a .NET app so I'm not sure how to programmatically find the specific windows I need. Looking at Spy++, I can see several issues: 1) they all have the same class name, 2) what I would normally see as a listbox evidently is something else and so on. Therefore, what I'm looking for is an example of a C++ program driving a .NET application and basically screen scraping from the .NET apps windows. Tom Archer (blog) Program Manager MSDN Online (Windows Vista and Visual C++) MICROSOFT
-
Thanks Nibu. That gets me the SendKeys bit, but the hardest part is getting the data from other app. Generally, that's not too difficult with a standard Windows app. However, it's a .NET app so I'm not sure how to programmatically find the specific windows I need. Looking at Spy++, I can see several issues: 1) they all have the same class name, 2) what I would normally see as a listbox evidently is something else and so on. Therefore, what I'm looking for is an example of a C++ program driving a .NET application and basically screen scraping from the .NET apps windows. Tom Archer (blog) Program Manager MSDN Online (Windows Vista and Visual C++) MICROSOFT
Tom Archer - MSFT wrote:
However, it's a .NET app so I'm not sure how to programmatically find the specific windows I need. Looking at Spy++, I can see several issues: 1) they all have the same class name, 2) what I would normally see as a listbox evidently is something else and so on.
With a .NET Framework-based application, the window messages and classes intercepted by Spy++ don't correspond to anything useful. You want to see managed events and property values. See here for more.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
-
Tom Archer - MSFT wrote:
However, it's a .NET app so I'm not sure how to programmatically find the specific windows I need. Looking at Spy++, I can see several issues: 1) they all have the same class name, 2) what I would normally see as a listbox evidently is something else and so on.
With a .NET Framework-based application, the window messages and classes intercepted by Spy++ don't correspond to anything useful. You want to see managed events and property values. See here for more.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
Yep. I remembered this article last night. It's not 100% what I wanted in that it doesn't show how to find a particular window or what I'm capable of searching for, but it's definitely a start. Thanks David. Tom Archer (blog) Program Manager MSDN Online (Windows Vista and Visual C++) MICROSOFT