MusicForYou


#cs ____________________________________

 Au3 版本: 3.3.6.1
 脚本作者: wozijisunfly
 Email:
 QQ/TM:
 脚本版本: music-1.0
 脚本功能: Music Player

#ce _______________脚本开始_________________

#include <Sound.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

;Opt("GUIOnEventMode", 1)

Local $NewStyle = False, $gui, $display, $GuiStyles, $Msg,$width,$hight,$up,$stop
Local $down,$open,$num = 1,$count = 1,$arg,$music,$ss
Global $sound,$numline
$width = @DesktopWidth - 27
$hight = @DesktopHeight - 300
$gui = GUICreate("", 21, 115, $width, $hight, Default, $WS_EX_TOPMOST)
;You must be know for you .
$up = GUICtrlCreateButton("▲", 0, 10, 20, 20)
;GUICtrlSetOnEvent($up, "upMusic")
$stop = GUICtrlCreateButton("★", 0, 30, 20, 20)
;GUICtrlSetOnEvent($stop, "stopORstartMusic")
$down = GUICtrlCreateButton("▼", 0, 50, 20, 20)
;GUICtrlSetOnEvent($down, "downMusic")
$open = GUICtrlCreateButton("●", 0, 70, 20, 20)
;GUICtrlSetOnEvent($open, "openMusic")
$display = GUICtrlCreateButton("■", 0, 90, 20, 20)
;GUICtrlSetOnEvent($display, "displayMusic")
$GuiStyles = GUIGetStyle($gui)
GUICtrlSetTip($up,"上一首")
GUICtrlSetTip($stop,"播放")
GUICtrlSetTip($down,"下一首")
GUICtrlSetTip($open,"打开")
GUICtrlSetTip($display,"隐藏")
GUISetState()

While 1
 $Msg = GUIGetMsg()
 Switch $Msg
  Case $GUI_EVENT_CLOSE
   _SoundClose($sound)
   Exit
  Case $display
   If Not $NewStyle Then
    GUISetStyle(BitOR($WS_POPUPWINDOW, $WS_THICKFRAME), BitOR($WS_EX_CLIENTEDGE, $WS_EX_TOOLWINDOW))
    GUICtrlSetData($display, '□')
    GUICtrlSetData($up, '△')
    GUICtrlSetData($down, '▽')
    GUICtrlSetData($stop, '☆')
    GUICtrlSetData($open, '○')
    GUICtrlSetTip($display,"显示")
    $NewStyle = True
   Else
    GUISetStyle($GuiStyles[0], $GuiStyles[1])
    GUICtrlSetData($display, '■')
    GUICtrlSetData($up, '▲')
    GUICtrlSetData($down, '▼')
    GUICtrlSetData($stop, '★')
    GUICtrlSetData($open, '●')
    GUICtrlSetTip($display, "隐藏")
    $NewStyle = False
   EndIf
  Case $up
   ;upMusic()
  Case $down
   ;downMusic()
  Case $stop
   If Mod($num,2) <> 0 Then
    GUICtrlSetTip($stop,"暂停")
    $ss = "|"
   Else
    GUICtrlSetTip($stop,"播放")
    $ss = "="
   EndIf
   $num = $num + 1
   
   If FileExists("C:\music.log") Then
    $fileopen = FileOpen("C:\music.log")
    $numline = 1
    While 1
     $fileread = FileReadLine($fileopen,$numline)
     If $fileread == -1 Then ExitLoop

     If StringLen($fileread) == 0 Then ContinueLoop
     $sound = _SoundOpen( $fileread )
     $length = _SoundLength($sound,2)
     _SoundPlay($sound, 0)
     $mm = StringSplit($fileread,"\")
     GUICtrlSetTip($stop,$mm[$mm[0]])
     Sleep($length)
     ;_SoundPause( $sound )
     ;_SoundResume( $sound )
     $numline = $numline + 1
    WEnd
   Else
    MsgBox(0,"MusicForYou","The disk C: have no file music.log" & @CRLF & "Please click ● OR ○")
   EndIf
  Case $open
   GUICtrlSetState($open,$GUI_DISABLE)
   If FileExists("C:\music.log") Then
    $id = MsgBox(1,"MusicForYou","music.log exist,do you want replace it?")
    If $id == 1 Then
     FileDelete("C:\music.log")
    Else
     GUICtrlSetState($open,$GUI_ENABLE)
     ContinueLoop
    EndIf
   EndIf

   $musicpath = GUICreate("Music Path",300,55, Default, Default, Default, $WS_EX_TOPMOST)
   GUISetStyle(BitOR($WS_POPUPWINDOW, $WS_THICKFRAME), BitOR($WS_EX_CLIENTEDGE, $WS_EX_TOOLWINDOW),$musicpath)
   $label = GUICtrlCreateLabel("Music Path:",10,13)
   $filepath = GUICtrlCreateInput("",80,10,210)
   $yes = GUICtrlCreateButton("确定",100,30)
   $no = GUICtrlCreateButton("取消",160,30)
   GUISetState()
   Do
    $Msgx = GUIGetMsg()
    Select
     Case $Msgx = $yes
      GUISetState(@SW_HIDE, $musicpath)
      $file = GUICtrlRead($filepath)
      If FileExists($file) Then
       $search = FileFindFirstFile($file & "\*.*") 
       ; 检查搜索是否成功
       If $search = -1 Then
        MsgBox(0, "MusicForYou", "No FILE / DIRECTORY")
        Exit
       Else
        
        While 1
         $filename = FileFindNextFile($search)
         If @error Then ExitLoop
         If StringCompare(StringUpper(StringRight($filename,4)),".MP3") == 0 Then
          FileWriteLine("C:\music.log",$file & "\" & $filename)
         EndIf
        WEnd
        
       EndIf
       ; 关闭搜索句柄
       FileClose($search)
      Else
       MsgBox(0,"MusicForYou","Path not correct!")
       ContinueLoop
      EndIf
      
     Case $Msgx = $no
      GUISetState(@SW_HIDE, $musicpath)
    EndSelect
   Until $Msgx = $yes Or $Msgx = $no
   GUICtrlSetState($open,$GUI_ENABLE)
   GUIDelete($musicpath)
   If $NewStyle = False Then
    GUISetStyle($GuiStyles[0], $GuiStyles[1], $gui)
   Else
    GUISetStyle(BitOR($WS_POPUPWINDOW, $WS_THICKFRAME), BitOR($WS_EX_CLIENTEDGE, $WS_EX_TOOLWINDOW),$gui)
   EndIf
  Case Else
 EndSwitch
WEnd

;While 1
; Sleep(1000)
;WEnd

Func upMusic($sound)
 _SoundStop($sound)
 $numline = $numline - 1
 $fileread = FileReadLine($fileopen,$numline)
 If $fileread == -1 Then
  MsgBox(0,"MusicForYou","The MP3 file already end.")
  
 EndIf

 $sound = _SoundOpen( $fileread )
 $length = _SoundLength($sound,2)
 _SoundPlay($sound, 0)
 $mm = StringSplit($fileread,"\")
 GUICtrlSetTip($stop,$mm[$mm[0]])
 Sleep($length)
 ;_SoundPause( $sound )
 ;_SoundResume( $sound )
 $numline = $numline + 1
EndFunc
Func downMusic($sound)
 _SoundStop($sound)
 $numline = $numline + 1
 $fileread = FileReadLine($fileopen,$numline)
 If $fileread == -1 Then
  MsgBox(0,"MusicForYou","The MP3 file already end.")
  
 EndIf
 $sound = _SoundOpen( $fileread )
 $length = _SoundLength($sound,2)
 _SoundPlay($sound, 0)
 $mm = StringSplit($fileread,"\")
 GUICtrlSetTip($stop,$mm[$mm[0]])
 Sleep($length)
 ;_SoundPause( $sound )
 ;_SoundResume( $sound )
 $numline = $numline + 1
EndFunc

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值