tags:

views:

576

answers:

7

I am likely to be working on a few projects soon where I will need to take data from a file and input that data programmatically into another third-party (not my own) application. One problem: I have no idea how to do this.I will need to enter data (like times on a time sheet, for exampls) Can anyone steer me in the right direction to acquire this skill?

ADDITIONAL SPECS: I wrote the original post late at night so may not have been as detailed as I should have. Here is an example: My client has an ERP app that they use to collect time stamps from the line workers as they perform their jobs and get projects out the door throughout the day. This app does NOT have an API I can use to feed data into. I have heard of a guy who was able to actually push data onto the screen in this app's windows and controls programmatically, such that the data was able to be collected into, say, an Excel worksheet, then effectively uploaded into this app. Sort of a reverse screen-scrape. It's not pretty like an API would be, but it works.

I've seen app's interact with other apps in a similar way. One good example I can think of is SnagIt, the screenshot utility. You can order it to screen capture a window in a particular app, and as you move your mouse around that window, the controls under the pointer will outline in red to indicate which control it will capture for you. I think that is interesting, and probably just a step away from actually being able to type text into such a control.

Thanks for the comments and answers so far, I'm pursuing them all.

+4  A: 

Different applications allow you to control them programmatically in different ways. The two commonest approaches are:

1) Some applications expose commandline arguments. Example:

c:\> someapp.exe arg1 arg2

You can call such apps from a C++ program with a call like this:

System("C:\\>someapp.exe arg1 arg2");

2) Other applications may expose far more powerful, object oriented APIs. For example, Microsoft Excel lets you program it by using the App itself as an object in your C# program:

Excel.Application excelApp = new Excel.App()

Once you have the app object, you can call methods on it to control its behaviour. You can, for instance, open a new Excel file with a subsequent call like this:

excelApp.Workbooks.Open("\\Somefile.xls", ...);

For any third party app you're trying to control, you are going to have to read its documentation as to how it lets you to do that. The info on how to program Excel, for example, can be found here.

Frederick
A: 

I once did something like this where a windows application was controlled by a web application. I used a lot of Win32 API for that. If your application is a similar one, then look for open source Winamp remote controller for starters.

+2  A: 

It may be very very difficult if the application is not designed to be interacted with. You will need to send mocked events (to pretend as though the mouse was doing certain things for example). One way of doing that is to write a mouse driver that doesn't connect to a real mouse. But, as I say, it depends on the application. Applications with bigger user bases often have APIs to allow programmatic interaction, or have in-built scripting capabilities (so you can kinda make the application use your code instead).

Jesse Pepper
+2  A: 

I think FindWindow and SendMessage are the functions you want to use, in general.

Zach Hirsch
A: 

Or if you want to be even more "hacky", start reading the program memory and inject data directly. :P

But that can be very complex, and often wont work at all because of how the program uses the memory.

Wolf5
A: 

It's not the prettiest way to do it, but I've seen some applications that use the clipboard to do stuff like this. Unfortunately, this will likely also require manual intervention since you probably don't have a way to make the application programmatically pull from/push to the clipboard.

Jason Baker
+4  A: 

You might be able to automate it with an AutoIt script. This is a simple scripting language that hides some of the complexities of sending messages to windows and controls.

Adam Neal
This looks like exactly what I had in mind. Amazingly, it's Freeware! If it works as well as I hope, a donation will be in order.
Mike at KBS