2014年6月27日金曜日

第34回「vbsから開いているIEを操作する」

第34回「vbsから開いているIEを操作する」です。

既に開いているIEのウィンドウ、タブがGoogleだったら、閉じます。

#####
ie.vbs
#####
Option Explicit

Private FSO
Private Browser
Private ProgName
Private BrowsersArray(),c

Set FSO = CreateObject("Scripting.FileSystemObject")
c = 0
For Each Browser In CreateObject("Shell.Application").Windows
    ProgName = FSO.GetFileName(Browser.FullName)
    If LCase(ProgName) = "iexplore.exe" Then
        ReDim Preserve BrowsersArray(c)
        Set BrowsersArray(c) = Browser
        c = c + 1
    End If
Next

Set FSO = Nothing
If c > 0 Then
    For Each Browser In BrowsersArray
        'WScript.Echo Browser.LocationURL
        'WScript.Echo Browser.LocationName
        If Browser.LocationName = "Google" Then
            Browser.Quit
        End If
    Next
End If

0 件のコメント: