Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

Can a VB.NET app control another app?

I found an Freeware OCR Java application that I want to launch (found this link (http://www.dev-archive.com/dotnet/Article/7914/0/page/1) ), but once it's launched I need to tell it to "click" a Load Image button. That button then opens a standard Windows browse for file window, and I need to input the right path, select file and click open. Then I need to "click" Decode Image, and exit. Can VB do this? Can anyone point me in the right direction? Am I going to have to create a WMI script and launch that?

Please help,

Adam
[555 byte] By [Nepenthe79] at [2007-11-11 10:05:54]
# 1 Re: Can a VB.NET app control another app?
You can do this with a series of SendKeys commands. This won't be a 100% reliable - if the user clicks on another application or the OCR program throws any errors, you probably won't be able to recover. Have you looked at any OCR components for .NET?
waterjock2000 at 2007-11-11 20:48:37 >
# 2 Re: Can a VB.NET app control another app?
I haven't looked at any of the OCR components of VB.NET, but the program I found is designed to decode a PDF417 2D Barcode (specifically Driver's Licenses) and out put the data into plain text/Hex. Is their an easy way to do that in VB.NET? Also, I tried the SendKeys command, but it's not working because keyboard input to the java program has no effect. It actually requires a mouse click. Any thoughts?
Nepenthe79 at 2007-11-11 20:49:37 >
# 3 Re: Can a VB.NET app control another app?
Ahh - you'll need something like this:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/userinput/keyboardinput/keyboardinputreference/keyboardinputfunctions/sendinput.asp

It's an API call, but is easy enough to use. Here's some additional info on how to use that call with .NET:
http://www.pinvoke.net/default.aspx/user32.SendInput
waterjock2000 at 2007-11-11 20:50:37 >
# 4 Re: Can a VB.NET app control another app?
I'll play around with those, thanks a lot!
Nepenthe79 at 2007-11-11 20:51:36 >