基本的に、テキストをコピーして Web サイトを開き、そのテキストを貼り付けて Enter キーを押したいと思います。お願い助けて
5388 次
1 に答える
1
ファイル システム オブジェクトを使用して、テキスト ファイルをコピーできます。
Dim objFSO, objTextFile, objIE
Dim strTextFile, strTextLine
Set objFSO = CreateObject("Scripting.FileSystemObject")
' Set up the origin and destination files
strTextFile = "C:\myFile.txt"
' Open the temporary text file for reading
Set objTextFile = objFSO.OpenTextFile(strTextFile)
' Read the temporary text file
strTextLine = objTextFile.ReadLine
テキストをコピーしたら、Web サイトを開きます。
Set objIE = CreateObject("InternetExplorer.Application")
objIE.Navigate "http://www.google.com"
Do Until objIE.readyState = 4 : Wscript.Sleep 10 : Loop
次に、貼り付けるフィールドの名前を知る必要があります。これは、ソース コードを右クリックして表示することで実行できます。
objIE.document.all.item("field_name").value = strTextLine
最後に、sendkeys を使用して Enter キーをエミュレートします。
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.SendKeys "{ENTER}"
于 2013-10-21T14:54:49.973 に答える