Solved

Controlling a DOS window from inside VB

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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…
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…

860 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