Reputation:
Currently running this code to open Business Vision (an application written by someone else that i don't have access to the code of):
ProcessStartInfo myProcessStartInfo = new ProcessStartInfo(BusinessVisionPath);
myProcessStartInfo.UseShellExecute = false;
myProcessStartInfo.RedirectStandardOutput = true;
myProcess.StartInfo = myProcessStartInfo;
myProcess.Start();
StreamReader myStreamReader = myProcess.StandardOutput;
Boolean done = false;
while (done == false)
{
int s = myStreamReader.Read();
Console.WriteLine(s);
if (s == -1)
{
done = true;
Process IProcess = new Process();
ProcessStartInfo IProcessStartInfo = new ProcessStartInfo(QuickPrinterPath);
IProcessStartInfo.WindowStyle = ProcessWindowStyle.Maximized;
IProcess.StartInfo = IProcessStartInfo;
IProcess.Start();
}
}
myProcess.Close();
Console.ReadLine();
Anyways,
this code currently opens my printer program when BusinessVision closes.
Questions:
Upvotes: 0
Views: 191
Reputation: 161
You can try to use one of the approved way to access data.
In the case of Sage BusinessVision there is:
1 is the most simple way and nothing is automatic.
2 is more challenging but will give you acces to the underlying data live.
3 requires that you pay and that you meet requirement by Sage.
If you combine 2. and some UI automation you could build some trigger on certain UI events and bring foward new windows filled with data from the database.
Note that UI automation will be extremly fragile to new version of the application and will certainly need to be reworked every time.
Upvotes: 1
Reputation: 2921
You might want to look into Microsoft's UI Automation. It allows you to read data from the windows of other applications, and interact with other applications' UI programmatically. I used this a couple years ago to automate a bunch of tests on an old VB6 app we had. My code would find the main window of the application, then drill down to the menus/controls/etc that I was interested in. From there I could automate clicks and keystrokes, and then scrape the text/data I wanted from the labels in various windows. I could then pull the data into my .NET app and do what I wanted with it.
In your case you would need some always-running app (such as a Windows service) to constantly monitor the BV program and detect when the message box appears, and then react accordingly by launching your program.
It takes a fair amount of work to understand and get working, but it's very powerful. There are free apps out there that will make it easier to browse the visual hierarchy of windows and see what kind of information is available. Check out Microsoft's UISpy:
http://msdn.microsoft.com/en-us/library/ms727247.aspx
Here are some other links to get you started:
http://en.wikipedia.org/wiki/Microsoft_UI_Automation
http://msdn.microsoft.com/en-us/library/ms747327.aspx
Upvotes: 1
Reputation: 20788
If the target is a .NET exe, perhaps the developers were sloppy and exposed their classes and methods publicly. In that case, load the exe as if it were a DLL dependency for your application and call their methods directly.
Upvotes: 0
Reputation: 2746
Upvotes: 0