sendkeys problem for telnet

M

mike

hi
i wrote this piece of code

Private Sub CommandButton1_Click()
Dim ReturnValue
ReturnValue = Shell("c:\windows\system32\telnet", 1) ' Run
Calculator.
For t = 1 To 10000000
Next t
Application.SendKeys "open"
Application.SendKeys ("{Enter}")
End Sub

When i click, the telnet program opens and all i get was

Welcome to Microsoft Telnet Client

Escape Character is 'CTRL+]'

Microsoft Telnet>

but did not see "open"
how should sendkeys be done in this case??
thanks
 
G

Guest

Dont't use Application.SendKeys, since it then sends the keystrokes to the
Application (Excel). Instead, just use SendKeys - and to make sure you send
them to Telnet, use AppActivate "Telnet" first; e.g:

AppActivate "Telnet" (see note below)
SendKeys "open{ENTER}"

The AppActivate argument should match exactly the windows title (title bar
text) of your telnet app, I just don't know what that is.

One thing: in odd cases, another app may grab control of windows between
your AppActivate and SendKeys statements, making the keys go to the wrong
app. For example, I have had Groupwise notifications pop up at the wrong
time and steal focus from the app I want to send keys to. So be careful!

Another note: In your timing loop, it is good to put DoEvents to allow
Windows to do some processing tasks while the loop runs, otherwise you might
freeze things up for a while - and I prefer to use a timed loop instead of
looping to some number, e.g. for a 10 second delay:

QuitTime = Now()+ TimeValue("00:00:10")
While QuitTime >= Now()
DoEvents
Wend
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top