Solved

how to operate an exe from another exe in VB2013

Posted on 2014-11-30
4
150 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
Comment Utility
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
Comment Utility
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 13

Assisted Solution

by:frankhelk
frankhelk earned 166 total points
Comment Utility
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
Comment Utility
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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

763 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now