找回密码
 加入
搜索
查看: 1228|回复: 3

循环中如何让某一小项只执行一次

[复制链接]
发表于 2009-6-26 11:40:54 | 显示全部楼层 |阅读模式
本帖最后由 faceyao 于 2009-6-26 15:39 编辑
while 1

    if WinExists("aaa") then
    
    msgbox(0,"",a存在)

    endif

     if WinExists("bbb") then
    
      msgbox(0,"",b存在)

     endif

     if WinExists("ccc") then
    
      msgbox(0,"",c存在)

      endif

sleep(44000)

WEnd
就是想要假如a存在,并msgbox弹出a存在后,以后就不再对a是否存在做检测了(a不能关闭)

也就是假如上次检测到了a存在,并且发出msgbox消息后,循环后如果第二次检测到a存在,就不再msgbox发出提示(不能对a窗口进行关闭处理)

请问这个循环语句该怎么写
发表于 2009-6-26 12:09:57 | 显示全部楼层
$is_a = 1
while 1

    if WinExists("aaa") And $is_a then
    
    msgbox(0,"",a存在)
        $is_a = 0

    endif

     if WinExists("bbb") then
    
      msgbox(0,"",b存在)

     endif

     if WinExists("ccc") then
    
      msgbox(0,"",c存在)

      endif

sleep(44000)

WEnd
 楼主| 发表于 2009-6-26 12:37:51 | 显示全部楼层
谢谢楼上,按您的代码ok了,就不知道是什么原理,呵呵
发表于 2009-6-26 13:28:44 | 显示全部楼层
先自定义变量$is_a = 1
当WinExists("aaa") And $is_a 条件满足就执行并同时修改$is_a =0
这样再进入循环$is_a =0,WinExists("aaa") And $is_a 这一段判断条件无法成立
自然就不会再执行第一次的代码了
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-5-3 12:49 , Processed in 0.072693 second(s), 19 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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