Solved

how to operate an exe from another exe in VB2013

Posted on 2014-11-30
4
156 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Need help parsing JSON in my VB.Net application 4 44
Error in page 3 46
Not showing page correctly 3 30
fso.FolderExists("\\server\HiddenFolder$") 4 51
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
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…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

911 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

22 Experts available now in Live!

Get 1:1 Help Now