def check_for_popups
@autoit = WIN32OLE.new('AutoItX3.Control')
#
# Do forever - assumes popups could occur anywhere/anytime in your application.
loop do
# Look for window with given title. Give up after 1 second.
ret = @autoit.WinWait('Windows Internet Explorer','',3)
#ret = WinActivate("Windows Internet Explorer","")
#autoit.ControlClick("Windows Internet Explorer","","[CLASS:Button; INSTANCE:1]",2)
puts(ret) #
# If window found, send appropriate keystroke (e.g. {enter}, {Y}, {N}).
if (ret==1) then @autoit.Send("{Enter}") end
#
# Take a rest to avoid chewing up cycles and give another thread a go.
# Then resume the loop.
sleep(3)
end
end
@popups=TC_recorded.new
$popup = Thread.new{@popups.check_for_popups} # start popup handler
at_exit{Thread.kill($popup)}作者: kokahkhk 时间: 2011-6-27 13:43
ret = @autoit.WinWait('Windows Internet Explorer','',3)
改成 @autoit.WinWaitActive("Windows Internet Explorer", "",9)试试,应该能识别的。我们这里经常处理这类popup 可以实现的作者: vkemc 时间: 2011-7-25 14:22