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

[原创] 抽奖程序Demo版

  [复制链接]
发表于 2021-3-7 10:34:53 | 显示全部楼层
afan 发表于 2021-3-5 14:29
_SoundPlay($sound, 1) 参数1是 等待,直到声音完成。如果你有其它操作就不能使用该方法。

用创建计时器走进度条后做循环,第一次走完可循环。但第二遍进度条就不走了,不能连续循环。
有什么方法,帮我提个思路,谢谢!
 楼主| 发表于 2021-3-7 10:40:07 | 显示全部楼层
chzj589 发表于 2021-3-7 10:34
用创建计时器走进度条后做循环,第一次走完可循环。但第二遍进度条就不走了,不能连续循环。
有什么方法 ...

可贴出来看看~
发表于 2021-3-7 10:46:26 | 显示全部楼层
本帖最后由 chzj589 于 2021-3-8 08:28 编辑
afan 发表于 2021-3-7 10:40
可贴出来看看~

#NoTrayIcon
#include <Sound.au3>
#include <Array.au3>
#include <GuiListView.au3>
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <SliderConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Timers.au3>
#include <GuiSlider.au3>
#include <GuiStatusBar.au3>
#include <ProgressConstants.au3>

Opt("GUIOnEventMode", 1)
Opt("GUICloseOnESC", 0)
TraySetClick(0)
TraySetState()
TraySetToolTip("chzj589  " & @YEAR & "年" & @MON & "月" & @MDAY & "日")
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
$title = "简易MP3播放器";& StringFormat("%02d:%02d:%02d", @HOUR, @MIN, @SEC)
$work = 0
$uselrc = 0
$line_1 = 0
Dim $geshu, $sjpd, $Label1
Global $g_iMsecs = 0
Local $open, $numold, $Array[1]
Global $g_iTimer1, $g_iTimer2, $Form1, $idChange, $iWait = 10, $idState, $ListView1, $Input1, $Progress1, $Durata2
Global $Pause, $Durata1, $Durata, $Tempo, $WaveVolume, $hListview1, $CheckBox2, $Pausea, $iTimerProgress, $Play
Global $g_idMemo, $g_hStatus, $g_idProgress, $g_iPercent = 0, $g_iDirection = 1
If WinExists($title) Then Exit
_Example_Events()
While 1
        Sleep(1000)
WEnd
Func _Example_Events()
        $Form1 = GUICreate($title, 415, 440)
        GUISetBkColor(0x007180);GUISetBkColor(0x008099)
        GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close")
        $Label1a = GUICtrlCreateLabel("播放歌曲", 5, 45, 60, 25)
        GUICtrlSetColor(-1, 0xFFFFFF);
        $Label1 = GUICtrlCreateLabel("", 65, 45, 130, 20)
        GUICtrlSetColor(-1, 0xFFFFFF);
        GUICtrlSetBkColor(-1, -2)
        $Progress1 = GUICtrlCreateProgress(5, 70, 260, 17, $PBS_SMOOTH);$PBS_MARQUEE);
        GUICtrlSetData($Progress1, 1)
        $Durata2 = GUICtrlCreateInput("", 275, 45, 55, 17)
        $Durata1 = GUICtrlCreateInput(StringFormat("%02d:%02d:%02d", @HOUR, @MIN, @SEC), 335, 45, 75, 17)
        $Durata = GUICtrlCreateInput("", 275, 70, 55, 17)
        $Tempo = GUICtrlCreateInput(StringFormat("%02d:%02d:%02d", @HOUR, @MIN, @SEC + 8), 335, 70, 75, 17)

        $Play = GUICtrlCreateButton("播放", 180, 95, 40, 22)
        GUICtrlSetOnEvent(-1, "MPlayClick2")
        ;$idState= GUICtrlCreateButton("启动", 230, 95, 40, 22)
        $Pause = GUICtrlCreateButton("暂停", 230, 95, 40, 22)
        GUICtrlSetOnEvent(-1, "PlayClick");"_idState");
        $Pausea = GUICtrlCreateButton("恢复", 230, 95, 40, 22)
        GUICtrlSetOnEvent(-1, "PlayClick1")
        GUICtrlSetState($Pausea, 32)
        $Next = GUICtrlCreateButton("停止", 280, 95, 40, 22)
        GUICtrlSetOnEvent(-1, "MPlayClick1")

        $Input1 = GUICtrlCreateInput("", 5, 15, 355, 21)
        $AddFile = GUICtrlCreateButton("歌曲", 365, 15, 40, 22)
        GUICtrlSetOnEvent(-1, "AddFileClick1")
        $WaveVolume = GUICtrlCreateSlider(5, 95, 110, 22)
        GUICtrlSetBkColor(-1, 0x990000);0xFFFFFF);0x007180)
        GUICtrlSetOnEvent(-1, "WaveVolumeChange")
        _GUICtrlSlider_SetRange(-1, 0, 100)
        _GUICtrlSlider_SetPos(-1, 60)
        ;GUICtrlSetData(-1, 60)
        SoundSetWaveVolume(100)

        $ListView1 = GUICtrlCreateListView("", 10, 130, 395, 300)
        Dim $hListview1 = GUICtrlGetHandle(-1)
        _GUICtrlListView_AddColumn($ListView1, "歌曲列表", 80, 0)
        _GUICtrlListView_AddColumn($ListView1, "歌曲时间", 100, 0)
        _GUICtrlListView_AddColumn($ListView1, "歌曲目录", 210, 0)
        $caidan = GUICtrlCreateContextMenu($ListView1)
        $MPlay = GUICtrlCreateMenuItem("播放此歌", $caidan)
        GUICtrlSetOnEvent(-1, "MPlayClick")
        $MPlay1 = GUICtrlCreateMenuItem("停止播放", $caidan)
        GUICtrlSetOnEvent(-1, "MPlayClick1")
        $DPlay = GUICtrlCreateMenuItem("删除此歌", $caidan)
        GUICtrlSetOnEvent(-1, "DPlayClick")
        $Clean = GUICtrlCreateMenuItem("清除列表", $caidan)
        GUICtrlSetOnEvent(-1, "CleanClick")
        AddFileClick()
        DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 0)
        $CheckBox2 = GUICtrlCreateCheckbox("循环", 120, 98, 47, 17)
        GUICtrlSetFont(-1, 9, 400, 0, "MS Sans Serif")
        GUICtrlSetColor(-1, 0xFFFFFF);
        ;GUICtrlSetOnEvent(-1, "_Checkbox2")
        _Timer_SetTimer($Form1, 1000, "_UpdateStatusBarClocka") ; 创建计时器
        GUISetState(@SW_SHOW)
        $pos = WinGetPos($Form1)
        GUIRegisterMsg($WM_TIMER, "WM_TIMER")
        $g_iTimer1 = _Timer_SetTimer($Form1, 1000)
GUICtrlSetData($Durata2,  56)
EndFunc   ;==>_Example_Events
Func Form1Close()
        GUIDelete()
        Exit
EndFunc   ;==>Form1Close



本帖子中包含更多资源

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

×
 楼主| 发表于 2021-3-7 10:56:07 | 显示全部楼层
chzj589 发表于 2021-3-7 10:46
#AutoIt3Wrapper_icon= K01.ico;g.ico;;                              C:\WINDOWS\system32\SHELL32.dll|- ...

你这太长了,没时间看,之前写了个例子
#include <Sound.au3>

Opt('GUIOnEventMode', 1)

Global $aSound, $iSound
Local $fMusic = @ScriptDir & '\MP3.mp3'
_PlayLoop($fMusic)

GUICreate('')
        GUISetOnEvent(-3, '_Exit')
GUICtrlCreateButton('暂停/播放', 20, 50, 100, 25)
        GUICtrlSetOnEvent(-1, '_Pause')
GUISetState()

While 1
        Sleep(1000)
WEnd

Func _PlayLoop($fMusic)
        Dim $aSound = _SoundOpen($fMusic)
                If @error Then Return SetError(1)
        _SoundPlay($aSound)
        AdlibRegister('_CKPlayLoop')
EndFunc   ;==>_PlayLoop
Func _CKPlayLoop()
        Local Static $iTS
        Local $iPos = _SoundPos($aSound, 2)
        If $iPos = $iTS Then
                _SoundStop($aSound)
                Sleep(500)
                _SoundPlay($aSound)
        EndIf
        $iTS = $iPos
EndFunc   ;==>_CKPlayLoop
Func _Pause()
        Local Static $bPause
        $bPause = Not $bPause
        If $bPause Then
                AdlibUnRegister('_CKPlayLoop')
                _SoundPause($aSound)
        Else
                _SoundResume($aSound)
                AdlibRegister('_CKPlayLoop')
        EndIf
EndFunc   ;==>_Pause
Func _Exit()
        _SoundClose($aSound)
        Exit
EndFunc   ;==>_Exit
发表于 2021-3-7 11:08:57 | 显示全部楼层
afan 发表于 2021-3-7 10:56
你这太长了,没时间看,之前写了个例子

谢谢!我学习学习
发表于 2021-3-13 09:50:06 | 显示全部楼层
afan 发表于 2021-3-7 10:56
你这太长了,没时间看,之前写了个例子

A版,首先谢谢你的代码。加上进度条,好玩。


还有个问题请教,列表上的音乐文件如何连续播放。给个思路方法。谢谢



本帖子中包含更多资源

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

×
 楼主| 发表于 2021-3-13 09:58:40 | 显示全部楼层
本帖最后由 afan 于 2021-3-13 10:01 编辑
chzj589 发表于 2021-3-13 09:50
A版,首先谢谢你的代码。加上进度条,好玩。

每次点击列表中的项目进行播放时保存该列表索引;
在单曲播放完毕检测是否需循环,如是则重复播放;如不是则列表索引+1,播放下一曲。
在列表索引+1时还可判断:如有列表整体循环需求则>若列表索引+1大于列表总数-1则返回到第一首播放。
发表于 2021-3-13 10:02:30 | 显示全部楼层
afan 发表于 2021-3-13 09:58
每次点击列表中的项目进行播放时保存该列表索引;
在单曲播放完毕检测是否需循环,如是则重复播放;如不 ...

好的,我试试。谢谢
发表于 2021-3-17 17:00:10 | 显示全部楼层
afan 发表于 2021-3-13 09:58
每次点击列表中的项目进行播放时保存该列表索引;
在单曲播放完毕检测是否需循环,如是则重复播放;如不 ...

列表可以连续播放了。还有一个问题请教,在连续播放列表里的音乐时,列表项目背景色如何随播放的项目移动?
1:用WM_NOTIFY
2:用WM_COMMAND
两个方法我都无法实现。
 楼主| 发表于 2021-3-17 17:03:52 | 显示全部楼层
chzj589 发表于 2021-3-17 17:00
列表可以连续播放了。还有一个问题请教,在连续播放列表里的音乐时,列表项目背景色如何随播放的项目移动 ...

这个不用消息,直接在播放下一曲时 _GUICtrlListView_SetItemSelected 选中该项目
发表于 2021-3-17 17:34:58 | 显示全部楼层
afan 发表于 2021-3-17 17:03
这个不用消息,直接在播放下一曲时 _GUICtrlListView_SetItemSelected 选中该项目

谢谢!  老是想到用消息,折腾了大半天。帮助文件还得再学习
发表于 2021-8-19 11:24:05 | 显示全部楼层

楼主辛苦,谢谢楼主,感谢分享,楼主好人,一生平安
发表于 2021-8-19 11:30:08 | 显示全部楼层
能自定义吗,a神
 楼主| 发表于 2021-8-19 12:32:07 | 显示全部楼层
rdw167 发表于 2021-8-19 11:30
能自定义吗,a神

这是个演示版,没有加入自定义等设置功能~
发表于 2021-9-17 16:27:00 | 显示全部楼层
这效果看着就很666
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-4-27 01:30 , Processed in 0.074349 second(s), 15 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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