1

VBScriptからの出力をリアルタイムでメモ帳/ワードパッドに書き込みたいのですが。これを行うための最良の方法は何ですか?sendkeysを知っていますが、特別なコマンドの入力を解析する必要があります。

4

2 に答える 2

2

SendKeys is the only method for writing to a third-party application in realtime. Why don't you use CScript and write to the standard output instead? That is what it is meant for.

' Force the script to run in the CScript engine
If LCase(Right(WScript.FullName, 11)) <> "cscript.exe" Then
  strPath = WScript.ScriptFullName
  strCommand = "%comspec% /k cscript " & Chr(34) & strPath & chr(34)
  CreateObject("WScript.Shell").Run(strCommand)
  WScript.Quit
End If

For i = 1 to 10
  For j = 0 to 25
    WScript.StdOut.WriteLine String(j, " ") & "."
    WScript.Sleep 50
  Next

  For j = 24 to 1 Step - 1
    WScript.StdOut.WriteLine String(j, " ") & "."
    WScript.Sleep 50
  Next
Next
于 2012-02-22T20:16:32.263 に答える
1

これを試して

 Const fsoForWriting = 2

   Dim objFSO
   Set objFSO = CreateObject("Scripting.FileSystemObject")

  'Open the text file
   Dim objTextStream
   Set objTextStream = objFSO.OpenTextFile("C:\SomeFile.txt", fsoForWriting, True)

  'Display the contents of the text file
   objTextStream.WriteLine "Hello, World!"

  'Close the file and clean up
   objTextStream.Close
   Set objTextStream = Nothing
   Set objFSO = Nothing
于 2012-02-22T04:20:54.153 に答える