2016-07-28 4 views
1

Windowsエクスプローラを閉じるときにスクリプトの実行を停止するにはどうすればよいですか?ここに私のコードです。VBScript:Windowsエクスプローラが閉じられているときにスクリプトを停止する

Dim i 
    CreateObject("Wscript.Shell").Run """website1.com""", 0, False 
    Wscript.Sleep 40000 
    CreateObject("Wscript.Shell").Run """website2.com""", 0, False 
    Wscript.Sleep 40000 

For i=1 to 10 
    Set WshShell = WScript.CreateObject("WScript.Shell") 
    WshShell.AppActivate "Internet Explorer" 
    WshShell.SendKeys "{F5}" 
    Wscript.Sleep 1000 
    WshShell.SendKeys "^{TAB}" 
    Wscript.Sleep 40000   
Next 

答えて

0

これは、関心のウィンドウの数をカウントしたときに0

Set objShell = CreateObject("Shell.Application") 
Do 
    Set AllWindows = objShell.Windows 
    Count = 0 
    For Each window in AllWindows 
     window.refresh2 3 
     Count = Count + 1 
    Next 
    If Count = 0 then Exit Do 
    Wscript.sleep 5000 
Loop 

または2つだけの窓

Set objShell = CreateObject("Shell.Application") 
Do 
    Set AllWindows = objShell.Windows 
    Count = 0 
    For Each window in AllWindows 
     If window.locationname = "website1.com" or window.locationname = "website2.com" then 
      window.refresh2 3 
      Count = Count + 1 
     End If 
    Next 
    If Count = 0 then Exit Do 
    Wscript.sleep 5000 
Loop 
をリフレッシュするために存在します
関連する問題