找回密码
 加入
搜索
查看: 2928|回复: 7

[系统综合] Error:请求动作失败(请求于对象),大家帮帮忙!

  [复制链接]
发表于 2010-10-31 14:51:44 | 显示全部楼层 |阅读模式
本帖最后由 zwanlei 于 2010-10-31 15:51 编辑

代码如下:
#NoTrayIcon
#Region ;**** 参数创建于 ACNWrapper_GUI ****
#AutoIt3Wrapper_icon=D:\tools\ICO\The Icons\Network.ico
#AutoIt3Wrapper_outfile=urltz.exe
#EndRegion ;**** 参数创建于 ACNWrapper_GUI ****
Opt("MustDeclareVars",1)
;au3监控IE地址栏网址自动路转
Global $ConfigFile = @ScriptDir & "\urltz.ini"
Global $oShell,$oShellWindows,$SourceUrls,$TargetURL
Global $DefaultTargetURL = "http://www.hao123.com"
HotKeySet("#{F9}","_Exit")

$SourceUrls = IniReadSection($ConfigFile,"SourceURL")
$TargetURL = IniRead($ConfigFile,"TargetURL","TargetURL",$DefaultTargetURL)

While 1
Sleep(500)
$oShell = ObjCreate('shell.application') 
$oShellWindows = $oShell.windows 
For $Window In $oShellWindows
        Local $i
        If StringRight($Window.FullName, 12) = 'iexplore.exe' Then
        ;If StringRight($Window.FullName, 12) = '360se.exe' Then
                For $i = 1 To $SourceUrls[0][0]
                        If $Window.locationurl=$SourceUrls[$i][1] or $Window.locationurl=$SourceUrls[$i][1] & "/" Then $Window.navigate($TargetURL)
                Next
        EndIf
Next
WEnd 

Func _Exit()
        Exit
EndFunc
在执行时,有时(如将IE窗口关闭)会弹出错误提示:
Line 19 (File "F:\urltz.exe")
Error:请求动作失败(请求于对象)

各位大侠们,高手们,帮帮小弟看如何才能避免这个错误提示啊?
发表于 2010-10-31 15:09:51 | 显示全部楼层
第19行:
If $Window.locationurl=$SourceUrls[$i][1] or $Window.locationurl=$SourceUrls[$i][1] & "/" Then $Window.navigate($TargetURL)

$Window.locationurl
我记得变量中间使用小数点会有问题的,换成“_”,试试看
 楼主| 发表于 2010-10-31 15:49:55 | 显示全部楼层
回复 2# yhxhappy

这里点不能换成"_", 因为这里点不是变量名的一部分  ,是指$window的locationurl属性.
高手们继续帮忙啊
 楼主| 发表于 2010-11-1 11:37:47 | 显示全部楼层
自己顶,高手帮忙啊
发表于 2010-11-1 13:19:01 | 显示全部楼层
新手不知道问题的所在。
发表于 2010-11-1 14:12:56 | 显示全部楼层
呵呵 不懂,跟着学习
发表于 2010-11-1 15:42:25 | 显示全部楼层
应该出错在这里面。。去看看是不是你的数组有问题啊。

                For $i = 1 To $SourceUrls[0][0]
                        If $Window.locationurl=$SourceUrls[$i][1] or $Window.locationurl=$SourceUrls[$i][1] & "/" Then $Window.navigate($TargetURL)
                Next
 楼主| 发表于 2010-11-2 07:25:00 | 显示全部楼层
本帖最后由 zwanlei 于 2010-11-2 07:36 编辑

数组没有问题,算了,我已经找到了另外的方法达到这个目的,谢谢大家都帮助!

我新写的代码发到源码区了:http://www.autoitx.com/thread-19400-1-1.html
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-5-21 08:08 , Processed in 0.080124 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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