Okay I can't see what I am doing wrong with the following code....
The issue is in the Send() Function, it does the "config t" just fine and sends all the the {enter} keys, but not the $checkstring. It ends up on the console.
Any ideas what my simple brain is overlooking today?
Code:
;Script Options
$SO=SETOPTION("Explicit", "ON")
$SO=SETOPTION("NoMacrosInStrings", "ON")
$SO=SETOPTION("NoVarsInStrings", "ON")
$SO=SETOPTION("WrapAtEOL", "ON")
BREAK ON
Dim $SO, $FH, $Device[], $Input[], $R, $, $I
CLS
$FH=FreeFileHandle()
If Open($FH, @ScriptDir+"\devicelist.txt",2)= 0
$R = Readline($fh)
$SO = 0
While @Error = 0
Redim Preserve $Device[$SO]
$Device[$SO] = $R
$SO = $SO + 1
$R = Readline($fh)
Loop
Close($FH)
Else
? @Serror
EndIF
If Open($FH, @ScriptDir+"\input.txt",2)=0
$R = Readline($fh)
$SO = 0
While @Error = 0
Redim Preserve $Input[$SO]
$Input[$SO] = $R
$SO = $SO + 1
$R = Readline($fh)
Loop
Close($FH)
Else
? @Serror
EndIF
For each $SO in $Device
CLS
? "Please connect to: " + $SO
? "Press -C- once connected and in Exec mode"
Press()
Select
Case SetFocus("Untitled - Notepad") = 0
$I = "Untitled - Notepad"
Case Setfocus("Telnet "+$SO) = 0
$I = "Telnet "+$SO
Case Setfocus($SO+" - PuTTY") = 0
$I = $SO + " - PuTTY"
Case Setfocus($SO+" - SecureCRT") = 0
$I = $SO + " - SecureCRT"
Case ? "Unable to find Window"
$I = 0
EndSelect
If $I <> 0
Send($Input,$I)
EndIf
Next
Function Press()
Dim $
While $ <> "C"
Get $
Loop
EndFunction
Function Send($Input,$I)
Dim $, $Checkstring
SetFocus($I)
Sendkeys("config t {enter}")
For each $ in $Input
CheckString($)
SetFocus($I)
SendKeys($checkstring+"{Enter}")
Next
EndFunction
Function CheckString ($letters)
Dim $a, $i, $s
$a = ""
For $i= 1 to Len($letters)
$a = Substr($letters, $i, 1)
Select
Case $a = "+"
$a = "{+}"
Case $a = "^"
$a = "{^}"
Case $a = "~"
$a = "{~}"
Case $a = "("
$a = "{(}"
Case $a = ")"
$a = "{)}"
Case $a = "{"
$a = "{{}"
Case $a = "}"
$a = "{}}"
EndSelect
$s = $s+$a
Next
$checkstring = $s
EndFunction