Bug oder GuiGetMsg() will nicht wie ich will

  • Hallo,

    könnt ihr mir bei folgendem Problem weiterhelfen - ich habe keine Ahnung mehr, woran das liegen könnte. Hunderte von Skripte geschrieben, welche alle ähnlich aufgebaut sind und jetzt dieses Problem, welches mich fast in den Wahnsinn treibt ?(

    Sache:

    Einfach nur ein GUI erstellen, ein paar Buttons, fertig.

    Das Problem:

    Bei folgender Reihenfolge funktioniert GuiGetMsg() nicht.

    "X" Button 1x drücken, danach in das rechte weiße Feld etwas eintragen und Programm beenden (über Kreuz rechts oben)

    Ausgespuckt wird dann eine Temp.txt Datei, welche das Problem sichtbar macht:

    Zuerst passiert nichts, dann wird die Taste "X" gedrückt, dann wird das rechte Feld bearbeitet, UND DANN SPRINGT DER SCHEISS WIEDER ZURÜCK ZUR X TASTE!!!

    Warum???

    Bitte helft mir mit Klartext weiter...

    Vielen Dank und viele Grüße

  • Hallo dost0011,

    es fehlt nur das exit bei Case $msg = $GUI_EVENT_CLOSE. Dann klappt's. Zum debuggen ist es einfacher sich mit Consolewrite solche Sachen in die Ausgabe von Scite ausgeben z lassen, denn dann hat man alles im Blick,

    Spoiler anzeigen
    [autoit]

    $Version = "V1.13"

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

    #include <ButtonConstants.au3>
    #include <GUIConstants.au3>
    #include <EditConstants.au3>
    #include <WindowsConstants.au3>
    #include <array.au3>
    #include <ListviewConstants.au3>

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

    #include <GuiConstantsEx.au3>
    #include <GuiListView.au3>
    #include <GuiImageList.au3>

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

    Opt("WinTitleMatchMode", 3)
    Opt("SendKeyDelay", 1)

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

    $height = 300
    $top = (@DesktopHeight - $height - 60)
    $left = 0
    $width = @DesktopWidth
    GUICreate("Einsortieren " & $Version, $width, $height, $left, $top, $GUI_SS_DEFAULT_GUI, $WS_EX_ACCEPTFILES + $GUI_DROPACCEPTED)

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

    ; -------------------------
    ; Erzeuge linke Gruppe
    $randhor1 = 10
    $randhor2 = 40

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

    Global $Ordnername_Musik_neu = GUICtrlCreateInput("", 40, 50, ($width / 2) - $randhor2 - 2 * 40, 30, $ES_READONLY)
    GUICtrlSetState(-1, $GUI_DROPACCEPTED)
    GUICtrlSetFont(-1, "14")
    Global $Ordnername_Musik_neu_rename_ID = GUICtrlCreateInput("", 40, 90, ($width / 2) - $randhor2 - 2 * 40, 30)
    GUICtrlSetFont(-1, "14")

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

    Global $Informationen_Musik_neu_ID = GUICtrlCreateEdit("", 40, 150, ($width / 2) - $randhor2 - 2 * 40, 120, $ES_READONLY)
    GUICtrlSetFont(-1, "14")

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

    ; -------------------------
    ; Erzeuge rechte Gruppe
    GUICtrlCreateGroup("Musikbibliothek: " & "\", $width / 2 + $randhor2, 20, (($width - 2 * ($randhor1 + $randhor2)) / 2), $height - 2 * 20)
    GUICtrlSetFont(-1, "14")
    Global $Ordnername_Musik = GUICtrlCreateInput("", $width / 2 + 80, 50, ($width / 2) - $randhor2 - 2 * 40, 30, $ES_READONLY)
    GUICtrlSetState(-1, $GUI_DROPACCEPTED)
    GUICtrlSetFont(-1, "14")
    Global $Ordnername_Musik_rename_ID = GUICtrlCreateInput("", $width / 2 + 80, 90, ($width / 2) - $randhor2 - 2 * 40, 30)
    GUICtrlSetFont(-1, "14")

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

    Global $Informationen_Musik_ID = GUICtrlCreateEdit("", $width / 2 + 80, 150, ($width / 2) - $randhor2 - 2 * 40, 120, $ES_READONLY)
    GUICtrlSetFont(-1, "14")

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

    ; Erzeuge Buttons in der Mitte
    Global $Button_Act = GUICtrlCreateButton("Reload", $width / 2 - 40, 10, 80, 40)
    ;GUICtrlSetFont(-1,"18")

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

    Global $Button_Copy_Folder = GUICtrlCreateButton("Kopiere Ordner", $width / 2 - 40, 100, 80, 40)
    ;GUICtrlSetFont(-1,"14")
    GUICtrlSetBkColor(-1, "0xAAAAAA")

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

    Global $Button_Replace_Folder = GUICtrlCreateButton("Ersetze Ordner", $width / 2 - 40, 150, 80, 40)
    ;GUICtrlSetFont(-1,"18")
    GUICtrlSetBkColor(-1, "0xAAAAAA")

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

    Global $Button_Delete = GUICtrlCreateButton("X", $width / 2 - 120, 10, 40, 40)
    GUICtrlSetFont(-1, "18")
    GUICtrlSetBkColor(-1, "0xAAAAAA")

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

    Global $Button_Musik_Up = GUICtrlCreateButton("Up", $width - 160, 10, 40, 40)
    Global $Button_Musik_Root = GUICtrlCreateButton("Root", $width - 120, 10, 40, 40)
    Global $Button_Create = GUICtrlCreateButton("Create", $width - 80, 10, 40, 40)

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

    Global $Button_Hilfe = GUICtrlCreateButton("Hilfe", $width / 2 - 40, 250, 80, 40)
    ; Suchvorschläge werden hier abgelegt
    Global $searchresult[1000]
    Global $search_index = 0

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

    GUISetState()

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

    ;Global $file23 = FileOpen("temp.txt", 2)
    ;ConsoleWrite("Waschen")

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

    While 1
    $msg = GUIGetMsg()
    Sleep(100)
    ; Consolewrite($file23,$msg)
    ;MsgBox(0,"msg",$msg,1)
    Select
    Case $msg = $Button_Delete
    ConsoleWrite("Löschen Start" & @crlf)
    ConsoleWrite("Löschen Ende" & @crlf)
    Case $msg = $GUI_EVENT_CLOSE
    ConsoleWrite("Exit" & @crlf)
    Exit
    ;FileClose($file23)
    Case $msg = $Button_Musik_Root
    ;MsgBox(0,$msg,"2" & @crlf)
    Case $msg = $Button_Musik_Up
    ;MsgBox(0,$msg,"3" & @crlf)
    Case $msg = $Button_Create
    ;MsgBox(0,$msg,"4" & @crlf)
    Case $msg = $Button_Act
    ;MsgBox(0,$msg,"5" & @crlf)
    Case $msg = $Button_Copy_Folder
    ;MsgBox(0,$msg,"6" & @crlf)
    Case $msg = $Button_Replace_Folder
    ;MsgBox(0,$msg,"7" & @crlf)
    Case $msg = $Ordnername_Musik_rename_ID
    ;MsgBox(0,$msg,"8" & @crlf)
    ConsoleWrite("umbenennen" & @crlf)
    ConsoleWrite("fertig umbenennen" & @crlf)
    ;MsgBox(0,"Fertig 8",$msg)
    Case $msg = $Ordnername_Musik_neu_rename_ID
    ;MsgBox(0,$msg,"10" & @crlf)
    Case $msg = $Button_Hilfe
    ;MsgBox(0,$msg,"11" & @crlf)
    Case $msg = $GUI_EVENT_DROPPED
    ;MsgBox(0,$msg,"12" & @crlf)
    EndSelect
    WEnd

    [/autoit]

    mfg (Auto)Bert

  • Hab nur mal das Sleep rausgenommen, und

    [autoit]

    If $msg <> 0 Then FileWriteLine($file23,$msg)

    [/autoit]


    gemacht ,damit man es besser erkennen kann.

    Spoiler anzeigen

    Waschen
    -11
    -11
    -11
    -11
    -11
    -11
    -11
    -11
    -11
    -11
    -11
    -11
    -11
    -11
    -11
    -11
    -11
    -11
    -11
    -11
    -11
    -11
    -7
    13
    Löschen Start
    Löschen Ende
    -8
    -11
    -11
    -11
    -11
    -11
    -11
    -11
    -11
    -7
    -8
    -11
    -11
    -11
    -11
    -11
    -11
    -11
    -11
    -11
    -11
    -11
    -11
    -11
    -11
    -11
    -11
    -11
    -11
    -11
    -11
    -3

    Bei mir funktioniert alles ?(

  • Danke für Eure Antworten und den Tipp mit dem Consolwrite. Jetzt wirds für mich aber spannend, denn ich bekomme folgendes Ergebniss:

    Eingabe:

    "X" drücken

    rechts weißes Feld anklicken und "1" und "ENTER" tippen

    Programm schließen

    ---------------------------------------

    Ergebnis:

    Löschen Start
    Löschen Ende
    umbenennen
    fertig umbenennen
    Löschen Start
    Löschen Ende
    Exit

    Warum wird bei mir wieder Löschen aufgerufen, obwohl ich das gar nicht gemacht habe? Ist das bei Euch anders???

  • Erstaunlicherweise wird das durch das GUICtrlSetBkColor hinter dem Button hervorgerufen. Ich glaube nicht, dass dieses Verhalten erwünscht ist.
    Wenn nochmal jemand drüberschaut und den Fehler nicht findet werd ich nen Bugreport schreiben.

    Spoiler anzeigen
    [autoit]

    $Version = "V1.13"

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

    #include <ButtonConstants.au3>
    #include <GUIConstants.au3>
    #include <EditConstants.au3>
    #include <WindowsConstants.au3>
    #include <array.au3>
    #include <ListviewConstants.au3>

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

    #include <GuiConstantsEx.au3>
    #include <GuiListView.au3>
    #include <GuiImageList.au3>

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

    Opt("WinTitleMatchMode", 3)
    Opt("SendKeyDelay", 1)

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

    $height = 300
    $top = (@DesktopHeight - $height - 60)
    $left = 0
    $width = @DesktopWidth
    GUICreate("Einsortieren " & $Version, $width, $height, $left, $top, $GUI_SS_DEFAULT_GUI, $WS_EX_ACCEPTFILES + $GUI_DROPACCEPTED)

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

    ; -------------------------
    ; Erzeuge linke Gruppe
    $randhor1 = 10
    $randhor2 = 40

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

    Global $Ordnername_Musik_neu = GUICtrlCreateInput("", 40, 50, ($width / 2) - $randhor2 - 2 * 40, 30, $ES_READONLY)
    GUICtrlSetState(-1, $GUI_DROPACCEPTED)
    GUICtrlSetFont(-1, "14")
    Global $Ordnername_Musik_neu_rename_ID = GUICtrlCreateInput("", 40, 90, ($width / 2) - $randhor2 - 2 * 40, 30)
    GUICtrlSetFont(-1, "14")

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

    Global $Informationen_Musik_neu_ID = GUICtrlCreateEdit("", 40, 150, ($width / 2) - $randhor2 - 2 * 40, 120, $ES_READONLY)
    GUICtrlSetFont(-1, "14")

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

    ; -------------------------
    ; Erzeuge rechte Gruppe
    GUICtrlCreateGroup("Musikbibliothek: " & "\", $width / 2 + $randhor2, 20, (($width - 2 * ($randhor1 + $randhor2)) / 2), $height - 2 * 20)
    GUICtrlSetFont(-1, "14")
    Global $Ordnername_Musik = GUICtrlCreateInput("", $width / 2 + 80, 50, ($width / 2) - $randhor2 - 2 * 40, 30, $ES_READONLY)
    GUICtrlSetState(-1, $GUI_DROPACCEPTED)
    GUICtrlSetFont(-1, "14")
    Global $Ordnername_Musik_rename_ID = GUICtrlCreateInput("", $width / 2 + 80, 90, ($width / 2) - $randhor2 - 2 * 40, 30)
    GUICtrlSetFont(-1, "14")

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

    Global $Informationen_Musik_ID = GUICtrlCreateEdit("", $width / 2 + 80, 150, ($width / 2) - $randhor2 - 2 * 40, 120, $ES_READONLY)
    GUICtrlSetFont(-1, "14")

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

    ; Erzeuge Buttons in der Mitte
    Global $Button_Act = GUICtrlCreateButton("Reload", $width / 2 - 40, 10, 80, 40)
    ;GUICtrlSetFont(-1,"18")

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

    Global $Button_Copy_Folder = GUICtrlCreateButton("Kopiere Ordner", $width / 2 - 40, 100, 80, 40)
    ;GUICtrlSetFont(-1,"14")
    GUICtrlSetBkColor(-1, "0xAAAAAA")

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

    Global $Button_Replace_Folder = GUICtrlCreateButton("Ersetze Ordner", $width / 2 - 40, 150, 80, 40)
    ;GUICtrlSetFont(-1,"18")
    GUICtrlSetBkColor(-1, "0xAAAAAA")

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

    Global $Button_Delete = GUICtrlCreateButton("X", $width / 2 - 120, 10, 40, 40)
    MsgBox(0, "", "Delete: " & $Button_Delete & @CRLF & "Musik: " & $Ordnername_Musik_rename_ID)
    GUICtrlSetFont(-1, "18")
    GUICtrlSetBkColor(-1, "0xAAAAAA")

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

    Global $Button_Musik_Up = GUICtrlCreateButton("Up", $width - 160, 10, 40, 40)
    Global $Button_Musik_Root = GUICtrlCreateButton("Root", $width - 120, 10, 40, 40)
    Global $Button_Create = GUICtrlCreateButton("Create", $width - 80, 10, 40, 40)

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

    Global $Button_Hilfe = GUICtrlCreateButton("Hilfe", $width / 2 - 40, 250, 80, 40)
    ; Suchvorschläge werden hier abgelegt
    Global $searchresult[1000]
    Global $search_index = 0

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

    GUISetState()

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

    ConsoleWrite("Waschen" & @CRLF)

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

    While 1
    $msg = GUIGetMsg()
    If $msg > 0 Then ConsoleWrite($msg & @CRLF)
    ;MsgBox(0,"msg",$msg,1)
    Select
    Case $msg = $Button_Delete
    MsgBox(0, "", "Delete", 1)
    ConsoleWrite("Löschen Start" & @CRLF)
    ConsoleWrite("Löschen Ende" & @CRLF)
    Case $msg = $GUI_EVENT_CLOSE
    Exit
    Case $msg = $Button_Musik_Root
    ;MsgBox(0,$msg,"2")
    Case $msg = $Button_Musik_Up
    ;MsgBox(0,$msg,"3")
    Case $msg = $Button_Create
    ;MsgBox(0,$msg,"4")
    Case $msg = $Button_Act
    ;MsgBox(0,$msg,"5")
    Case $msg = $Button_Copy_Folder
    ;MsgBox(0,$msg,"6")
    Case $msg = $Button_Replace_Folder
    ;MsgBox(0,$msg,"7")
    Case $msg = $Ordnername_Musik_rename_ID
    ;MsgBox(0,$msg,"8")
    ConsoleWrite("umbenennen" & @CRLF)
    ConsoleWrite("fertig umbenennen" & @CRLF)
    ;MsgBox(0,"Fertig 8",$msg)
    Case $msg = $Ordnername_Musik_neu_rename_ID
    ;MsgBox(0,$msg,"10")
    Case $msg = $Button_Hilfe
    MsgBox(0, $msg, "11")
    Case $msg = $GUI_EVENT_DROPPED
    ;MsgBox(0,$msg,"12")
    EndSelect
    WEnd
    Exit

    [/autoit]

    X anklicken -> was ins rechte input schreiben, schließen.

    das gleiche nochmal mit auskommentierter Zeile 67, danke

  • Hallo SEuBo,

    ich hatte schon einen Workaround mit einem unsichtbaren Button, indem ich in der while Schleife immer wieder den State $GUI_DEFBUTTON zugewiesen habe. Damit tritt der Fehler nicht mehr auf. Aber es ist einfacher und vor allem programmiertechnisch sauberer wenn man einfach die Farbzuweisung weglässt.
    Ich wollte dost0011 schon empfehlen auf den OnEvent-Modus umzusteigen, da ich dort ein so seltsames Verhalten noch nie hatte,

    Übrigens der Effekt tritt natürlich auch bei den beiden anderen Buttons auf, falls sie anstelle dieses Buttons zuvor geklickt werden.

    mfg (Auto)Bert