ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   sendkeys problem for telnet (https://www.excelbanter.com/excel-programming/331821-sendkeys-problem-telnet.html)

mike

sendkeys problem for telnet
 
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


K Dales[_2_]

sendkeys problem for telnet
 
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


"mike" wrote:

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




All times are GMT +1. The time now is 03:23 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com