Solved

Controlling a DOS window from inside VB

Posted on 2000-04-12
3
148 Views
Last Modified: 2010-05-02
What I want to do is be able to send key clicks (type as though i am using the keyboard) to a DOS window. The following code works with Windows programs but besides opeing the DOS window and doing some wierd things, did not work:

Private Sub Command1_Click()
Dim ReturnValue, I
ReturnValue = Shell("C:\command.com", 1)  
'MsgBox ReturnValue
AppActivate ReturnValue    ' Activate
SendKeys "X", True


End Sub
0
Comment
Question by:adinas
[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
3 Comments
 

Expert Comment

by:sp_phillips
ID: 2707677
There's an answer on the new Microsoft MSDN Code Site

http://msdn.microsoft.com/code
The best way is using the API

i.e.

AllocConsole
FreeConsole
CloseHandle
GetStdHandle
WriteConsole
SetConsoleCtrlHandler

The example wraps this up in a class wrapper, so it's easy to manipulates

You'll find this in Code Exapmles\Visual Studio, Tools & Lanuages\Visual Basic\Console Window

Simon
0
 
LVL 20

Accepted Solution

by:
hes earned 50 total points
ID: 2708704
Also take a look here:
http://www.saurik.com/samples/

look at smpConsole
0
 
LVL 1

Author Comment

by:adinas
ID: 2710819
OK. I see i didn't explain myself well. The code you showed me indeed created a console which accepts keyboard and mouse input but I wanted to control a REAL DOS window. I want to be able to run a certain DOS App and then send key input to it (from inside my program) for example: I would open a DOS window and my program would type "DIR" and then the Enter key and then the DOS window would show the results.

0

Featured Post

Technology Partners: 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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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 process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Suggested Courses
Course of the Month9 days, 7 hours left to enroll

623 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