Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 1998-09-22
4
Medium Priority
?
164 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
[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
  • 2
4 Comments
 

Expert Comment

by:sjrl
ID: 1436046
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 210 total points
ID: 1436047
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
ID: 1436048
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
ID: 1436049
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
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…
Suggested Courses

609 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