找回密码
 加入
搜索
查看: 4126|回复: 13

[AU3基础] 这个IF语句怎么错了

 火.. [复制链接]
发表于 2011-4-4 10:24:56 | 显示全部楼层 |阅读模式
安装C++2008   如果没安装下面的代码还能用,如果出现替换窗口,ELSEIF后面的就不执行了
哪位大虾帮下忙,搞好久了  都不行  窗口和标题都是对的
Dim $bt = "Microsoft Visual C++ 2008 Redistributable Setup"
Run("C2008sp1.exe")
If WinWaitActive($bt, "Welcome to Microsoft Visual") Then
        ControlClick($bt, "Welcome to Microsoft Visual", "Button12")
        WinWaitActive($bt, "Be sure to carefully read and understand all the rights and ")
        ControlClick($bt, "Be sure to carefully read and understand all the rights and ", "Button11")
        ControlClick($bt, "Be sure to carefully read and understand all the rights and ", "Button8")
        WinWaitActive($bt, "It is highly recommended that you download and")
        ControlClick($bt, "It is highly recommended that you download and", "Button2")
ElseIf WinWaitActive($bt, "Select one of the options below") Then
        ControlClick($bt, "Select one of the options below", "Button9")
        ControlClick($bt, "Select one of the options below", "Button7")
        WinWaitActive($bt, "Setup Complete")
ElseIf WinWaitActive($bt, "Error: Another instance of setup is running") Then
        ControlClick($bt, "Error: Another instance of setup is running", "Button11")
EndIf
Exit
发表于 2011-4-4 10:41:57 | 显示全部楼层
WinWaitActive是个动词,winexists判断窗口是否存在不好吗?
发表于 2011-4-4 10:49:00 | 显示全部楼层
主要是winexists得有个时间问题吧
发表于 2011-4-4 10:54:35 | 显示全部楼层
试试我的想法
Dim $bt = "Microsoft Visual C++ 2008 Redistributable Setup",$a=0

Run("C2008sp1.exe")

Do
        Sleep(1000)
        If WinExists($bt, "Welcome to Microsoft Visual") Then $a=1
        If WinExists($bt, "Select one of the options below") Then $a=2
        If WinExists($bt, "Error: Another instance of setup is running") Then $a=3
        
Until $a<>0 


If $a=1 Then
                WinActivate($bt, "Welcome to Microsoft Visual")
        ControlClick($bt, "Welcome to Microsoft Visual", "Button12")

        WinWaitActive($bt, "Be sure to carefully read and understand all the rights and ")

        ControlClick($bt, "Be sure to carefully read and understand all the rights and ", "Button11")

        ControlClick($bt, "Be sure to carefully read and understand all the rights and ", "Button8")

        WinWaitActive($bt, "It is highly recommended that you download and")

        ControlClick($bt, "It is highly recommended that you download and", "Button2")

ElseIf $a=2 Then
                WinActivate($bt, "Select one of the options below")
        ControlClick($bt, "Select one of the options below", "Button9")

        ControlClick($bt, "Select one of the options below", "Button7")

        WinWaitActive($bt, "Setup Complete")

ElseIf $a=3 Then
                WinActivate($bt, "Error: Another instance of setup is running")
        ControlClick($bt, "Error: Another instance of setup is running", "Button11")

EndIf

Exit
发表于 2011-4-4 10:58:40 | 显示全部楼层
"Welcome to Microsoft Visual"和"Select one of the options below"同级?
发表于 2011-4-4 11:04:41 | 显示全部楼层
本帖最后由 smady 于 2011-4-5 16:53 编辑
主要是winexists得有个时间问题吧
dearmb 发表于 2011-4-4 10:49



    这样怎样?
Dim $bt = "Microsoft Visual C++ 2008 Redistributable Setup"
Run("C2008sp1.exe")
sleep(1000)
if winexists($bt, "Error: Another instance of setup is running") Then
        ControlClick($bt, "Error: Another instance of setup is running", "Button11")
elseif  Winexists($bt, "Welcome to Microsoft Visual") Then
        ControlClick($bt, "Welcome to Microsoft Visual", "Button12")
        WinWaitActive($bt, "Be sure to carefully read and understand all the rights and ")
        ControlClick($bt, "Be sure to carefully read and understand all the rights and ", "Button11")
        ControlClick($bt, "Be sure to carefully read and understand all the rights and ", "Button8")
        WinWaitActive($bt, "It is highly recommended that you download and")
        ControlClick($bt, "It is highly recommended that you download and", "Button2")
WinWaitActive($bt, "Select one of the options below")
        ControlClick($bt, "Select one of the options below", "Button9")
        ControlClick($bt, "Select one of the options below", "Button7")
        WinWaitActive($bt, "Setup Complete")
 endif  
发表于 2011-4-4 11:10:21 | 显示全部楼层
$bt是你在刚开始定义的,并且你函数里也没让它变呐,当然一直都不变呐
我感觉我帮你改那个应该可以吧,你试试啊
发表于 2011-4-4 11:12:58 | 显示全部楼层
这样怎样?
Dim $bt = "Microsoft Visual C++ 2008 Redistributable Setup"
Run("C2008sp1.exe ...
smady 发表于 2011-4-4 11:04



    你这样写,如果窗口1秒以上出现,应该就不好使了吧
 楼主| 发表于 2011-4-4 11:51:49 | 显示全部楼层
谢谢你们  搞定了  下面的经过测试可行
Dim $bt = "Microsoft Visual C++ 2008 Redistributable Setup"
Run("C2008sp1.exe")
If WinExists($bt, "Welcome to Microsoft Visual") Then;如果检测到窗口 则运行
        WinWaitActive($bt, "Welcome to Microsoft Visual")
        ControlClick($bt, "Welcome to Microsoft Visual", "Button12")
        WinWaitActive($bt, "Be sure to carefully read and understand all the rights and ")
        ControlClick($bt, "Be sure to carefully read and understand all the rights and ", "Button11")
        ControlClick($bt, "Be sure to carefully read and understand all the rights and ", "Button8")
        WinWaitActive($bt, "It is highly recommended that you download and")
        ControlClick($bt, "It is highly recommended that you download and", "Button2")
        Exit
ElseIf WinWaitActive($bt, "Select one of the options below") Then
        ControlClick($bt, "Select one of the options below", "Button9")
        ControlClick($bt, "Select one of the options below", "Button7")
        WinWaitActive($bt, "Setup Complete")
        ControlClick($bt, "Setup Complete", "Button2")
        Exit
ElseIf WinWaitActive($bt, "Error: Another instance of setup is running") Then
        ControlClick($bt, "Error: Another instance of setup is running", "Button11")
        Exit
EndIf
Exit
发表于 2011-4-4 21:39:47 | 显示全部楼层
学习一下,学习一下
发表于 2011-4-4 22:58:06 | 显示全部楼层
解决了就好。
发表于 2011-4-8 12:51:32 | 显示全部楼层
很好的,学习了。
发表于 2011-4-8 16:32:02 | 显示全部楼层
学习1下,学习1下
 楼主| 发表于 2011-4-13 20:47:46 | 显示全部楼层
2楼  谢谢  解决了
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-10-2 08:29 , Processed in 0.078954 second(s), 19 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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