Solved

How do I SendKeys to an application that is not designed to run in Microsoft Windows?

Posted on 1998-09-22
4
150 Views
Last Modified: 2010-04-30
How do I SendKeys to an application that is not designed to run in Microsoft Windows? I need to be able to send a key  to a DOS window application while in Windows from a VB application. I've been using SendKeys for Windows style programs but that won't work for a DOS application. Is there a similar statement for DOS programs from VB? Some examples would be great. Thanks
0
Comment
Question by:scully12
  • 2
4 Comments
 

Expert Comment

by:sjrl
Comment Utility
SendKeys sends keystrokes to the active window. If this is the window in which the DOS program is running then the DOS program should receive them. I presume you tried this and it failed?
0
 
LVL 12

Accepted Solution

by:
mark2150 earned 70 total points
Comment Utility
DOS itself is not set up to recieve input by any other means than input redirection. You can place all of the commands in a text file and the redirect the program to accept input from the file. The drawback is that this is static and not interactive. You can capture the output from the DOS program (also by using redirection), but the file cannot be accessed by your program until the DOS thread has completed running. General form of the command is:

SHELL ( program & " < script > result" ), 1

This will spawn a child task in PROGRAM and will pass in the ASCII characters in SCRIPT and return the program output in RESULT.

SHELL is an asynchronous process. I have code for ExecCmd that will spawn a child and wait for it to complete before allowing the VB to continue execution.

It's been posted here before so contact me at mark_Lambert@ntsc.navy.mil for a copy.

M
0
 

Author Comment

by:scully12
Comment Utility
I did notice a post similar to mine several days back. I was hoping though that there might be another solution. I did attempt the SendKeys method but I realized rather quickly that wasn't going to work after reading the Help file in VB on SendKeys. I don't think the script idea will work for me because I need to control the DOS program while it is running rather than waiting for it to shut down. Basically, what I was doing was trying to add extra support to a DOS program that views 3D models and turn it into a screen saver. I was using my VB app to start the program and determine what model and image would be wrapped around the model. Once it was started I was going to send keys to the DOS program to scroll, turn, freeze etc. Thanks for the info.
0
 
LVL 12

Expert Comment

by:mark2150
Comment Utility
Yeah, sounds like it won't work the way you want. Sorry. Thanks for the points tho!

Did you want the ExecCmd?
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
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…

744 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

16 Experts available now in Live!

Get 1:1 Help Now