GUI Input eingabe -> Controls erscheinen -> Input Zeichen löschen -> Controls verstecken

  • Hallo zusammen,

    Sorry erstmal für die vllt nicht so aussagekräftige Überschrift.

    erstmal mein Script:

    [autoit]

    #include <ButtonConstants.au3>
    #include <EditConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <ProgressConstants.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>
    $Form1_1 = GUICreate("Form1", 310, 220, 273, 249)
    $Input1 = GUICtrlCreateInput("", 24, 40, 121, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_PASSWORD))
    $Label1 = GUICtrlCreateLabel("Password:", 24, 16, 67, 22)
    GUICtrlSetFont(-1, 10, 800, 0, "Trebuchet MS")
    GUISetState(@SW_SHOW)
    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $Input1
    If GUICtrlRead($Input1) = "test" Then
    $Group1 = GUICtrlCreateGroup("Install Printer ", 24, 72, 273, 129)
    GUICtrlSetFont(-1, 9, 400, 0, "Trebuchet MS")
    $Button1 = GUICtrlCreateButton("Button1", 112, 168, 75, 17)
    $Label2 = GUICtrlCreateLabel("Install Generic / Text Only @ LPT1", 40, 104, 238, 22)
    GUICtrlSetFont(-1, 10, 400, 0, "Trebuchet MS")
    $Progress1 = GUICtrlCreateProgress(64, 136, 166, 9)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    Else
    MsgBox(16,"","Falsches Passwort")
    EndIf

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

    EndSwitch
    WEnd

    [/autoit]

    Das Problem was ich habe:

    Wenn ich "Test" eingebe und mit Enter bestätige erscheint die Group mit Button,Label und Progressbar.

    Soweit so gut.

    Ist es möglich wenn ich von "Test" nur das kleine "t" lösche das die Group usw. was vorher erschienen ist gelöscht bzw. versteckt wird?

    Danke schonmal für eure Hilfe

    Gruß Norman

    3 Mal editiert, zuletzt von Norman Bates (13. November 2012 um 02:07)

  • quick und vor allem dirty-lösung:

    Spoiler anzeigen
    [autoit]


    #include <ButtonConstants.au3>
    #include <EditConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <ProgressConstants.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>
    #include <WinAPI.au3>

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

    $Form1_1 = GUICreate("Form1", 310, 220, 273, 249)
    $Input1 = GUICtrlCreateInput("", 24, 40, 121, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_PASSWORD))
    $Label1 = GUICtrlCreateLabel("Password:", 24, 16, 67, 22)
    GUICtrlSetFont(-1, 10, 800, 0, "Trebuchet MS")
    $Group1 = GUICtrlCreateGroup("Install Printer ", 24, 72, 273, 129)
    GUICtrlSetFont(-1, 9, 400, 0, "Trebuchet MS")
    GUICtrlSetState(-1, $GUI_HIDE)
    $Button1 = GUICtrlCreateButton("Button1", 112, 168, 75, 17)
    GUICtrlSetState(-1, $GUI_HIDE)
    $Label2 = GUICtrlCreateLabel("Install Generic / Text Only @ LPT1", 40, 104, 238, 22)
    GUICtrlSetState(-1, $GUI_HIDE)
    GUICtrlSetFont(-1, 10, 400, 0, "Trebuchet MS")
    GUICtrlSetState(-1, $GUI_HIDE)
    $Progress1 = GUICtrlCreateProgress(64, 136, 166, 9)
    GUICtrlSetState(-1, $GUI_HIDE)
    GUICtrlCreateGroup("", -99, -99, 1, 1)

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

    GUISetState(@SW_SHOW)

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

    GUIRegisterMsg($WM_COMMAND, 'WM_COMMAND')

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit

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

    EndSwitch
    WEnd

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

    Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam)
    #forceref $hWnd, $iMsg
    Local $hWndFrom, $iIDFrom, $iCode
    $hWndFrom = $ilParam
    $iIDFrom = BitAND($iwParam, 0xFFFF) ; Low Word
    $iCode = BitShift($iwParam, 16) ; Hi Word
    Select
    Case $iCode; = 0x0
    Local $ID = _WinAPI_GetDlgCtrlID(ControlGetHandle($Form1_1, '', ControlGetFocus($Form1_1)))
    Switch $ID
    Case $input1
    If GUICtrlRead($Input1) = "test" Then
    GUICtrlSetState($Group1, $GUI_SHOW)
    GUICtrlSetState($Button1, $GUI_SHOW)
    GUICtrlSetState($Label2, $GUI_SHOW)
    GUICtrlSetState($Progress1, $GUI_SHOW)
    Else
    GUICtrlSetState($Group1, $GUI_HIDE)
    GUICtrlSetState($Button1, $GUI_HIDE)
    GUICtrlSetState($Label2, $GUI_HIDE)
    GUICtrlSetState($Progress1, $GUI_HIDE)
    EndIf

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

    EndSwitch
    EndSelect
    Return $GUI_RUNDEFMSG
    EndFunc ;==>WM_COMMAND

    [/autoit]
    • Offizieller Beitrag

    Ich habe das Skript von Torni mal noch etwas überarbeitet und kommentiert.

    Spoiler anzeigen
    [autoit]

    #include <EditConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>

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

    $Form1_1 = GUICreate("Form1", 310, 220, 273, 249)
    $Input1 = GUICtrlCreateInput("", 24, 40, 121, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_PASSWORD))
    $Label1 = GUICtrlCreateLabel("Password:", 24, 16, 67, 22)
    GUICtrlSetFont(-1, 10, 800, 0, "Trebuchet MS")
    $Group1 = GUICtrlCreateGroup("Install Printer ", 24, 72, 273, 129)
    GUICtrlSetFont(-1, 9, 400, 0, "Trebuchet MS")
    GUICtrlSetState(-1, $GUI_HIDE)
    $Button1 = GUICtrlCreateButton("Button1", 112, 168, 75, 17)
    GUICtrlSetState(-1, $GUI_HIDE)
    $Label2 = GUICtrlCreateLabel("Install Generic / Text Only @ LPT1", 40, 104, 238, 22)
    GUICtrlSetState(-1, $GUI_HIDE)
    GUICtrlSetFont(-1, 10, 400, 0, "Trebuchet MS")
    GUICtrlSetState(-1, $GUI_HIDE)
    $Progress1 = GUICtrlCreateProgress(64, 136, 166, 9)
    GUICtrlSetState(-1, $GUI_HIDE)
    GUICtrlCreateGroup("", -99, -99, 1, 1)

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

    GUISetState(@SW_SHOW)

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

    GUIRegisterMsg($WM_COMMAND, 'WM_COMMAND') ; == Registrieren der Windows-Message WM_COMMAND

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    EndSwitch
    WEnd

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

    Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam) ; == Auswerten der Windows-Message WM_COMMAND
    #forceref $hWnd, $iMsg
    Local $hWndFrom, $iIDFrom, $iCode
    $hWndFrom = $ilParam
    $iIDFrom = BitAND($iwParam, 0xFFFF) ; Low Word
    $iCode = BitShift($iwParam, 16) ; Hi Word
    ; == WENN ( Code=Änderung_im_Control ) UND ( CTRL-ID=$input1 )
    If $iCode = $EN_CHANGE And $iIDFrom = $input1 Then
    If GUICtrlRead($Input1) = "test" Then ; == WENN Ctrl-Inhalt = "test"
    _SetState($GUI_SHOW) ; == Ctrls zeigen
    Else ; == in jedem anderen Fall
    _SetState($GUI_HIDE) ; == Ctrls verstecken
    EndIf
    EndIf
    Return $GUI_RUNDEFMSG
    EndFunc ;==>WM_COMMAND

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

    Func _SetState($_iState)
    GUICtrlSetState($Group1, $_iState)
    GUICtrlSetState($Button1, $_iState)
    GUICtrlSetState($Label2, $_iState)
    GUICtrlSetState($Progress1, $_iState)
    EndFunc

    [/autoit]
  • Hallo zusammen,

    ich muss das Thema leider nochmal öffnen.

    ich habe eine HAUPT GUI mit der ich über ein MenuItem die GUI oben öffne nennen wir sie mal MenuItemGui.

    Meine Haupt GUI hat ein Input Feld.

    Die MenuItemGUI schliesse ich wie folgt:

    [autoit]

    Case $GUI_EVENT_CLOSE
    GUIDelete($MenuItemGUI)
    Exitloop

    [/autoit]

    Anschließend bin ich wieder in meiner HAUPT GUI nur das tut sich nichts mehr wenn ich den Inhalt aus dem Input Feld lesen will.

    Hat einer ne Idee woran das liegen kann.

    Ich würde auf die GUIRegisterMsg tippen aber sicher bin ich mir nicht.


    Gruß Norman