找回密码
 加入
搜索
查看: 3364|回复: 9

[AU3基础] 帮忙解决一个文本闪烁的问题

  [复制链接]
发表于 2015-12-21 17:02:46 | 显示全部楼层 |阅读模式
#include <File.au3>
#include <Array.au3>
#include <GUIListView.au3>
#include <Timers.au3>

;Form1
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

;Form GetKeyword新增
#include <GUIListBox.au3>

;进度条
#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>


Global $ProgressTitle
$Step123="正在计算,请耐心等待!"
GUICreate("--- 耐心等待,若需终止请右下角或任务管理器 ---", 280, 100, 100, 200,$WS_BORDER,$WS_EX_TOPMOST)
$progressbar1 = GUICtrlCreateProgress(10, 10, 255, 20, $PBS_SMOOTH)
$Label = GUICtrlCreateLabel($Step123, 10, 50, 255, 20, $SS_CENTER)
GUISetState(@SW_HIDE); = 隐藏窗口


Global $i,$j
$j=9000
$ProgressTitle="1"
For $i=0 to $j
        Processbar($i,$j,$ProgressTitle)
Next
MsgBox(262144,"","The end")
GUISetState(@SW_HIDE)



Func Processbar($start,$end,$ProgressTitle)
        $jindu=Int($start/$end*10000)/100
;~         MsgBox(262144,"进度",$start & "-" & $end & "-" & $jindu)
        GUICtrlSetData($Label,$ProgressTitle & "阶段进度..." & $jindu & " % 剩余项:"& $end-$start)
        GUICtrlSetData($progressbar1,$jindu)
        GUISetState(@SW_SHOW );@SW_HIDE = 隐藏窗口
EndFunc
下面的进度会不停闪烁,请问怎么修改一下?
发表于 2015-12-22 08:38:59 | 显示全部楼层
給個代碼你研究
#include <GUIConstantsEx.au3> 
$Form = GUICreate("倒計時&進度條示例", 280, 230, 195, 125)
GUISetState(@SW_SHOW)
Global $time = 8
$Label5 = GUICtrlCreateLabel($time & "秒后自動放棄操作!", 30, 168, 200,25)
GUICtrlSetColor($Label5, 0x8A2BE2)
GUICtrlSetFont($Label5, 10)
$Progress1 = GUICtrlCreateProgress(20, 195, 230, 10)
GUISetState(@SW_SHOW)
AdlibEnable("_timer", 1000)
Func _timer()
        $time -= 1
        GUICtrlSetData($Label5,$time & "秒后自動放棄操作!!")
        GUICtrlSetData($Progress1, (10 - $time) / 0.1)
        If $time <= 0 Then Exit
EndFunc
While 1
        $nMsg = GUIGetMsg()
        Select
                Case $nMsg = $GUI_EVENT_CLOSE 
                        DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $Form, "int", 500, "long", 0x00090000)
                        Exit
                Case $nMsg = $GUI_EVENT_PRIMARYDOWN
                        AdlibDisable()
                        GUICtrlSetState($Progress1,$GUI_DISABLE )
        EndSelect
WEnd
发表于 2015-12-22 08:46:22 | 显示全部楼层
或许加上个sleep会好一些
 楼主| 发表于 2015-12-22 16:29:51 | 显示全部楼层
回复 3# haijie1223


    就是不想加sleep,因为程序处理的数据量很大,搜索每天的FTP_LOG,有的文件(txt)长达20万行
 楼主| 发表于 2015-12-22 16:48:35 | 显示全部楼层
回复 2# txen548


    谢谢,回家再慢慢扒出程序试试效果,哈哈
发表于 2015-12-22 17:39:23 | 显示全部楼层
回复 4# 不是小灵通


    那就分开设置标签控件,只闪烁变化的数字。
 楼主| 发表于 2015-12-23 08:58:16 | 显示全部楼层
本帖最后由 不是小灵通 于 2015-12-23 10:52 编辑

回复 6# haijie1223


    是的,这个确实可以,做成多个标签就只是闪烁数字部分了,不过暂时还没这样做,谢谢

StringFormat函数倒是可以解决末尾为0时,位数不一致的问题:
StringFormat( "%.2f",12.3)=12.30
 楼主| 发表于 2015-12-23 11:01:24 | 显示全部楼层
还有个办法是,人为的增大显示的时间间隔,比如说在循环体中,进行一次判断,每100或更大次才变化一次参数,如:

For $i=0 to $j
       If $i/200=Int($i/200)Then Processbar($i,$j,$ProgressTitle)
Next
发表于 2015-12-23 11:28:44 | 显示全部楼层
sleep一下比较好吧
 楼主| 发表于 2015-12-23 13:17:52 | 显示全部楼层
回复 9# xz00311


    不行,sleep会导致程序运行变得极其缓慢,因为处理的行数太多了,测试了一下20万行的文件,要么效果不明显,要么耗时不能接受了
    我倒是在考虑,每隔一定时间才刷新一次GUI,但是又产生了其他问题,诸如进度条在后期到不了100%的位置之类的,当然可以通过由循环变量的末尾值来判断,但仍需要增加运算时间,所以还在总结
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-9-29 00:22 , Processed in 0.097801 second(s), 21 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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