Solved

send command to dos window

Posted on 2001-08-09
12
259 Views
Last Modified: 2008-02-01
I need to send a txt string to a dos window telnet session

if you use activateapp and then send keys the telnet sessing pops up in front of everthing I don't want this

i need some api like

SendMessage HWNDOFtelnet, WM_SETTEXT, 1, "Some message"

etc.
0
Comment
Question by:jrspano
[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
  • 6
  • 2
  • 2
  • +2
12 Comments
 
LVL 38

Expert Comment

by:PaulHews
ID: 6369267
listening...(might jump in later if I find the link I had.)
0
 
LVL 22

Expert Comment

by:rspahitz
ID: 6369283
Try this answer that worked when I asked a similar question:

http://www.experts-exchange.com/jsp/qManageQuestion.jsp?ta=visualbasic&qid=20094939
0
 
LVL 3

Author Comment

by:jrspano
ID: 6369424
I havent tried it yet but looking at the link rspahitz you still have to have the dos window in focus to use it.  I want the telnet window to get the keystroke without getting focus.
0
Independent Software Vendors: 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!

 
LVL 22

Expert Comment

by:rspahitz
ID: 6369467
There's probably a way, but since DOS has a life of its own, it may be easier to use a Windows-based tool for the job.  Unfortunately, even the Win2000 version of FTP uses a DOS-style Window.

Have you tried getting the handle of the Window and using a SendMessage string?  (Personally, I've never tried it so I probably can't help much with its usage, but I'll bet Paul could!)
0
 
LVL 3

Author Comment

by:jrspano
ID: 6369776
I have tried getting the return from shell and passing that to sendmessages.  it didn't work.  do you think the handle of the window would be better?  or is there something that can send messages to a process id?
0
 
LVL 2

Expert Comment

by:AndrewK
ID: 6370186
Have you tried using SendKeys?
0
 

Expert Comment

by:devendra_patil
ID: 6371810
Use the Api FindWindow to get the handle of the Dos window.Then send the text to dos window using
SendMessage hDosWnd, WM_CHAR, Asc(Char),byval 1
For executing any command use,
SendMessage hDosWnd, WM_KeyDown, Virtual Key Code..,byval 1
SendMessage hDosWnd, WM_KeyUp, virtual...,byval 1
hope this solves ur problem
0
 
LVL 3

Author Comment

by:jrspano
ID: 6372095
andrew yep tried that it works great except that the dos window gets the focus ever time.  I want to avoid this

devendra i'll try your idea in a little while
thanks
0
 
LVL 3

Author Comment

by:jrspano
ID: 6372126
devendra: what would the classname of the window be for the findwindow api??
0
 
LVL 3

Author Comment

by:jrspano
ID: 6372232
i'm going to bump up the points and make the question larger.

when sending the keys to the telnet window i send a command followed by enter this does something in the telnet and gets a response back from the server.  is there any way to see what the returned string is in the vb app?
0
 
LVL 38

Accepted Solution

by:
PaulHews earned 100 total points
ID: 6372288
Sounds to me like you would be better off either writing your own vb telnet client, or using one with a graphical interface.  I was not able to attach to a console and retrieve/send text from/to a dos program that way.

http://www.freevbcode.com/ShowCode.Asp?ID=2839
http://www.freevbcode.com/ShowCode.Asp?ID=578
http://www.freevbcode.com/ShowCode.Asp?ID=1688
0
 
LVL 3

Author Comment

by:jrspano
ID: 6372932
yep i think you are right.  i cant get anything but send keys to work.  thanks for the links.  i think we are going to make the server piece over again using vc++.  Do you know of any working apps that run 24/7 that listen to a telnet port and validate data that work for long periods of time???  any one using something like this?
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…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

740 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