2011-03-24 34 views
0

有沒有人有發送變量的示例VBS代碼,等待響應並重復?vbs腳本發送數據並重復

我到目前爲止有:

dim input 
input = Inputbox ("Enter Var:" ,"Var sender...") 

SourceURL = "http://example.com/someFunction.php?var="&input&"" 

就是這樣......我的其他代碼不起作用......

在此先感謝,希望有人可以幫助,在VBS完全失去了...在Windows中一般...

回答

1

假設這是Windows腳本宿主,您可以使用MSXML2庫。

do while true 

    Dim input, SourceURL 
    input = Inputbox ("Enter Var:" ,"Var sender...") 

    SourceURL = "http://www.google.co.uk/search?q=" & input 
    ''// connect and send to server 
    Dim http: set http = CreateObject("MSXML2.XMLHTTP") 
    http.open "GET", SourceURL, false 
    http.send 

    if http.status = 200 then 
     ''// do something with the return value if necessary 
     WScript.Echo http.responseText 
    else 
     ''// problem? 
    end if 
    ''// pause execution if you don't want to hit the server so often 
    WScript.Sleep 10 
loop 

,如果你在服務器上修改的東西,你應該使用POST請求而不是一個GET請求,但如果你的服務器端腳本只接受GET請求

+0

您好,感謝這應該工作你的迴應,我認爲我得到它,但是,你是如何做到的,只是發送價值,然後清除輸入框,並等待另一個響應無限期地重複過程? – 2011-03-25 11:55:02

+0

我已經更新了代碼片段以反映您的評論:我已將「inputbox()」帶入循環中,並且輸入現在是Google查詢(用於我的測試)。此外,我更正了'sleep()'調用,它需要成爲'WScript'對象的一個​​方法 – 2011-03-25 12:14:49