找回密码
 加入
搜索
查看: 1723|回复: 11

[网络通信] [已解决]如何设置一个进度条或者可输入数字项用于调节延时操作?

[复制链接]
发表于 2019-1-13 10:59:55 | 显示全部楼层 |阅读模式
本帖最后由 virgo091 于 2019-1-15 19:36 编辑

大神们,求赐教
重点是 外部可调节延时
发表于 2019-1-14 09:08:33 | 显示全部楼层
路过攒金币!
发表于 2019-1-14 14:25:46 | 显示全部楼层
帖上你的进度条代码,我修改一下
发表于 2019-1-14 17:10:08 | 显示全部楼层
本帖最后由 229989799 于 2019-1-14 17:12 编辑


Example()

Func Example()
    ; 显示一个进度条窗口.
    ProgressOn("进度计算", "每秒增量", "0%")

    ; 更新进度条窗口的每秒进度值.
    For $i = 0 To 100 Step 10 ;例子是从0%开始到100%结束,每秒进10%
        Sleep(1000)
        ProgressSet($i, $i & "%")
    Next

    ; 设置进度条窗口 "子文本" 与 "主文本".
    ProgressSet(100, "完成", "进度状态:")
    Sleep(2000)

    ; 关闭进度窗口.
    ProgressOff()
EndFunc   ;==>Example
发表于 2019-1-14 17:50:08 | 显示全部楼层

#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>
Global $iWait, $Input1
Example()
Func Example()
        GUICreate("进度条控件 GUI", 270, 100, -1, 200)
        Local $idButton = GUICtrlCreateButton("启动", 75, 70, 70, 20)
        $Label = GUICtrlCreateLabel('选择延时', 10, 12, 50, 22)
        $Input1 = GUICtrlCreateInput("200", 65, 10, 70, 17)
        GUISetState(@SW_SHOW)
        While 1
                $nMsg = GUIGetMsg()
                Switch $nMsg
                        Case -3
                                Exit
                        Case $idButton
                                Examplea()
                EndSwitch
        WEnd
EndFunc   ;==>Example
Func Examplea()
        $iWait = GUICtrlRead($Input1)
        ; 显示一个进度条窗口.
        ProgressOn("进度计算", "每秒增量", "0%", -1, -1)
        ; 更新进度条窗口的每秒进度值.
        For $i = 0 To 100 Step 10 ;例子是从0%开始到100%结束,每秒进10%
                Sleep($iWait)
                ProgressSet($i, $i & "%")
        Next
        ; 设置进度条窗口 "子文本" 与 "主文本".
        ProgressSet(100, "完成", "进度状态:")
        Sleep($iWait)
        ; 关闭进度窗口.
        ProgressOff()
EndFunc   ;==>Examplea
发表于 2019-1-15 10:20:28 | 显示全部楼层
看看,学习下
 楼主| 发表于 2019-1-15 19:26:28 | 显示全部楼层

谢谢指点!学习了
 楼主| 发表于 2019-1-15 19:32:44 | 显示全部楼层
chzj589 发表于 2019-1-14 17:50
[au3]
#include
#include

多谢大神指导
其实在这例子中主要是对$nMsg = GUIGetMsg()的不理解
看到你的例子重新了解了一下跟 #include <GUIConstantsEx.au3> 相关,不知是否正确
如果是这样GUIConstantsEx.au3里面相关的内容在哪里能找到?
发表于 2019-1-15 21:01:19 | 显示全部楼层
virgo091 发表于 2019-1-15 19:32
多谢大神指导
其实在这例子中主要是对$nMsg = GUIGetMsg()的不理解
看到你的例子重新了解了一下跟 #inc ...

循环模式:#include <GUIConstantsEx.au3>
$Button = GUICtrlCreateButton('关闭', 161, 9, 30, 15)
While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case -3
                        Exit
                Case  $Button
        EndSwitch
WEnd
事件模式:
#include <GUIConstantsEx.au3>
Opt('GUIOnEventMode', 1)


While 1
        Sleep(1000)
WEnd

$Button = GUICtrlCreateButton('关闭', 161, 9, 30, 15)
GUICtrlSetOnEvent($Button, "_Button")

与#include <GUIConstantsEx.au3> 无关
打开D:\AutoIt3\Include文件夹,就能查看:GUIConstantsEx.au3
发表于 2019-1-15 21:14:49 | 显示全部楼层
chzj589 发表于 2019-1-15 21:01
循环模式:#include
$Button = GUICtrlCreateButton('关闭', 161, 9, 30, 15)
While 1


代码事件模式:
;-----------------------------------------------------------------


#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>
Opt("GUIOnEventMode", 1)
Global $iWait, $Input1
Example()
While 1
        Sleep(10)
WEnd
Func Example()
GUICreate("进度条控件 GUI", 270, 100, -1, 200)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
Local $idButton = GUICtrlCreateButton("启动", 55, 70, 70, 20)
GUICtrlSetOnEvent(-1, "Examplea")
Local $idButton1 = GUICtrlCreateButton("关闭", 155, 70, 70, 20)
GUICtrlSetOnEvent(-1, "_Off")
$Label = GUICtrlCreateLabel('选择延时', 10, 12, 50, 22)
$Input1 = GUICtrlCreateInput("100", 65, 10, 70, 17)
GUISetState(@SW_SHOW)
#cs
While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case -3
                        Exit
                Case $idButton
                        Examplea()
                Case $idButton1
                        ProgressOff()
        EndSwitch
WEnd
#ce
EndFunc   ;==>Example
Func Examplea()
        $iWait = GUICtrlRead($Input1)
        ; 显示一个进度条窗口.
        ProgressOn("进度计算", "每秒增量", "0%", 870, 200, 16)
        ; 更新进度条窗口的每秒进度值.
        For $i = 0 To 105 Step 1 ;例子是从0%开始到100%结束,每秒进10%
                Sleep($iWait)
                ProgressSet($i, $i & "%")
        Next
        ; 设置进度条窗口 "子文本" 与 "主文本".
        ProgressSet(100, "完成", "进度状态:")
        Sleep($iWait)
        ; 关闭进度窗口.
        ;ProgressOff()
EndFunc   ;==>Examplea
Func _Off()
        ProgressOff()
EndFunc   ;==>Examplea
Func _Exit()
        Exit
EndFunc   ;==>QUIT


发表于 2019-1-17 13:35:38 | 显示全部楼层
路过学习一下 1
 楼主| 发表于 2019-2-4 10:12:34 | 显示全部楼层
chzj589 发表于 2019-1-15 21:14
代码事件模式:
;-----------------------------------------------------------------

学习了,谢谢指导
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-4-27 09:09 , Processed in 0.072513 second(s), 19 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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