IEの特定のタブをアクティブにする。(その2)
VB.NETに移植。
Function TabActivate(URL As String) As String
Dim Shell As Object=CreateObject("Shell.Application")
Dim ie As Object=Nothing
For Each ie In Shell.Windows()
If ie.LocationURL=URL Then Exit For
ie=Nothing
Next
If ie Is Nothing Then
TabActivate="Not Found 1"
Exit Function
End If
Dim wShell As Object=CreateObject("WScript.Shell")
If wShell.AppActivate(ie.Document.title) Then
TabActivate=True
Exit Function
End If
Dim ix As Object=Nothing
Dim LocationURL As String
For Each ix In Shell.Windows()
If ix.HWND=ie.HWND Then
If ix.Document.title<>"" Then If wShell.AppActivate(ix.Document.title) Then Exit For
LocationURL=ix.LocationURL
If Left(LocationURL,8)="file:///" Then
LocationURL=Replace(Uri.UnescapeDataString(Mid(LocationURL,9)),"/","\")
End If
If wShell.AppActivate(LocationURL) Then Exit For
End If
ix=Nothing
Next
If ix Is Nothing Then
TabActivate="Not Found 2"
Exit Function
End If
For Each ix In Shell.Windows()
If ix.HWND=ie.HWND Then
wShell.SendKeys("^{tab}")
Threading.Thread.Sleep(100)
If wShell.AppActivate(ie.Document.title) Then
TabActivate=True
Exit Function
End If
End If
Next
TabActivate="Not Found 3"
End Function
« バッチファイルで文字色と背景色を変えて文字列をECHOする。 | トップページ | ファイル名にDEL文字が使える! »