VBScript と AutoIt は初めてです。AutoIt スクリプトを使用して VBScript (テキスト ファイル) を変更しようとしています。ユーザーからの入力をカンマ区切りのコマンド形式で受け取り、それを.vbs
ファイルに書き込んでいます。While
文字列を配列に格納してからループ を使用して書き込むことで、これを実行しようとしました。
例:
入力の場合:テキスト ファイルの行"140"から次のような出力ALPHA,BETA,GAMMA
が期待されます
WshShell.appactivate "telnet 10.250.124.85"
WScript.Sleep 1999
WshShell.SendKeys"ALPHA"
WshShell.appactivate "telnet 10.250.124.85"
WScript.Sleep 1999
WshShell.SendKeys"BETA"
WshShell.appactivate "telnet 10.250.124.85"
WScript.Sleep 1999
WshShell.SendKeys"GAMMA"
代わりに、次のような出力が得られます。
WshShell.appactivate "telnet 10.250.124.85"
WScript.Sleep 1999
WshShell.SendKeys""
WshShell.appactivate "telnet 10.250.124.85"
WScript.Sleep 1999
WshShell.SendKeys""
WshShell.appactivate "telnet 10.250.124.85"
WScript.Sleep 1999
WshShell.SendKeys""
つまり、SendKeys の引用符が何らかの間違いにより空になっています。私が使用したコードは次のとおりです。
$fileadd="C:\Users\rmehta\Downloads\zyxw\Memorycheck.vbs"
$commandnewstring= InputBox("Command Settings","Please enter the commands seperated by commas","")
If @error=0 Then
Global $count,$usestring,$output
$usestring=$commandnewstring
$count= UBound(StringSplit($commandnewstring, ",",""))-1
Global $a[$count],$line
$line=140
$count= $count-1
$output= StringSplit($usestring,",","")
While $count >= 0
$a[$count]= $output
_FileWriteToLine($fileadd,$line,"WshShell.appactivate" & Chr( 34 ) & "telnet 10.250.124.85" & Chr( 34 ),1)
_FileWriteToLine($fileadd,$line+1,"WScript.Sleep" & " 1999",1)
_FileWriteToLine($fileadd,$line+2,"WshShell.SendKeys" & Chr( 34 ) & $a[$count] & Chr( 34 ),1)
$count=$count-1
$line=$line+3
WEnd
Else
MsgBox(0,"You clicked on Cancel",2)
EndIf
いろいろ考えましたが答えが出ませんでした。