?
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
?
160 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

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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 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…
Suggested Courses

764 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