简体   繁体   中英

VB.Net Check if a website is open in IE

I'm searching if it possible to check if some website for eg google.com is opened in IE. I have already this code but it was only for checking if IE is open and to close it, But it's not working.

Dim processCollection() As Process
processCollection = Process.GetProcessesByName("iexplore.exe")

If processCollection.Count > 0 Then
   For Each process As Process In processCollection
      process.Dispose()
   Next
   Return False
Else
   MessageBox.Show("Ie is now close", "IE")
End If

Thanks for helping

Follow these steps

  1. Add Microsoft Internet Controls reference to project. It is available in COM. It will appear as SHDocVw

在此处输入图片说明

  1. Now in property explorer of SHDocVw change Embedded InterOp types to false 在此处输入图片说明

  2. Save , Clean and Rebuild the project.

  3. Import SHDocVw in your code.
  4. Use below piece of code

     For Each ie As InternetExplorer In New ShellWindows() Console.WriteLine(ie.LocationURL()) Next 
    Function InternetExplorerRunning()
    For Each ie As InternetExplorer In New ShellWindows()
        Dim OpenWebsite As String
        OpenWebsite = ie
        If OpenWebsite = "google.com" Then
            MsgBox("Google is open")
        End If
    Next
End Function

This code is in a timer.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM