不是像下面这句一样根据窗口标题来判断
hwnd1 = FindWindow("IEFrame", "百度——全球最大中文搜索引擎 - Microsoft Internet Explorer") 
我想根据ie窗口的地址栏里的地址来判断网页是不是百度,应该咋写?最好说详细点 我很菜!谢谢

解决方案 »

  1.   

    IE地址栏的句柄是可以通过枚举IE子窗口枚举到,地址栏的类名是Edit(IE7版本)。
      

  2.   

    Option Explicit
    Private Sub Command1_Click()   Text1.Text = ""
       EnumWindows AddressOf EnumProc, 0
       If Text1.Text = "" Then Text1.Text = "没有启动 IE 浏览器"
    End Sub注:IE8用不了
      

  3.   

    首先打开VB,建立一个新工程,点击菜单 Projects | References 项,在Available References 列表中选择
    'Microsoft Internet Controls项将Internet对象引用介入到工程中。添加一个ListBox到Form1,然后在Form1中添加上面代码
      

  4.   

    Private Sub Command1_Click()
    Dim objShell, objWindows, objIE, strURL
    strURL = "http://www.baidu.com"
    Set objShell = CreateObject("Shell.Application") 'New ShellWindows
    Set objWindows = objShell.Windows For Each objIE In objWindows '枚举所有已打开的ie和explore窗口
    If LCase(Right(objIE.FullName, 13)) = "\iexplore.exe" Then '如果是ie窗口        
    If (LCase(objIE.LocationURL) = strURL) Or _
    (LCase(Left(objIE.LocationURL, Len(strURL) + 1)) = strURL + "/") Then '根据网址进行判断
       MsgBox "有"
       Exit Sub
    End If
    End If
    Next

    Set objIE = Nothing
    Set objWindows = Nothing
    Set objShell = Nothing

    MsgBox "没有"
    End Sub