Je viens vous présenter un petit logiciel que j'ai fait cet après-midi (je ne savais pas quoi faire alors...)
Il permet de jouer un aire de musique simplement.
Pour cela, il suffit de cliquer sur la case correspondant à la note souhaitée.
Il est également possible de modifier la durée des notes avec le fichier "Start.ini" (voir l'exemple).
Voici le scripte :
► Afficher le texte
Code : Tout sélectionner
#cs ----------------------------------------------------------------------------
AutoIt Version: 3.3.6.1
Author: TT22
Script Function:Logiciel de musique.
Template AutoIt script.
#ce ----------------------------------------------------------------------------
; Script Start - Add your code below here
Dim $Notes[13][20][2]
Dim $Hertz[14] = [349.228,369.994,391.995,415.305,440,466.164,493.883,523.251,554.365,587.33,622.254,659.255,698.456,0]
Dim $LongBeep[20] = [IniRead("Start.ini","LONG","1",1000),IniRead("Start.ini","LONG","2",1000),IniRead("Start.ini","LONG","3",1000), _
IniRead("Start.ini","LONG","4",1000),IniRead("Start.ini","LONG","5",1000),IniRead("Start.ini","LONG","6",1000), _
IniRead("Start.ini","LONG","7",1000),IniRead("Start.ini","LONG","8",1000),IniRead("Start.ini","LONG","9",1000), _
IniRead("Start.ini","LONG","10",1000),IniRead("Start.ini","LONG","11",1000),IniRead("Start.ini","LONG","12",1000), _
IniRead("Start.ini","LONG","13",1000),IniRead("Start.ini","LONG","14",1000),IniRead("Start.ini","LONG","15",1000), _
IniRead("Start.ini","LONG","16",1000),IniRead("Start.ini","LONG","17",1000),IniRead("Start.ini","LONG","18",1000), _
IniRead("Start.ini","LONG","19",1000),IniRead("Start.ini","LONG","20",1000)]
$Gui = GUICreate("Musique",399,289)
For $i = 0 To 12 Step 1;Création des contrôles...
For $j = 0 To 19 Step 1
$Notes[$i][$j][0] = GUICtrlCreateLabel("",$j*20,$i*20,19,19)
GUICtrlSetBkColor($Notes[$i][$j][0],0xCCCCCC)
$Notes[$i][$j][1] = False
Next
Next
$ButtonStart = GUICtrlCreateButton("Démarrer",0,259,399,30)
GUISetState(@SW_SHOW)
If FileExists("Start.ini") Then
For $i = 0 To 19 Step 1
$Value = Number(IniRead("Start.ini","NOTE",$i+1,0))
If $Value <> 0 Then
GUICtrlSetBkColor($Notes[12-($Value-1)][$i][0],0x00FF00)
$Notes[12-($Value-1)][$i][1] = True
EndIf
Next
EndIf
While 1
If GUIGetMsg() = -3 Then
Exit
EndIf
If _IsPressed("01") Then
$Msg = GUIGetMsg()
For $i = 0 To 12 Step 1;Création des contrôles...
For $j = 0 To 19 Step 1
If $Msg = $Notes[$i][$j][0] Then
If $Notes[$i][$j][1] = False Then
For $k = 0 To 12 Step 1
If $Notes[$k][$j][1] = True Then
If $Notes[$k][$j][1] = True Then
GUICtrlSetBkColor($Notes[$k][$j][0],0xCCCCCC)
$Notes[$k][$j][1] = False
EndIf
EndIf
Next
GUICtrlSetBkColor($Notes[$i][$j][0],0x00FF00)
$Notes[$i][$j][1] = True
Else
GUICtrlSetBkColor($Notes[$i][$j][0],0xCCCCCC)
$Notes[$i][$j][1] = False
EndIf
EndIf
Next
Next
EndIf
If GUIGetMsg() = $ButtonStart Then
GUICtrlSetData($ButtonStart,"Arrêter")
$ExitLoop = False
While 1
For $i = 0 To 19 Step 1
$ToBeep = 13
For $j = 12 To 0 Step -1
If GUIGetMsg() = $ButtonStart Then
$ExitLoop = True
ExitLoop
EndIf
If $Notes[$j][$i][1] = True Then
$ToBeep = 12-$j
ExitLoop
Else
GUICtrlSetBkColor($Notes[$j][$i][0],0xFFFF00)
EndIf
Next
If Not $ExitLoop Then Beep($Hertz[$ToBeep],$LongBeep[$i])
For $j = 0 To 12 Step 1
If $Notes[$j][$i][1] = False Then
GUICtrlSetBkColor($Notes[$j][$i][0],0xCCCCCC)
EndIf
Next
If $ExitLoop Then
ExitLoop
EndIf
Next
If $ExitLoop Then
GUICtrlSetData($ButtonStart,"Démarrer")
ExitLoop
EndIf
WEnd
EndIf
WEnd
Func _IsPressed($sHexKey, $vDLL = 'user32.dll')
; $hexKey must be the value of one of the keys.
; _Is_Key_Pressed will return 0 if the key is not pressed, 1 if it is.
Local $a_R = DllCall($vDLL, "short", "GetAsyncKeyState", "int", '0x' & $sHexKey)
If @error Then Return SetError(@error, @extended, False)
Return BitAND($a_R[0], 0x8000) <> 0
EndFunc ;==>_IsPressed
► Afficher le texte
Code : Tout sélectionner
[LONG]
1=500
2=500
3=250
4=500
5=500
6=250
7=500
8=500
9=250
10=500
11=500
12=250
13=500
14=500
15=250
16=500
17=500
18=250
19=500
20=500
[NOTE]
1=10
2=10
3=9
4=10
5=10
6=11
7=12
8=12
9=11
10=12
11=12
12=13
13=10
14=10
15=9
16=10
17=10
18=13
19=10
20=0
► Afficher le texte
- acdll.png (5.23 Kio) Vu 3154 fois
Dite-moi ce que vous en pensez !