Tastenklick gibt geräusch

  • guten morgen

    ich habe in meinem skript ein problem immer wenn ich a,w,s oder d drücke gibt der computer ein geräusch das soll der aber nicht machen was muss ich tun

    hier mein skript

    Spoiler anzeigen
    [autoit]

    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>
    #include <Misc.au3>
    #include <StaticConstants.au3>
    $UserDLL = DllOpen("User32.dll")
    Global $Rot_Wert = 100
    Global $Blau_Wert = 100
    Global $Rot_Richtung = "rechts"
    Global $Rot_Y = 250
    Global $Rot_X = 250
    Global $Blau_Y = 250
    Global $Blau_X = 250
    Global $Blau_Zaehler = 0
    Global $Rot_Zaehler = 0
    Global $Blau_Richtung = "rechts"
    Global $Blau_Feinde = 0
    Global $Rot_Feinde = 0
    Global $Rot_Timer = 0
    Global $Blau_Timer = 0
    Dim $Rot_Label[10000000]
    Dim $Blau_Label[10000000]
    Dim $Blau_Feind_Label[10000000]
    Dim $Blau_Feind_X[10000000]
    Dim $Blau_Feind_Y[10000000]
    Dim $Rot_Feind_Label[10000000]
    Dim $Rot_Feind_X[10000000]
    Dim $Rot_Feind_Y[10000000]
    Menu()
    Func Menu()
    $FormMenu = GUICreate("MultiplayerSnake", 510, 269, -1, -1, $WS_POPUP)
    GUISetBkColor(0x590000)
    $Close = GUICtrlCreateIcon("", -1, 464, 8, 40, 40, BitOR($SS_NOTIFY,$WS_GROUP))
    GUICtrlSetImage(-1,"dw.ico")
    GUICtrlCreatePic("", 8, 56, 500, 100, BitOR($SS_NOTIFY,$WS_CLIPSIBLINGS))
    GUICtrlSetImage(-1,"Unbenannt-2 Kopie.jpg")
    $Play = GUICtrlCreatePic("", 19, 160, 150, 100, BitOR($SS_NOTIFY,$WS_CLIPSIBLINGS))
    GUICtrlSetImage(-1,"play.jpg")
    $Quit = GUICtrlCreatePic("", 347, 160, 150, 100, BitOR($SS_NOTIFY,$WS_CLIPSIBLINGS))
    GUICtrlSetImage(-1,"quit.jpg")
    $Settings = GUICtrlCreatePic("", 183, 160, 150, 100, BitOR($SS_NOTIFY,$WS_CLIPSIBLINGS))
    GUICtrlSetImage(-1,"settings.jpg")
    GUISetState(@SW_SHOW)
    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $Play
    GUIDelete($FormMenu)
    Var()
    Spiel()
    Case $Close
    Exit
    Case $Settings
    Settings()
    Case $Quit
    Exit
    EndSwitch
    WEnd
    EndFunc
    Func Spiel()
    Global $Form = GUICreate("MultiplayerSnake", 500, 500)
    GUISetBkColor(0x590000)
    DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 0)
    $Rot_Prozess = GUICtrlCreateProgress(400,10,90,15)
    GUICtrlSetColor(-1,0xff0000)
    GUISetBkColor(0x590000)
    $Blau_Prozess = GUICtrlCreateProgress(400,35,90,15)
    GUICtrlSetColor(-1, 0x0000FF)
    GUISetBkColor(0x590000)
    DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 7)
    $Rot_Anzeige = GUICtrlCreateLabel("",10,5,30,30)
    GUICtrlSetFont(-1, 14, 800, 0, "Verdana")
    GUICtrlSetColor(-1, 0xff0000)
    $Blau_Anzeige = GUICtrlCreateLabel("",10,30,30,30)
    GUICtrlSetFont(-1, 14, 800, 0, "Verdana")
    GUICtrlSetColor(-1, 0x0000FF)
    $Rot_Anzeige2 = GUICtrlCreateLabel("",40,5,30,30)
    GUICtrlSetFont(-1, 10, 800, 0, "Verdana")
    GUICtrlSetColor(-1, 0xff0000)
    $Blau_Anzeige2 = GUICtrlCreateLabel("",40,30,30,30)
    GUICtrlSetFont(-1, 10, 800, 0, "Verdana")
    GUICtrlSetColor(-1, 0x0000FF)
    GUISetState(@SW_SHOW)
    GUICtrlSetData($Rot_Prozess,$Rot_Wert)
    GUICtrlSetData($Blau_Prozess,$Blau_Wert)
    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    EndSwitch
    If _IsPressed(27,$UserDLL) = 1 Then
    If $Rot_Richtung = "unten" Or $Rot_Richtung = "oben" Then
    Global $Rot_Richtung = "rechts"
    EndIf
    EndIf
    If _IsPressed(25,$UserDLL) = 1 Then
    If $Rot_Richtung = "unten" Or $Rot_Richtung = "oben" Then
    Global $Rot_Richtung = "links"
    EndIf
    EndIf
    If _IsPressed(26,$UserDLL) = 1 Then
    If $Rot_Richtung = "rechts" Or $Rot_Richtung = "links" Then
    Global $Rot_Richtung = "oben"
    EndIf
    EndIf
    If _IsPressed(28,$UserDLL) = 1 Then
    If $Rot_Richtung = "rechts" Or $Rot_Richtung = "links" Then
    Global $Rot_Richtung = "unten"
    EndIf
    EndIf
    If _IsPressed(44,$UserDLL) = 1 Then
    If $Blau_Richtung = "unten" Or $Blau_Richtung = "oben" Then
    Global $Blau_Richtung = "rechts"
    EndIf
    EndIf
    If _IsPressed(41,$UserDLL) = 1 Then
    If $Blau_Richtung = "unten" Or $Blau_Richtung = "oben" Then
    Global $Blau_Richtung= "links"
    EndIf
    EndIf
    If _IsPressed(57,$UserDLL) = 1 Then
    If $Blau_Richtung = "rechts" Or $Blau_Richtung = "links" Then
    Global $Blau_Richtung = "oben"
    EndIf
    EndIf
    If _IsPressed(53,$UserDLL) = 1 Then
    If $Blau_Richtung = "rechts" Or $Blau_Richtung = "links" Then
    Global $Blau_Richtung = "unten"
    EndIf
    EndIf
    $Sleep = 20
    If _IsPressed("A3",$UserDLL) = 1 Then
    If $Rot_Wert <= 0 Then
    Else
    $Rot_Wert = $Rot_Wert - 10
    GUICtrlSetData($Rot_Prozess,$Rot_Wert)
    $Sleep = 60
    EndIf
    EndIf
    If _IsPressed("A0",$UserDLL) = 1 Then
    If $Blau_Wert <= 0 Then
    Else
    $Blau_Wert = $Blau_Wert - 10
    GUICtrlSetData($Blau_Prozess,$Blau_Wert)
    $Sleep = 60
    EndIf
    EndIf
    If _IsPressed(20,$UserDLL) = 1 Then
    If $Blau_Feinde = 20 Then
    Else
    $Blau_Feind_Label[$Blau_Feinde] = GUICtrlCreateLabel("",$Blau_Y,$Blau_X,10,10)
    $Blau_Feind_X[$Blau_Feinde] = $Blau_X
    $Blau_Feind_Y[$Blau_Feinde] = $Blau_Y
    GUICtrlSetBkColor(-1,0x000000)
    $Blau_Feinde = $Blau_Feinde + 1
    EndIf
    EndIf
    If _IsPressed("A1",$UserDLL) = 1 Then
    If $Rot_Feinde = 20 Then
    Else
    $Rot_Feind_Label[$Rot_Feinde] = GUICtrlCreateLabel("",$Rot_Y,$Rot_X,10,10)
    $Rot_Feind_X[$Rot_Feinde] = $Rot_X
    $Rot_Feind_Y[$Rot_Feinde] = $Rot_Y
    GUICtrlSetBkColor(-1,0x000000)
    $Rot_Feinde = $Rot_Feinde + 1
    EndIf
    EndIf
    GUICtrlSetData($Rot_Anzeige,$Rot_Feinde)
    GUICtrlSetData($Blau_Anzeige,$Blau_Feinde)
    Rot()
    Blau()
    GUICtrlSetData($Rot_Anzeige2,$Rot_Timer)
    GUICtrlSetData($Blau_Anzeige2,$Blau_Timer)
    If $Rot_Feinde = 20 Then
    $Rot_Timer = $Rot_Timer + 1
    If $Rot_Timer = 101 Then
    For $Zaehler = 0 To 20
    GUICtrlDelete($Rot_Feind_Label[$Zaehler])
    Next
    Dim $Rot_Feind_Label[10000000]
    Dim $Rot_Feind_X[10000000]
    Dim $Rot_Feind_Y[10000000]
    $Rot_Feinde = 0
    $Rot_Timer = 0
    EndIf
    EndIf
    If $Blau_Feinde = 20 Then
    $Blau_Timer = $Blau_Timer + 1
    If $Blau_Timer = 101 Then
    For $Zaehler = 0 To 20
    GUICtrlDelete($Blau_Feind_Label[$Zaehler])
    Next
    Dim $Blau_Feind_Label[10000000]
    Dim $Blau_Feind_X[10000000]
    Dim $Blau_Feind_Y[10000000]
    $Blau_Feinde = 0
    $Blau_Timer = 0
    EndIf
    EndIf
    Sleep($Sleep)
    If $Blau_Wert >= 100 Then
    Else
    $Blau_Wert = $Blau_Wert + 0.3
    GUICtrlSetData($Blau_Prozess,$Blau_Wert)
    EndIf
    If $Rot_Wert >= 100 Then
    Else
    $Rot_Wert = $Rot_Wert + 0.3
    GUICtrlSetData($Rot_Prozess,$Rot_Wert)
    EndIf
    WEnd
    EndFunc
    Func Rot()
    If $Rot_Richtung = "rechts" Then $Rot_Y = $Rot_Y + 10
    If $Rot_Richtung = "links" Then $Rot_Y = $Rot_Y - 10
    If $Rot_Richtung = "oben" Then $Rot_X = $Rot_X - 10
    If $Rot_Richtung = "unten" Then $Rot_X = $Rot_X + 10
    $Rot_Label[$Rot_Zaehler] = GUICtrlCreateLabel("",$Rot_Y,$Rot_X,10,10)
    GUICtrlSetBkColor(-1,0xff0000)
    If $Rot_X >= 500 Then
    $Rot_X = -10
    ElseIf $Rot_X <= -10 Then
    $Rot_X = 500
    EndIf
    If $Rot_Y >= 500 Then
    $Rot_Y = -10
    ElseIf $Rot_Y <= -10 Then
    $Rot_Y = 500
    EndIf
    $Rot_Loeschen = $Rot_Zaehler -10
    If $Rot_Zaehler >= 10 Then GUICtrlDelete($Rot_Label[$Rot_Loeschen])
    $Rot_Zaehler = $Rot_Zaehler + 1
    For $Zaehler = 0 To 20
    If $Rot_X = $Rot_Feind_X[$Zaehler] Then
    If $Rot_Y = $Rot_Feind_Y[$Zaehler] Then
    RotVerloren()
    EndIf
    EndIf
    Next
    For $Zaehler = 0 To 20
    If $Rot_X = $Blau_Feind_X[$Zaehler] Then
    If $Rot_Y = $Blau_Feind_Y[$Zaehler] Then
    RotVerloren()
    EndIf
    EndIf
    Next
    EndFunc
    Func Blau()
    If $Blau_Richtung = "rechts" Then $Blau_Y = $Blau_Y + 10
    If $Blau_Richtung = "links" Then $Blau_Y = $Blau_Y - 10
    If $Blau_Richtung = "oben" Then $Blau_X = $Blau_X - 10
    If $Blau_Richtung = "unten" Then $Blau_X = $Blau_X + 10
    $Blau_Label[$Blau_Zaehler] = GUICtrlCreateLabel("",$Blau_Y,$Blau_X,10,10)
    GUICtrlSetBkColor(-1, 0x0000FF)
    If $Blau_X >= 500 Then
    $Blau_X = -10
    ElseIf $Blau_X <= -10 Then
    $Blau_X = 500
    EndIf
    If $Blau_Y >= 500 Then
    $Blau_Y = -10
    ElseIf $Blau_Y <= -10 Then
    $Blau_Y = 500
    EndIf
    $Blau_Loeschen = $Blau_Zaehler -10
    If $Blau_Zaehler >= 10 Then GUICtrlDelete($Blau_Label[$Blau_Loeschen])
    $Blau_Zaehler = $Blau_Zaehler + 1
    For $Zaehler = 0 To 20
    If $Blau_X = $Rot_Feind_X[$Zaehler] Then
    If $Blau_Y = $Rot_Feind_Y[$Zaehler] Then
    BlauVerloren()
    EndIf
    EndIf
    Next
    For $Zaehler = 0 To 20
    If $Blau_X = $Blau_Feind_X[$Zaehler] Then
    If $Blau_Y = $Blau_Feind_Y[$Zaehler] Then
    BlauVerloren()
    EndIf
    EndIf
    Next
    EndFunc
    Func BlauVerloren()
    $Form2 = GUICreate("MultiplayerSnake", 300, 300, -1, -1, $WS_POPUP)
    GUISetBkColor(0x590000)
    $Close = GUICtrlCreateIcon("", -1, 264, 8, 40, 40, BitOR($SS_NOTIFY,$WS_GROUP))
    GUICtrlSetImage(-1,"dw.ico")
    GUICtrlCreateLabel("Rot hat", 74, 80, 200, 39)
    GUICtrlSetFont(-1, 24, 800, 0, "Verdana")
    GUICtrlSetColor(-1, 0xff0000)
    GUICtrlCreateLabel("gewonnen", 58, 120, 200, 39)
    GUICtrlSetFont(-1, 24, 800, 0, "Verdana")
    GUICtrlSetColor(-1, 0xff0000)
    $Button_Wiederholen = GUICtrlCreatePic("widerholen.jpg", 25, 190, 250, 100, BitOR($SS_NOTIFY,$WS_CLIPSIBLINGS))
    GUICtrlSetFont(-1, 8, 400, 0, "Verdana")
    GUISetState(@SW_SHOW)
    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $Button_Wiederholen
    GUIDelete($Form2)
    GUIDelete($Form)
    Var()
    Spiel()
    Case $Close
    Exit
    EndSwitch
    WEnd
    EndFunc
    Func RotVerloren()
    $Form2 = GUICreate("MultiplayerSnake", 300, 300, -1, -1, $WS_POPUP)
    GUISetBkColor(0x590000)
    $Close = GUICtrlCreateIcon("", -1, 264, 8, 40, 40, BitOR($SS_NOTIFY,$WS_GROUP))
    GUICtrlSetImage(-1,"dw.ico")
    GUICtrlCreateLabel("Blau hat", 74, 80, 200, 39)
    GUICtrlSetFont(-1, 24, 800, 0, "Verdana")
    GUICtrlSetColor(-1, 0x0000FF)
    GUICtrlCreateLabel("gewonnen", 58, 120, 200, 39)
    GUICtrlSetFont(-1, 24, 800, 0, "Verdana")
    GUICtrlSetColor(-1, 0x0000FF)
    $Button_Wiederholen = GUICtrlCreatePic("widerholen.jpg", 25, 190, 250, 100, BitOR($SS_NOTIFY,$WS_CLIPSIBLINGS))
    GUICtrlSetFont(-1, 8, 400, 0, "Verdana")
    GUISetState(@SW_SHOW)
    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $Button_Wiederholen
    GUIDelete($Form2)
    GUIDelete($Form)
    Var()
    Spiel()
    Case $Close
    Exit
    EndSwitch
    WEnd
    EndFunc
    Func Var()
    Global $Rot_Wert = 100
    Global $Blau_Wert = 100
    Global $Rot_Richtung = "rechts"
    Global $Rot_Y = 250
    Global $Rot_X = 100
    Global $Blau_Y = 250
    Global $Blau_X = 400
    Global $Blau_Zaehler = 0
    Global $Rot_Zaehler = 0
    Global $Blau_Richtung = "rechts"
    Global $Blau_Feinde = 0
    Global $Rot_Feinde = 0
    Global $Rot_Timer = 0
    Global $Blau_Timer = 0
    Dim $Rot_Label[10000000]
    Dim $Blau_Label[10000000]
    Dim $Blau_Feind_Label[10000000]
    Dim $Blau_Feind_X[10000000]
    Dim $Blau_Feind_Y[10000000]
    Dim $Rot_Feind_Label[10000000]
    Dim $Rot_Feind_X[10000000]
    Dim $Rot_Feind_Y[10000000]
    EndFunc
    Func Settings()
    EndFunc

    [/autoit]

    Einmal editiert, zuletzt von gem (11. Juli 2011 um 17:14)

  • Beispiel:

    Spoiler anzeigen
    [autoit]

    #include <GUIConstants.au3>

    [/autoit] [autoit][/autoit] [autoit]

    $hWnd = GUICreate("Test", 400, 400)
    $cButton = GUICtrlCreateButton("Button", 50, 50, 100, 25)
    $cDummy = GUICtrlCreateDummy()
    GUISetState()

    [/autoit] [autoit][/autoit] [autoit]

    Dim $aAccel[4][2] = [['a', $cDummy], ['w', $cDummy], ['s', $cDummy], ['d', $cDummy]]
    GUISetAccelerators($aAccel, $hWnd)

    [/autoit] [autoit][/autoit] [autoit]

    While GUIGetMsg() <> $GUI_EVENT_CLOSE
    WEnd

    [/autoit]