Skocz do zawartości
  • 👋 Witaj na MPCForum!

    Przeglądasz forum jako gość, co oznacza, że wiele świetnych funkcji jest jeszcze przed Tobą! 😎

    • Pełny dostęp do działów i ukrytych treści
    • Możliwość pisania i odpowiadania w tematach
    • System prywatnych wiadomości
    • Zbieranie reputacji i rozwijanie swojego profilu
    • Członkostwo w jednej z największych społeczności graczy

    👉 Dołączenie zajmie Ci mniej niż minutę – a zyskasz znacznie więcej!

    Zarejestruj się teraz

Sound Keyboard


Arkeus

Rekomendowane odpowiedzi

Opublikowano

Siemanko, zobaczyłem pomysł gdzieś w dziale i postanowiłem napisać własnego Keyboarda w ramach treningu w Au3...

Kod starałem się napisać ładnie i czytelnie bez zbędnych komentarzy co do nauki znajdziecie tutaj takie rzeczy jak Timery bądź _Ispressed i wiele innych przykładów dla początkujących.

Uporządkowanie kodu jest tylko i wyłącznie moim kaprysem (pedant ) xD

 

 

Cała paczka .exe + przykładowe soundy:

 

http://trainbot.pl/d...ad/Keyboard.rar

 

Skan: (Nie mam pojęcia co robią te trojany ale gwarantuje że jest czyste...)

 

 

 

 

 

 

Kod źródłowy:

 

 


#cs ----------------------------------------------------------------------------
Script Version: V1.0 (beta)
Author: Arkes
Script Function: Simple Keyboard
#ce ----------------------------------------------------------------------------

;----------------------INCLUDES-------------------------
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
#include <Misc.au3>
#include <Sound.au3>
#include <Timers.au3>
;----------------------INCLUDES-------------------------

;-----------------------GUI-----------------------------
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Keyboard", 330, 208, 190, 124, -1, BitOR($WS_EX_TOOLWINDOW,$WS_EX_TOPMOST,$WS_EX_WINDOWEDGE))
GUISetBkColor(0x696969)
$Label1 = GUICtrlCreateLabel("Status", 128, 0, 60, 22)
GUICtrlSetFont(-1, 12, 800, 0, "Verdana")
$Button1 = GUICtrlCreateButton("On", 56, 32, 75, 25)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x0066CC)
$Button2 = GUICtrlCreateButton("Off", 176, 32, 75, 25)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x0066CC)
$Label2 = GUICtrlCreateLabel("Author Arkes", 224, 184, 81, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$Edit1 = GUICtrlCreateEdit("", 0, 64, 329, 105, BitOR($GUI_SS_DEFAULT_EDIT,$ES_NUMBER))
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
GuiCtrlSetstate($button2,128)
;-----------------------GUI------------------------------
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
$Soundsnull = _Timer_SetTimer($Form1,1,"Playnull")
$Soundsone = _Timer_SetTimer($Form1,1,"Playone")
$Soundstwo = _Timer_SetTimer($Form1,1,"Playtwo")
$Soundsthree = _Timer_SetTimer($Form1,1,"Playthree")
$Soundsfour = _Timer_SetTimer($Form1,1,"Playfour")
$Soundsfive = _Timer_SetTimer($Form1,1,"Playfive")
$Soundssix = _Timer_SetTimer($Form1,1,"Playsix")
$Soundsseven = _Timer_SetTimer($Form1,1,"Playseven")
$Soundseight = _Timer_SetTimer($Form1,1,"Playeight")
$Soundsnine = _Timer_SetTimer($Form1,1,"Playnine")
GuiCtrlSetstate($button2,64)
GuiCtrlSetstate($button1,128)

Case $Button2
_Timer_KillTimer($Form1, $Soundsnull)
_Timer_KillTimer($Form1, $Soundsone)
_Timer_KillTimer($Form1, $Soundstwo)
_Timer_KillTimer($Form1, $Soundsthree)
_Timer_KillTimer($Form1, $Soundsfour)
_Timer_KillTimer($Form1, $Soundsfive)
_Timer_KillTimer($Form1, $Soundssix)
_Timer_KillTimer($Form1, $Soundsseven)
_Timer_KillTimer($Form1, $Soundseight)
_Timer_KillTimer($Form1, $Soundsnine)
GuiCtrlSetstate($button2,128)
GuiCtrlSetstate($button1,64)

EndSwitch
WEnd


;----------------------FUNCTIONS-------------------------
Func Playnull($1,$2,$3,$4)
Local $hDLL = DllOpen("user32.dll")
If _IsPressed("30", $hDLL) Then SoundPlay(@ScriptDir & "\Sound\0.wav", 0)
DllClose($hDLL)
EndFunc
Func Playone($1,$2,$3,$4)
Local $hDLL = DllOpen("user32.dll")
If _IsPressed("31", $hDLL) Then SoundPlay(@ScriptDir & "\Sound\1.wav", 0)
DllClose($hDLL)
EndFunc
Func Playtwo($1,$2,$3,$4)
Local $hDLL = DllOpen("user32.dll")
If _IsPressed("32", $hDLL) Then SoundPlay(@ScriptDir & "\Sound\2.wav", 0)
DllClose($hDLL)
EndFunc
Func Playthree($1,$2,$3,$4)
Local $hDLL = DllOpen("user32.dll")
If _IsPressed("33", $hDLL) Then SoundPlay(@ScriptDir & "\Sound\3.wav", 0)
DllClose($hDLL)
EndFunc
Func Playfour($1,$2,$3,$4)
Local $hDLL = DllOpen("user32.dll")
If _IsPressed("34", $hDLL) Then SoundPlay(@ScriptDir & "\Sound\4.wav", 0)
DllClose($hDLL)
EndFunc
Func Playfive($1,$2,$3,$4)
Local $hDLL = DllOpen("user32.dll")
If _IsPressed("35", $hDLL) Then SoundPlay(@ScriptDir & "\Sound\5.wav", 0)
DllClose($hDLL)
EndFunc
Func Playsix($1,$2,$3,$4)
Local $hDLL = DllOpen("user32.dll")
If _IsPressed("36", $hDLL) Then SoundPlay(@ScriptDir & "\Sound\6.wav", 0)
DllClose($hDLL)
EndFunc
Func Playseven($1,$2,$3,$4)
Local $hDLL = DllOpen("user32.dll")
If _IsPressed("37", $hDLL) Then SoundPlay(@ScriptDir & "\Sound\7.wav", 0)
DllClose($hDLL)
EndFunc
Func Playeight($1,$2,$3,$4)
Local $hDLL = DllOpen("user32.dll")
If _IsPressed("38", $hDLL) Then SoundPlay(@ScriptDir & "\Sound\8.wav", 0)
DllClose($hDLL)
EndFunc
Func Playnine($1,$2,$3,$4)
Local $hDLL = DllOpen("user32.dll")
If _IsPressed("39", $hDLL) Then SoundPlay(@ScriptDir & "\Sound\9.wav", 0)
DllClose($hDLL)
EndFunc
;----------------------FUNCTIONS-------------------------

 

Instrukcja: Gramy za pomocą klawiszy od 1 do 0, proponuje grać w polu tekstowym wtedy widzimy jak graliśmy i możemy to powtarzać, dzwięki w paczce można podmieniać na własne.

Opublikowano

_IsPressed jest średnim rozwiązaniem, bo żre pamięć jak głupie.

Aczkolwiek, dosyć ciekawe rozwiązanie ^^

 

Po drugie: Na cuj ci te parametry w procedurach o_O?]

 

I po trzecie: Do takich rzeczy radzę ci używać trybu OnEvent zamiast MessageLoop do obsługi GUI

 

I zamiast kombinować z timerami, możesz walnąć funkcje grające w AdlibRegister :D Jak już żreć pamięć, to porządnie.

846331404756772371599.jpeg
Opublikowano

Parametry to wątki do Timerów, obsługa GUI jest ok Timery robią swoje a ja mogę w każdej chwili robić to co chce.

Moim zdaniem Timery są lepsze od Adlib (ale to tylko moje zdanie).

_Ispressed nie pobiera aż tak dużo dałem dlcall..

Zarchiwizowany

Ten temat przebywa obecnie w archiwum. Dodawanie nowych odpowiedzi zostało zablokowane.

×
×
  • Dodaj nową pozycję...