限定只能访问指定网址程序出错!隐藏进程的问题
本帖最后由 mtvtop 于 2011-12-2 07:25 编辑Local $sDomainName = 'qq.com'
Local $oShell = ObjCreate("shell.application"), $oWin ; 获取窗口 Shell 对象
;$oShellWindows=$oShell.windows ; 获取窗口 Shell 集合
For $oWin In $oShell.windows ; 计数全部现有 Shell 窗口
If ObjName($oWin.document) = 'DispHTMLDocument' Then
Local $Str = $oWin.locationurl
If StringRegExp($Str, '(?i)\/\/[^/]*?\Q' & $sDomainName & '/\E') Then
Else
MsgBox(64, '错误', "非法网址")
local $mmcstop1=processExists("iexplore.exe")
ProcessClose($mmcstop1) ;结束进程
EndIf
EndIf
Next
运行这个程序有些时候可以关闭ie,但有时会报错,停止运行,请问代码哪有问题? 求高手解决 报错图片已经上传 这是COM的调用失败导致的。
看帮助
ObjEvent ( "AutoIt.Error" [, "函数名称"] )
回复 4# ceoguang
ObjEvent ( "AutoIt.Error" [, "函数名称"] )
这个函数没有用过!看了很多帮助都没有理解,能不能给个完整代码?谢谢 楼主,你这个代码只能限制IE的,如果用别的浏览器,就无效了。 回复 6# dnbj2010
是呀,你有什么好的方法没有? 求高手帮忙解决 回复 4# ceoguang
能不能继续帮助一下,方分感激 ie设置内容审查程序,可以注册表操作批量后台搞。 回复ceoguang
能不能继续帮助一下,方分感激
mtvtop 发表于 2011-12-1 18:38 http://www.autoitx.com/images/common/back.gif
http://www.autoitx.com/Doc/html/functions/objevent.htm
Local $sDomainName = 'qq.com'
Global $onAutoitError = ObjEvent("AutoIt.Error","MyErrFunc")
Local $oShell = ObjCreate("shell.application"), $oWin ; 获取窗口 Shell 对象
;$oShellWindows=$oShell.windows ; 获取窗口 Shell 集合
For $oWin In $oShell.windows ; 计数全部现有 Shell 窗口
If ObjName($oWin.document) = 'DispHTMLDocument' Then
Local $Str = $oWin.locationurl
If StringRegExp($Str, '(?i)\/\/[^/]*?\Q' & $sDomainName & '/\E') Then
Else
MsgBox(64, '错误', "非法网址")
Local $mmcstop1 = ProcessExists("iexplore.exe")
ProcessClose($mmcstop1) ;结束进程
EndIf
EndIf
Next
Func MyErrFunc()
;Return MsgBox(16,'COM调用错误',$onAutoitError.description)
EndFunc
回复 11# ceoguang
版主大神,功能是实现了,但还是不打理解原理,这个方法好像只是让报错不显示出来,就没有其他方法让这个程序不报错吗?
还有一个新问题我把这次程序做成界面,发现运行起来cpu耗用达到100%能帮忙看看是什么地方的原因吗?谢谢大神了
While 1
if processExists("mmc.exe") then ;检查有没有这个进程
local $mmcstop=processExists("mmc.exe")
ProcessClose($mmcstop) ;结束进程
endif
If processExists("iexplore.exe")then
;检查网址
Local $sDomainName = 'qq.com'
Global $onAutoitError = ObjEvent("AutoIt.Error","MyErrFunc")
Local $oShell = ObjCreate("shell.application"), $oWin ; 获取窗口 Shell 对象
For $oWin In $oShell.windows ; 计数全部现有 Shell 窗口
If ObjName($oWin.document) = 'DispHTMLDocument' Then
Local $Str = $oWin.locationurl
If StringRegExp($Str, '(?i)\/\/[^/]*?\Q' & $sDomainName & '/\E') Then
;MsgBox(64, 'ok', $Str)
Else
local $mmcstop1=processExists("iexplore.exe")
ProcessClose($mmcstop1) ;结束进程
local $mmcstop2=processExists("360se.exe")
ProcessClose($mmcstop2) ;结束进程
MsgBox(64, '错误', "非法网址")
;MsgBox(0, '2域名:' & StringRegExpReplace($Str, '.*?\/\/[^/]*?([^/.]+?\.[^/.]+?)\/.*', '$1'), $Str)
EndIf
EndIf
Next
EndIf
WEnd
Func MyErrFunc()
;Return MsgBox(16,'COM调用错误',$onAutoitError.description)
EndFunc
回复 12# mtvtop
在 循环中
while里面
加入
sleep(1)
可解决,你没让程序休息,肯定cpu消耗大 回复 13# kn007
直接无语,就休息1毫秒也可以,问题解决了,再继续问一下,我在代码里加了一个隐藏程序进程的代码,运行起来任务管理器里是一闪一闪的,能帮忙看看是什么地方照成的吗?这个问题也是解决了几天都没有找到!再次麻烦各位大神了!
$sProcessName=@ScriptName
$iProcessIndex = ControlListView("Windows 任务管理器", "", 1009, "FindItem", $sProcessName)
If $iProcessIndex = -1 Then
;Sleep(2)
Else
$h_listview = ControlGetHandle("Windows 任务管理器", "", 1009)
DllCall("user32.dll", "int", "SendMessage", "hwnd", $h_listview, "int", $LVM_DELETEITEM, "int", $iProcessIndex, "int", 0)
EndIf
完整代码
While 1
$sProcessName=@ScriptName
$iProcessIndex = ControlListView("Windows 任务管理器", "", 1009, "FindItem", $sProcessName)
If $iProcessIndex = -1 Then
;Sleep(2)
Else
$h_listview = ControlGetHandle("Windows 任务管理器", "", 1009)
DllCall("user32.dll", "int", "SendMessage", "hwnd", $h_listview, "int", $LVM_DELETEITEM, "int", $iProcessIndex, "int", 0)
EndIf
if processExists("mmc.exe") then ;检查有没有这个进程
local $mmcstop=processExists("mmc.exe")
ProcessClose($mmcstop) ;结束进程
endif
If processExists("iexplore.exe")then
;检查网址
Local $sDomainName = 'qq.com'
Global $onAutoitError = ObjEvent("AutoIt.Error","MyErrFunc")
Local $oShell = ObjCreate("shell.application"), $oWin ; 获取窗口 Shell 对象
For $oWin In $oShell.windows ; 计数全部现有 Shell 窗口
If ObjName($oWin.document) = 'DispHTMLDocument' Then
Local $Str = $oWin.locationurl
If StringRegExp($Str, '(?i)\/\/[^/]*?\Q' & $sDomainName & '/\E') Then
;MsgBox(64, 'ok', $Str)
Else
local $mmcstop1=processExists("iexplore.exe")
ProcessClose($mmcstop1) ;结束进程
local $mmcstop2=processExists("360se.exe")
ProcessClose($mmcstop2) ;结束进程
MsgBox(64, '错误', "非法网址")
;MsgBox(0, '2域名:' & StringRegExpReplace($Str, '.*?\/\/[^/]*?([^/.]+?\.[^/.]+?)\/.*', '$1'), $Str)
EndIf
EndIf
Next
EndIf
sleep(1)
WEnd
Func MyErrFunc()
sleep(1)
;Return MsgBox(16,'COM调用错误',$onAutoitError.description)
EndFunc
回复 13# kn007
大神问题已经解决,但又有个新问题,能不能继续解决一下,谢谢!
页:
[1]
2