Hallo,
ich bin Autoit-Anfänger und ich habe mal versucht einen Mini-Musik-Player zu schreiben, den möchte ich aber noch fortsetzen.
Deshalb habe ich zwei Fragen:
1. Kann man ein Sound per Drag und Drop abspielen, wenn er mit der Maus in die GUI gezogen wird?
2. Kann man die GUI so programmieren, dass sie nicht transparent ist, wenn man mit dem Mauszeiger darauf ist und halb-transparent wird, wenn man den Mauszeiger weg bewegt?
Mein Quelltext:
Spoiler anzeigen
#include <GUIConstantsEx.au3>
#include <SliderConstants.au3>
#include <WindowsConstants.au3>
#include <Sound.au3>
Opt("TrayMenuMode",1)
;erstelle GUI
Global $sound
GUICreate("Sound Player", 320, 90, @DesktopWidth / 2 - 160, @DesktopHeight / 2 - 45, -1)
GUISetIcon ("C:\WINDOWS\system32\shell32.dll", "-169")
TraySetIcon ("C:\WINDOWS\system32\shell32.dll", "-169")
GUICtrlSetState(-1, $GUI_DROPACCEPTED)
$Slider1 = GUICtrlCreateSlider(10, 10, 300, 30, BitOR($TBS_TOOLTIPS, $TBS_AUTOTICKS))
$btn = GUICtrlCreateButton("Dateiauswahl", 10, 50, 100, 30)
$stop = GUICtrlCreateButton("Anhalten", 110, 50, 100, 30)
$restop = GUICtrlCreateButton("Fortsetzen", 210, 50, 100, 30)
GUICtrlSetData ($Slider1, 50)
GUISetState(@SW_SHOW)
$count = 0
;GUI Ende
;erstelle Traymenü
$stopitem = TrayCreateItem("Anhalten")
$fortitem = TrayCreateItem("Fortsetzen")
$datitem = TrayCreateItem("Dateiauswahl")
TrayCreateItem("")
$invisibleitem = TrayCreateItem("Unsichtbar")
$visibleitem = TrayCreateItem("Sichtbar")
TrayCreateItem("")
$minitem = TrayCreateItem("Minimieren")
$normitem = TrayCreateItem("Wiederherstellen")
TrayCreateItem("")
$exititem = TrayCreateItem("Beenden")
;Traymenü Ende
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
e()
Case $btn
NewSound()
Case $stop
Stop()
Case $restop
Weiter()
Case $Slider1
Lautstarke()
EndSwitch
$msg = TrayGetMsg()
Select
Case $msg = 0
ContinueLoop
Case $msg = $datitem
NewSound()
Case $msg = $stopitem
Stop()
Case $msg = $fortitem
Weiter()
Case $msg = $visibleitem
iv()
Case $msg = $invisibleitem
v()
Case $msg = $exititem
e()
Case $msg = $minitem
min()
Case $msg = $normitem
norm()
EndSelect
WEnd
[/autoit] [autoit][/autoit] [autoit]Func NewSound()
If $count > 0 Then
_SoundClose ($sound)
EndIf
$var = FileOpenDialog("Bitte wählen Sie eine Sounddatei aus!", "C:\", "Musik (*.mp3;*.wma;*.wav;*.mid)", 1 + 4 )
$sound = _SoundOpen($var, "Musik")
$count = $count + 1
_SoundPlay($sound)
EndFunc
Func Stop()
_SoundPause($sound)
EndFunc
Func Weiter()
_SoundResume($sound)
EndFunc
Func Lautstarke()
$vol = GUICtrlRead($Slider1)
SoundSetWaveVolume($vol)
EndFunc
Func e()
For $i = 255 to 1 Step -1
WinSetTrans("Sound Player", "", $i)
Next
Exit
EndFunc
Func v()
WinSetState ( "Sound Player", "", @SW_HIDE)
EndFunc
Func iv()
WinSetState ( "Sound Player", "", @SW_SHOW)
EndFunc
Func min()
WinSetState ( "Sound Player", "", @SW_MINIMIZE)
EndFunc
Func norm()
WinSetState ( "Sound Player", "", @SW_RESTORE)
EndFunc
Danke schomal im Vorraus!