Solved

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

Posted on 1998-09-22
4
153 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
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 70 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

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…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

786 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