找回密码
 加入
搜索
查看: 2355|回复: 5

[AU3基础] 关于字体滚动(已解决)

[复制链接]
发表于 2010-9-21 17:55:43 | 显示全部楼层 |阅读模式
本帖最后由 shenrenba 于 2010-9-21 21:43 编辑

帮忙修改下  问题1:滚动不自然  问题2:如何获取字符占的总长度(不是字符的长度,比如像窗体的宽度100这样的数字)
要是能有其他精简的更好


#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
Global $y = 500
#Region ### START Koda GUI section ### Form=
GUICreate("测试", 500, 20, -1, 20, $WS_VISIBLE + $WS_POPUP, $WS_EX_TOOLWINDOW)
WinSetOnTop("测试", "", 1)
WinSetTrans("测试", "", 170)
$Label1 = GUICtrlCreateLabel("只是测试,即将开始", 0, 0, 500, 20)
GUICtrlSetColor(-1, 0xff0000)
GUISetState()
#EndRegion ### END Koda GUI section ###

AdlibRegister("gd", 300)

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE

Func gd()
                Global $a
                Local $sData = InetRead('http://www.verycd.com/statics/title.saying')
                Local $sR = StringRegExp(BinaryToString($sData, 4), "'(.+?)\'", 3)
                For $a = 0 To UBound($sR) - 2
                        $y = $y - 3
                        GUICtrlSetPos($Label1, $y, 0)
                        If $y < -200 Then
                                $y = 500
                                GUICtrlSetData($Label1, $sR[$a])
                        EndIf
                Next
EndFunc   ;==>gd
发表于 2010-9-21 19:36:36 | 显示全部楼层
在读取网页源代码的时候会浪费一些时间,如果网速不好的话会使字幕滚动不自然,做了一下修改,你现优化一下吧

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
Global $y = 500
Global $sR 
 Global $a
#Region ### START Koda GUI section ### Form=
GUICreate("测试", 500, 20, -1, 20, $WS_VISIBLE + $WS_POPUP, $WS_EX_TOOLWINDOW)
WinSetOnTop("测试", "", 1)
WinSetTrans("测试", "", 170)
$Label1 = GUICtrlCreateLabel("只是测试,即将开始", 0, 0, 500, 20)
GUICtrlSetColor(-1, 0xff0000)
GUISetState()
#EndRegion ### END Koda GUI section ###
 jj()
AdlibRegister("gd", 100)
 
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
 Func jj()

                Local $sData = InetRead('http://www.verycd.com/statics/title.saying')
                Global $sR = StringRegExp(BinaryToString($sData, 4), "'(.+?)\'", 3)         
 EndFunc
 
Func gd()
               
                For $a = 0 To UBound($sR) - 2
                        $y = $y - 1
                        GUICtrlSetPos($Label1, $y, 0)
                        If $y < -200 Then
                                $y = 500
                jj()
                                GUICtrlSetData($Label1, $sR[$a])
                                                                
                        EndIf
                Next
EndFunc   ;==>gd
Exit

评分

参与人数 1金钱 +20 收起 理由
afan + 20

查看全部评分

发表于 2010-9-21 19:39:09 | 显示全部楼层
关于获取字符总宽,论坛里有这样的例子,尤其是A版还专门写了这方面的函数,你可以查一下
发表于 2010-9-21 19:42:14 | 显示全部楼层
在读取网页源代码的时候会浪费一些时间,如果网速不好的话会使字幕滚动不自然,做了一下修改,你现优化一下 ...
xyold1 发表于 2010-9-21 19:36



    gd() 里面的 for循环不要..
发表于 2010-9-21 19:46:07 | 显示全部楼层
本帖最后由 xyold1 于 2010-9-21 19:59 编辑

回复 4# afan


    没细看,汗

附一修改后的

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
Global $y = 500
Global $sR 
 Global $a=0
#Region ### START Koda GUI section ### Form=
GUICreate("测试", 500, 20, -1, 20, $WS_VISIBLE + $WS_POPUP, $WS_EX_TOOLWINDOW)
WinSetOnTop("测试", "", 1)
WinSetTrans("测试", "", 170)
$Label1 = GUICtrlCreateLabel("只是测试,即将开始", 0, 0, 500, 20)
GUICtrlSetColor(-1, 0xff0000)
GUISetState()
#EndRegion ### END Koda GUI section ###
 jj()
AdlibRegister("gd", 5)
 
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
 Func jj()

                Local $sData = InetRead('http://www.verycd.com/statics/title.saying')
                Global $sR = StringRegExp(BinaryToString($sData, 4), "'(.+?)\'", 3)         
 EndFunc
 
Func gd()
               
;~                 For $a = 0 To UBound($sR) - 2
                        $y = $y - 3
                        GUICtrlSetPos($Label1, $y, 0)
                                                
                        If $y < -200 Then
                                $y = 500
                                                                If $a>UBound($sR) - 2 Then
                                                                        jj()
                                                                        $a=0
                                                                EndIf
                                                                
                                GUICtrlSetData($Label1, $sR[$a])
                                                                $a=$a+1
                        EndIf
;~                 Next
EndFunc   ;==>gd
Exit
发表于 2010-9-22 15:42:27 | 显示全部楼层
用LABEL就是闪动,除非画出来。。
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-5-7 15:48 , Processed in 0.086915 second(s), 27 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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