Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Controlling a DOS window from inside VB

Posted on 2000-04-12
3
Medium Priority
?
151 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 100 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…
Suggested Courses

927 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