Solved

Controlling a DOS window from inside VB

Posted on 2000-04-12
3
141 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
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
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…
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…
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…

758 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

21 Experts available now in Live!

Get 1:1 Help Now