#include <Sound.au3>
#include <Constants.au3>
#include <SendMessage.au3>
Opt("TrayMenuMode",1)
Dim $FileN
#Region
If $CmdLine[0] >0 Then
$FileN= $CmdLine[1]
$hWnd = WinGetHandle('Player ')
If NOT @error Then
$message = 'play'
$struct = DllStructCreate('wchar var1[1000]')
DllStructSetData($struct, 1, $message&"|"& $FileN)
$pStruct = DllStructGetPtr($struct)
$struct2 = DllStructCreate('dword;dword;ptr')
DllStructSetData($struct2, 1, 0)
DllStructSetData($struct2, 2, 1000)
DllStructSetData($struct2, 3, $pStruct)
$pStruct2 = DllStructGetPtr($struct2)
_SendMessage($hWnd, 0x4A, 0, $pStruct2)
Exit 0;
Else
$sound=_SoundOpen ($FileN, "Startup")
_SoundPlay($sound,0)
EndIf
EndIf
#EndRegion
#Region
GUICreate("Player ")
GUISetState(@SW_HIDE)
$Nameitem = TrayCreateItem($FileN)
TrayCreateItem("")
$Openitem = TrayCreateItem("Open")
$Playitem = TrayCreateItem("Play")
$Exititem = TrayCreateItem("Exit")
#EndRegion
;~ AutoItWinSetTitle("Player ")
ConsoleWrite(AutoItWinGetTitle())
GUIRegisterMsg(0x4A, '_Rec')
While 1
$msg = TrayGetMsg()
Select
Case $msg = $openitem
$File = FileOpenDialog("Choose file...","","Music (*.mp3;*.wma;*.wav)")
if $File<>"" then
if $FileN<>"" then _SoundClose ($sound)
$FileN=$File
$sound=_SoundOpen ($FileN)
_SoundPlay($sound,0)
TrayItemSetText($nameitem,$FileN)
Endif
Case $msg = $playitem
if $FileN<>"" then
_SoundPlay($sound,0)
Endif
Case $msg = $exititem
Exit 0
EndSelect
WEnd
Func _Rec($hWnd, $iMsg, $iwParam, $ilParam)
$S1 = DllStructCreate('dword var1;dword var2;ptr var3', $ilParam)
$S2 = DllStructGetData($S1, 3)
$S3 = DllStructCreate('wchar var1[1000]', $S2)
$S4 = DllStructGetData($S3, 1)
$Split= StringSplit($S4,'|')
$File = $Split[2]
$message =$Split[1]
if $File<>"" then
if $FileN<>"" then _SoundClose ($sound)
$FileN=$File
$sound=_SoundOpen ($FileN)
_SoundPlay($sound,0)
TrayItemSetText($nameitem,$FileN)
Endif
EndFunc ;==>_Rec
|