2014-11-17 35 views
0

我正在製作一個腳本,可以讓您登錄到您的Facebook帳戶,而無需前往互聯網並自行輸入。我想添加一個選項來保存您的登錄信息。我需要能夠將數據寫入文件並將數據放回到變量中。這是我到目前爲止:我需要使用wscript將數據保存到文本文件中

On Error Resume Next 
set ie = CreateObject("InternetExplorer.Application") 
sub loading 
do while ie.busy 
wscript.sleep 350 
loop 
end sub 
username=inputbox("Please Enter Your Facebook Username/Email:","Facebook LogIn") 
password=inputbox("Please Enter Your Facebook Password:","Facebook LogIn") 
ie.left=0 
ie.top=0 
ie.toolbar=0 
ie.statusbar=0 
ie.height=135 
ie.width=1020 
ie.resizable=0 
ie.navigate"https://www.facebook.com/" 
call loading 
ie.document.all.item("email").value=(username) 
ie.document.all.item("pass").value=(password) 
ie.Document.All.Item("login_form").Submit 
call loading 
ie.width=1200 
ie.height=700 
ie.resizable=true 
ie.visible=true 

請注意,我沒有自己編寫所有這些代碼。我有一些幫助,可以通過youtube編輯html代碼中的數據。

回答

0

要寫入文件:

Dim fso : Set fso = CreateObject("Scripting.FileSystemObject") 
Dim file : Set file = fso.OpenTextFile("C:\temp\myfile.txt", 2, True) 
file.Write "some text" 
file.Close 

讀取文件內容爲VAR:

Dim fso : Set fso = CreateObject("Scripting.FileSystemObject") 
Dim file : Set file = fso.OpenTextFile("C:\temp\myfile.txt", 1, False) 
myvar = file.ReadAll 
file.Close 

不用說,你必須修改這個 - 你不一定想要將整個文件內容讀入您的變量中。但這是基礎知識。

+0

這正是我需要的,非常感謝。 – Savvy

相關問題