524443834 发表于 2011-4-4 10:24:56

这个IF语句怎么错了

安装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

smady 发表于 2011-4-4 10:41:57

WinWaitActive是个动词,winexists判断窗口是否存在不好吗?

dearmb 发表于 2011-4-4 10:49:00

主要是winexists得有个时间问题吧

dearmb 发表于 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

3mile 发表于 2011-4-4 10:58:40

"Welcome to Microsoft Visual"和"Select one of the options below"同级?

smady 发表于 2011-4-4 11:04:41

本帖最后由 smady 于 2011-4-5 16:53 编辑

主要是winexists得有个时间问题吧
dearmb 发表于 2011-4-4 10:49 http://www.autoitx.com/images/common/back.gif


    这样怎样?
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")
elseifWinexists($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  

dearmb 发表于 2011-4-4 11:10:21

$bt是你在刚开始定义的,并且你函数里也没让它变呐,当然一直都不变呐
我感觉我帮你改那个应该可以吧,你试试啊

dearmb 发表于 2011-4-4 11:12:58

这样怎样?
Dim $bt = "Microsoft Visual C++ 2008 Redistributable Setup"
Run("C2008sp1.exe ...
smady 发表于 2011-4-4 11:04 http://www.autoitx.com/images/common/back.gif


    你这样写,如果窗口1秒以上出现,应该就不好使了吧

524443834 发表于 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

kadingxiaodi 发表于 2011-4-4 21:39:47

学习一下,学习一下

zitoy 发表于 2011-4-4 22:58:06

解决了就好。

guang19831217 发表于 2011-4-8 12:51:32

很好的,学习了。

0633zhou 发表于 2011-4-8 16:32:02

学习1下,学习1下

524443834 发表于 2011-4-13 20:47:46

2楼谢谢解决了
页: [1]
查看完整版本: 这个IF语句怎么错了