找回密码
 加入
搜索
楼主: fuldho

AU3如何实现在窗口中显示循环滚动文字

[复制链接]
发表于 2010-2-4 21:40:50 | 显示全部楼层
哇靠 。真是好想法啊。~太多牛人了。~仰望。。
发表于 2010-2-6 00:04:35 | 显示全部楼层

我也来发个我的作品:
#NoTrayIcon
#Region ;**** 参数创建于 ACNWrapper_GUI ****
#AutoIt3Wrapper_icon=..\17292.ICO\winxp\worldofaqua1\WorldOfAqua1\Aqua OS.ico
#AutoIt3Wrapper_outfile=调用游戏菜单.exe
#AutoIt3Wrapper_Res_Fileversion=0.0.0.0
#EndRegion ;**** 参数创建于 ACNWrapper_GUI ****
#include <GUIConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
$g_szVersion = "调用游戏菜单"
If WinExists($g_szVersion) Then Exit 
AutoItWinSetTitle($g_szVersion)
Opt("GUIOnEventMode", 1)  ; 切换为 OnEvent 模式 
Dim $Dll,$SkincrafterDll="SkinCrafterDll.dll",$SkincrafterSkin="Thai_Style_ST.skf",$hanle=WinGetHandle("调用游戏菜单","")
$Dll = DllOpen($SkincrafterDll) 
   DllCall($Dll, "int:cdecl", "InitLicenKeys", "wstr", "1", "wstr", "", "wstr", "1@1.com", "wstr", "1") 
   DllCall($Dll, "int:cdecl", "InitDecoration", "int", 1) 
   DllCall($Dll, "int:cdecl", "LoadSkinFromFile", "wstr", $SkincrafterSkin) 
   DllCall($Dll, "int:cdecl", "DecorateAs", "int", $hanle, "int", 25) 
   DllCall($Dll, "int:cdecl", "ApplySkin") 
$hwnd=GUICreate("调用游戏菜单",650,380,@DesktopWidth/2-500,@DesktopHeight/2-380)
DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int",500, "long", 0x00080000)
GUISetState()
GUICtrlCreateGroup("",3,3,647,377)
Dim $b = 1,$Label=GUICtrlCreateLabel("正在加载最新配置!请稍等。。。",120,240,300,40,$SS_CENTERIMAGE)
GUICtrlSetFont($Label,22,400,0,"华文行楷")
;run("\\Server\e\迅闪\游戏菜单\游戏菜单.exe","\\Server\e\迅闪\游戏菜单")
GUISetOnEvent($GUI_EVENT_CLOSE, "quit") 
While 1
Sleep(5)
if $b = 160 Then $b = 1
ControlMove ("调用游戏菜单","正在加载最新配置!请稍等。。。",$Label,120,240-$b,500, 40)
$b +=1
If WinActivate("齐心网吧游戏菜单","") Then quit()
WEnd
Func quit()
                DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 1000, "long", 0x00050010);implode
                            GUISetState(@SW_HIDE)
                        DllCall($dll, "int:cdecl", "DeInitDecoration")
                        DllCall($dll, "int:cdecl", "RemoveSkin")
                                                DllClose($dll)
                                                Exit
EndFunc

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×

评分

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

查看全部评分

发表于 2010-2-7 10:40:18 | 显示全部楼层
不错不错,学习了
发表于 2010-2-7 10:53:48 | 显示全部楼层
用 auto menu bulider
发表于 2010-2-8 12:46:44 | 显示全部楼层
不错,不错!
发表于 2010-2-8 17:50:30 | 显示全部楼层
不错不错,学习了.....
发表于 2012-1-13 18:17:27 | 显示全部楼层
例子很好,收藏了
发表于 2017-7-3 08:08:43 | 显示全部楼层
本帖最后由 sdycn2012 于 2017-7-3 08:13 编辑

昨天有个人联系我做一个滚动代码,刚好看了15楼的代码,这是我改进的代码
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

$formWidth = 300

$formHeight = 150

$form = GUICreate("滚动字幕",$formWidth,$formHeight)

$text = "滚动文字,时间2017年7月3日 07:10:16滚动文字,时间2017年7月3日 07:10:16"

$textLen = StringLen($text)

$textWidth = _regexp($text,0) * 6 + ($textLen - _regexp($text,0)) * 12

$textControl = GUICtrlCreateLabel($text,0,0)

GUISetState(@SW_SHOW)

_marquee()

#Region 滚动字幕 $x:初始x坐标,$step:滚动像素,$speed:速度
Func _marquee($x = 0,$step = 1,$speed = 100)

        $x-=$step

        GUICtrlSetPos($textControl,$x)

        Sleep($speed)

        If $x = -$textWidth Then $x = $formWidth

        if GUIGetMsg() = $GUI_EVENT_CLOSE Then

                Exit

        Else

                _marquee($x)

        EndIf

EndFunc
#EndRegion

#Region 获取字符串指定字节长度,此部分修改自3mile的代码
Func _regexp($input,$flag=1);flag,0='单字节字符',1='简体中文',2='其它双字节字符'

        local $single,$due,$other

        If StringRegExp($input, '[^\x00-\xff]+', 0) Then

                $temp = StringSplit($input, '')

                For $i = 1 To $temp[0]

                        If BinaryLen(StringToBinary($temp[$i])) = 2 Then

                                $high = BinaryMid(StringToBinary($temp[$i]), 1, 1)

                                $low = BinaryMid(StringToBinary($temp[$i]), 2, 1)

                                If $high >= 0xb0 And $high <= 0xf7 And $low >= 0xa1 And $low <= 0xfe Then

                                        $due&=$temp[$i]

                                Else

                                        $other&=$temp[$i]

                                EndIf

                        Elseif BinaryLen(StringToBinary($temp[$i])) =1 Then

                                $single&=$temp[$i]

                        EndIf

                Next

                select

                        case $flag=0

                                return StringLen($single)

                        case $flag=1

                                return StringLen($due)

                        case $flag=2

                                return StringLen($other)

                EndSelect

        EndIf

EndFunc   ;==>_regexp
#EndRegion

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit

        EndSwitch
WEnd
发表于 2017-7-3 08:23:07 | 显示全部楼层
回复 38# sdycn2012


    由固定滚动文字宽度改成了自动获取文字的宽度,如果文字的字体大小不一样,可以单独设置一个文字的字号变量来获取滚动文字的总宽度
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-3-29 06:46 , Processed in 0.071449 second(s), 15 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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