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

[AU3基础] [已解决]麻烦大神看下guictrlsetdata这个问题

[复制链接]
发表于 2015-10-21 17:46:08 | 显示全部楼层 |阅读模式
本帖最后由 synaspe 于 2015-10-25 10:29 编辑

#include<ButtonConstants.au3>
#include<GUIConstantsEx.au3>
#include<StaticConstants.au3>
#include<WindowsConstants.au3>
#include <GUIConstants.au3>

Local $time = 3, $d = 1
Opt("GUIOnEventMode", 1)

GUICreate("froml",200,200)
GUISetOnEvent($GUI_EVENT_CLOSE,"_Co")

$Button = GUICtrlCreateButton("暂停",20,20,50,30)
GUICtrlSetOnEvent($Button, "_Go")

$La = GUICtrlCreateLabel("123",100,100)
$Lable1 = GUICtrlCreateLabel("123",60,60)
GUISetState(@SW_SHOW)

AdlibRegister("_Timer",1000)
While 1

WEnd

Func _timer()
   If $time = 0 Then _Ao()
          Switch $d
           case 0
                  AdlibUnRegister("_Timer")

           case 1
                  $time -=1
           EndSwitch
           GUICtrlSetData($La,$time)


EndFunc


Func _Go()

   Switch $d
   Case 1
          $d = 0
          GUICtrlSetData($Button,"继续")
   Case 0
          $d = 1
          GUICtrlSetData($Button,"暂停")
          AdlibRegister("_Timer",1000)
EndSwitch

EndFunc


Func _Ao()
   AdlibUnRegister("_Timer")
   GUICtrlSetData ($La,"进行中")
   EndFunc




        Func _Co()
        MsgBox(0,"123",1)
        Exit
EndFunc

GUICtrlSetData ($La,"进行中")这条没反应,我运行的时候也没报错,不知是什么原因,谢谢!
 楼主| 发表于 2015-10-25 10:27:48 | 显示全部楼层
AdlibUnRegister("_timer")
   GUICtrlCreateLabel("正在安装",100,100)
   GUICtrlDelete($La)
自己尝试了几次改成这样也能达到我要的效果,结贴。
发表于 2015-10-25 11:31:05 | 显示全部楼层
Opt("GUIOnEventMode", 1)

Global $time = 10, $d = 1, $Button, $La

GUICreate("froml", 200, 200)
GUISetOnEvent(-3, "_Co")
$Button = GUICtrlCreateButton("暂停", 20, 20, 80, 30)
GUICtrlSetOnEvent($Button, "_Go")
$La = GUICtrlCreateLabel("123", 100, 100, 100)
GUICtrlCreateLabel("xxx", 60, 60)
GUISetState(@SW_SHOW)

AdlibRegister("_Timer", 1000)
While 1
        Sleep(1000)
WEnd

Func _timer()
        If $time = 0 Then Return _Ao()
        Switch $d
                Case 0
                        AdlibUnRegister("_Timer")
                Case 1
                        $time -= 1
        EndSwitch
        GUICtrlSetData($La, $time)
EndFunc   ;==>_timer

Func _Go()
        Switch $d
                Case 1
                        $d = 0
                        GUICtrlSetData($Button, "继续")
                Case 0
                        $d = 1
                        GUICtrlSetData($Button, "暂停")
                        AdlibRegister("_Timer", 1000)
        EndSwitch
EndFunc   ;==>_Go

Func _Ao()
        AdlibUnRegister("_Timer")
        GUICtrlSetData($La, "进行中")
        GUICtrlSetData($Button, "重新开始")
        Dim $time = 10, $d = 0
EndFunc   ;==>_Ao

Func _Co()
        MsgBox(0, "123", 1)
        Exit
EndFunc   ;==>_Co
 楼主| 发表于 2015-11-1 12:09:45 | 显示全部楼层
回复 3# afan


原来加了个Return _Ao(),GUICtrlSetData ($La,"进行中")这条才有反应,谢谢前辈!
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-9-28 22:17 , Processed in 0.082051 second(s), 21 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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