Solved

how to operate an exe from another exe in VB2013

Posted on 2014-11-30
4
161 Views
Last Modified: 2014-12-02
Hello experts,
We have this program from Zebra that prints the labels just the right way.

Our App has a function but its never as accurate as the Factory software.
Problem is this Factory software needs to fill in ten fields manually and then print.

In order to save our users the time and effort of filling these fields manually we would like to créate a very small program in visual basic that will open the application, fill the fields and press PRINT button..... like a very Little robot?

Can you send us an example on how to do this ? Preferable in VB 2013 but could be in  any other language ? an example with the source would be enough.

WE have a robot already working with websites filling data and working fine.

But with a desktop App we dont know how to do it yet. Please your advice.

Regards!
0
Comment
Question by:rguillermo
4 Comments
 
LVL 24

Accepted Solution

by:
mankowitz earned 167 total points
ID: 40472506
I would use AutoHotKey for something like this. I can't provide a complete example, but you're going to want something like this:

Lets assume that the data you want to populate are in param1, param2, param3 in your VB.NET program.

Process.Start("C:\autohotkey.exe zebra-script.ahk  """ & param1 & """, """ & param2 & """, """& param3 & """)

Now, your zebra-script.ahk would look something like this

Run, zebra-executable.exe  ; substitute name of the zebra executable
WinWaitActive, Zebra, , 2     ; substitute the name of the zebra window
Click 44, 55                               ; the location on the window where the input box is
Send %1%                                 ; the text of the first parameter
Click 88,99                                ; the second text box
Send %2%                               ; the second parameter
Click 100,200                            ; The "print" button
Send !{f4}                                ; an exit command, such as alt-F4
0
 
LVL 40

Assisted Solution

by:Jacques Bourgeois (James Burger)
Jacques Bourgeois (James Burger) earned 167 total points
ID: 40472603
I would first ask the people at Zebra if their software has been designed to be controlled through COM or .NET. If so, they should be able to provide you with the necessary documentation.

You can use the SendKeys class in the System.Windows.Forms namespace. Its Send method enables you to send keys in the system as if they were sent through the keyboard.

Be aware however that you cannot target a specific application. The keys go just as if they were typed, to the active application. This can lead to problems in some situations, specially if you send control keys. I have encountered a situation, a few years ago, where we where using it to fill out a form and then send a Ctrl-P to print the result. If a user switched to another application while we were processing the data, the Ctrl-P ended up in the other application.

User should be advised to wait until the operation is complete before switching to another application. On your side, try to build a long String (control characters and shortcuts can be embedded in the string required by SendKeys) and send it in one batch instead of calling Send multiple times as you go along.
0
 
LVL 14

Assisted Solution

by:frankhelk
frankhelk earned 166 total points
ID: 40473430
The problem with "active application" could be mostly circumvented ...

Process.Start() returns a System.Diagnostics.Process object that contains - among numerous other informations - the MainWindowHandle of the process. If you constantly bring that up to front & focus before sending a key, almost no keystroke will get lost.
0
 

Author Comment

by:rguillermo
ID: 40475432
Jacques Bourgeois (James Burger; I spoke to people at ZEBRA, their software cannot be integrated, the best is send data to an Access table and pull it from their App. Still making our users work with and additonal application.
Never the less it was useful talking to them because I discovered a few useful things to configurate the printer.
Thank you Jacques,

mankowitz and frankhelk, we are still testing your suggestions, thank you
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

713 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question