Solved

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

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…
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…

920 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