?
Solved

how to operate an exe from another exe in VB2013

Posted on 2014-11-30
4
Medium Priority
?
164 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 24

Accepted Solution

by:
mankowitz earned 668 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 668 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 664 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
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 Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Suggested Courses
Course of the Month13 days, 10 hours left to enroll

801 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