找回密码
 加入
搜索
查看: 2243|回复: 4

[IE类操作] 请问如何提取ie地址栏里的网址域名?[已解决]

[复制链接]
发表于 2011-11-29 16:36:06 | 显示全部楼层 |阅读模式
本帖最后由 mtvtop 于 2011-12-3 00:26 编辑

我ie地址访问的是:http://news.qq.com/a/20111129/000164.htm
请问要如何写au3,程序只有检测域名是qq.com的才可以运行?
        $oShell=ObjCreate("shell.application")

        For $oWin In $oShell.windows

        If ObjName($oWin.document)=="DispHTMLDocument" Then
                If $oWin.locationurl<>"http://www.qq.com/" Then

MsgBox(64,"1","ok")



                        EndIf
                                
                EndIf
                

        Next
发表于 2011-11-29 17:01:40 | 显示全部楼层
If StringRegExp($oWin.locationurl, '(?i)\/\/[^/]*?qq\.com\/') Then
发表于 2011-11-29 17:20:30 | 显示全部楼层
本帖最后由 afan 于 2011-11-29 17:43 编辑
Local $sDomainName = 'QQ.com'
Local $oShell = ObjCreate("shell.application"), $oWin
For $oWin In $oShell.windows
        If ObjName($oWin.document) = 'DispHTMLDocument' Then
                Local $Str = $oWin.locationurl
                If StringRegExp($Str, '(?i)\/\/[^/]*?\Q' & $sDomainName & '/\E') Then
                        MsgBox(64, 'ok', $Str)
                Else
                        MsgBox(0, '2域名:' & StringRegExpReplace($Str, '.*?\/\/[^/]*?([^/.]+?\.[^/.]+?)\/.*', '$1'), $Str)
                EndIf
        EndIf
Next
发表于 2011-11-29 21:52:53 | 显示全部楼层
楼上的代码写的比较规整
 楼主| 发表于 2011-11-29 22:20:29 | 显示全部楼层
回复 3# afan

实在感谢
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-6-11 02:22 , Processed in 0.083450 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表