$SES_PASSWORD Text zeigen aber nicht das Passwort?

  • Hallo zusammen!

    Ich hab mal ne Frage zu folgendem Code.

    [autoit]


    $passwort = GUICtrlCreateInput("Überschreib diesen Text mit deinem Passwort", 150, 152, 319, 21, $ES_PASSWORD)

    [/autoit]


    Ich hab in der InputBox jetzt ein Text stehen, welcher auch angezeigt werden soll. Wenn der User sein Passwort eintippt soll man das aber nicht erkennen.
    Gibt es da eine Möglichkeit?

    Vielen Dank!

    Gruß
    Sirius

    3 Mal editiert, zuletzt von Sirius (5. März 2013 um 09:40)

  • Hi Chesstiger!

    Vielen Dank für deine schnelle Hilfe!
    Leider bin ich Anfänger, hab jetzt versucht deinen Vorschlag umzusetzen, aber leider ohne Erfolg.
    Kannst du vielleicht ein Beispiel zeigen?

    Vielen Dank!

    Sirius

  • Klar.
    Müsste ungefähr so gehen:

    Spoiler anzeigen
    [autoit]


    #include <EditConstants.au3>
    $sPWText = "Ihr Passwort..."

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

    $hGUI = GUICreate("Test", 250, 250)
    $idInput = GUICtrlCreateInput($sPWText, 50, 120, 150, 20)
    GUISetState()

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

    $bWritePW = False

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

    While True
    $iMsg = GUIGetMsg()
    Switch $iMsg
    Case -3
    Exit
    EndSwitch

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

    If GUICtrlRead($idInput) <> $sPWText Then
    If Not $bWritePW Then
    GUICtrlSetStyle($idInput, $ES_PASSWORD)
    GUICtrlSetData($idInput, StringReplace(GUICtrlRead($idInput), $sPWText, ""))
    $bWritePW = True
    EndIf
    EndIf
    WEnd

    [/autoit]

    Das Skript habe ich jetzt nicht getestet (Bin grad unter Linux), aber sollte klappen.

    chess

  • Probiere es mal damit:

    Spoiler anzeigen
    [autoit]


    ;coded by UEZ 2013
    #include <EditConstants.au3>
    #include <WinAPI.au3>
    #include <WindowsConstants.au3>
    #include <GUIConstantsEx.au3>
    Opt("MustDeclareVars", 1)

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

    Global $sInputText = "Bitte Passwort eingeben"
    Global Const $hGUI = GUICreate("Password", 369, 46)
    Global Const $idInputPWD = GUICtrlCreateInput($sInputText, 68, 12, 151, 21)
    GUICtrlSetColor(-1, 0xA0A0A0)
    Global Const $hInputPWD = GUICtrlGetHandle($idInputPWD)
    Global Const $idLabelPWD = GUICtrlCreateLabel("Passwort:", 18, 14, 44, 19)
    Global Const $idButtonGO = GUICtrlCreateButton("GO", 286, 10, 75, 25)
    ControlFocus($hGUI, "", $idLabelPWD)
    GUISetState(@SW_SHOW)

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

    GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")

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

    While 1
    Switch GUIGetMsg()
    Case $GUI_EVENT_CLOSE, $idButtonGO
    GUIRegisterMsg($WM_COMMAND, "")
    Exit
    EndSwitch
    WEnd

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

    Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam)
    #forceref $hWnd, $iMsg
    Local $iIDFrom = _WinAPI_LoWord($iwParam)
    Local $iCode = _WinAPI_HiWord($iwParam)
    Switch $ilParam
    Case $hInputPWD
    Switch $iCode
    Case $EN_KILLFOCUS
    If GUICtrlRead($iIDFrom) = "" Then
    GUICtrlSendMsg($iIDFrom, $EM_SETPASSWORDCHAR, 0, 0)
    GUICtrlSetData($iIDFrom, $sInputText)
    GUICtrlSetColor($iIDFrom, 0xA0A0A0)
    EndIf
    Case $EN_SETFOCUS
    GUICtrlSetColor($iIDFrom, 0)
    GUICtrlSetData($iIDFrom, "")
    GUICtrlSendMsg($iIDFrom, $EM_SETPASSWORDCHAR, 9679, 0)
    EndSwitch
    EndSwitch
    Return "GUI_RUNDEFMSG"
    EndFunc ;==>WM_COMMAND

    [/autoit]

    Gruß,
    UEZ

    Auch am Arsch geht ein Weg vorbei...

    ¯\_(ツ)_/¯

  • Hi.

    Vielen Dank für eure Antworten. Die Version von UEZ bekomme ich irgendwie nicht in meinem Script unter. Es funktioniert, aber dann funzt der Rest meines Scripts nicht mehr. :(
    Chesstiger, dein Vorschlag funktioniert nicht richtig. Das Passwort wird sichtbar angezeigt.
    Da mir diese Variante von Chesstiger besser gefällt, bitte ich dich nochmal nach zu schauen, warum das Passwort angezeigt wird.
    Dann könnte ich es so machen.

    Vielen Dank!

    Gruß
    Sirius

    • Offizieller Beitrag

    Das Problem hatte ich auch schonmal. Das Inputfeld kann man mit GUICtrlSetStyle später nicht in ein Passwordfeld "umwandeln".
    Es funktioniert aber mit GUICtrlSendMsg (siehe unten):

    Spoiler anzeigen
    [autoit]


    #include <EditConstants.au3>

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

    $sPWText = "Ihr Passwort..."

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

    $hGUI = GUICreate("Test", 250, 250)
    $idInput = GUICtrlCreateInput($sPWText, 50, 120, 150, 20)
    GUISetState()

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

    $bWritePW = False

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

    While True
    $iMsg = GUIGetMsg()
    Switch $iMsg
    Case -3
    Exit
    EndSwitch

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

    If GUICtrlRead($idInput) <> $sPWText Then
    If Not $bWritePW Then
    ;~ GUICtrlSetStyle($idInput, $ES_PASSWORD)
    GUICtrlSendMsg($idInput, $EM_SETPASSWORDCHAR, Asc('*'), 0)
    GUICtrlSetData($idInput, StringReplace(GUICtrlRead($idInput), $sPWText, ""))
    $bWritePW = True
    EndIf
    EndIf
    WEnd

    [/autoit]
  • Hi,

    wie wärs es mit Folgendem?:

    [autoit]

    $idInput = GUICtrlCreateInput($sPWText, 50, 120, 150, 20, BitOR("", $ES_PASSWORD))

    [/autoit]

    Gruß
    x0r

    Simon nörgelt, Simon nervt - aber Simon verbessert die Welt. Glaubt er.

  • Moin Moin.

    Hab leider das selbe Problem wie mit WM_COMMAND. Der Rest vom Script funzt leider nicht mehr.
    Hab schon viel versucht, aber ich bekomme es nicht ans laufen.

    Hier mein Code

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

    #include <Misc.au3>
    #include <ButtonConstants.au3>
    #include <EditConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>
    #Include <SendMessage.au3>

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

    $sPWText = "Ihr Passwort"
    $sIPText = "Ihre IP"

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

    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Test VNC", 621, 437, 189, 119)
    $Button1 = GUICtrlCreateButton("VNC-Viewer starten", 192, 72, 225, 33)
    $IP = GUICtrlCreateInput($sIPText, 224, 120, 169, 21)
    $Passwort = GUICtrlCreateInput($sPWText, 224, 152, 169, 21)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

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

    $bWritePW = False

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

    While True
    $iMsg = GUIGetMsg()
    Switch $iMsg
    Case -3
    Exit
    EndSwitch

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

    If GUICtrlRead($Passwort) <> $sPWText Then
    If Not $bWritePW Then
    GUICtrlSendMsg($Passwort, $EM_SETPASSWORDCHAR, Asc('*'), 0)
    GUICtrlSetData($Passwort, StringReplace(GUICtrlRead($Passwort), $sPWText, ""))
    $bWritePW = True
    EndIf
    EndIf
    WEnd

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

    Func vncstart()
    ShellExecute("C:\Programme\RealVNC\VNC Viewer\vncviewer.exe")
    WinActivate("VNC Viewer")
    $PCip = GUICtrlRead($IP)
    Sleep(200)
    Send ($PCip & "{Enter}")
    WinWaitActive("VNC Viewer - Authentication")
    $vncpass = GUICtrlRead($Passwort)
    Sleep(150)
    Send ($vncpass & "{Enter}")
    EndFunc

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

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

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

    EndSwitch

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

    WEnd

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

    Das mit dem Passwort und dem Text funktioniert, aber leider ShellExecute mit VNC nicht mehr!

    Wo ist der Fehler, was mache ich falsch?

    Vielen Dank!

    Gruß
    Sirius

  • Moin!

    Es gibt auch noch Labels, mit denen man Inputboxen (und sonst auch alles) kennzeichnen kann, also warum nicht einfach die Box permanent als PW-Box und zusätzlich noch eins für den Benutzernamen im Klartext (falls es sowas gibt), je ein Label drüber und gut ist? :)

    Gruß
    x0r

    Simon nörgelt, Simon nervt - aber Simon verbessert die Welt. Glaubt er.

  • Und da ich gerade Lust hatte, hier in ordentlich :rolleyes:

    Spoiler anzeigen
    [autoit]

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

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

    Global $iMsg
    Global $bWritePW = False
    Global $sPW = "Ihr Passwort"
    Global $sIP = "Ihre IP"

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

    Global $hGui = GUICreate("Test VNC", 621, 437, 189, 119)
    Global $cStart = GUICtrlCreateButton("VNC-Viewer starten", 192, 72, 225, 33)
    Global $cIP = GUICtrlCreateInput($sIP, 224, 120, 169, 21)
    Global $cPassword = GUICtrlCreateInput($sPW, 224, 152, 169, 21)
    GUISetState()

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

    While 1
    If GUICtrlRead($cPassword) <> $sPW And Not $bWritePW Then
    GUICtrlSendMsg($cPassword, $EM_SETPASSWORDCHAR, Asc('*'), 0)
    GUICtrlSetData($cPassword, StringReplace(GUICtrlRead($cPassword), $sPW, ""))
    $bWritePW = True
    EndIf

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

    $iMsg = GUIGetMsg()
    Switch $iMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $cStart
    _StartVNC()
    EndSwitch
    WEnd

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

    Func _StartVNC()
    ShellExecute("C:\Programme\RealVNC\VNC Viewer\vncviewer.exe")
    WinActivate("VNC Viewer")
    Sleep(200)
    Send(GUICtrlRead($cIP) & "{Enter}")
    WinWaitActive("VNC Viewer - Authentication")
    Sleep(150)
    Send(GUICtrlRead($cPassword) & "{Enter}")
    EndFunc ;==>vncstart

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

    GUICtrlSendMsg($test_Input2, 0x1501, 0, "Hersteller")

    [/autoit]


    Aber warum machst du das nicht als Cuebanner?

    Spoiler anzeigen
    [autoit]

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

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

    Global $iMsg
    Global $sPW = "Ihr Passwort"
    Global $sIP = "Ihre IP"

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

    Global $hGui = GUICreate("Test VNC", 621, 437, 189, 119)
    Global $cStart = GUICtrlCreateButton("VNC-Viewer starten", 192, 72, 225, 33)
    Global $cIP = GUICtrlCreateInput("", 224, 120, 169, 21)
    GUICtrlSendMsg(-1, 0x1501, 0, $sIP)
    Global $cPassword = GUICtrlCreateInput("", 224, 152, 169, 21, $ES_PASSWORD)
    GUICtrlSendMsg(-1, 0x1501, 0, $sPW)
    GUISetState()

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

    While 1
    $iMsg = GUIGetMsg()
    Switch $iMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $cStart
    _StartVNC()
    EndSwitch
    WEnd

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

    Func _StartVNC()
    ShellExecute("C:\Programme\RealVNC\VNC Viewer\vncviewer.exe")
    WinActivate("VNC Viewer")
    Sleep(200)
    Send(GUICtrlRead($cIP) & "{Enter}")
    WinWaitActive("VNC Viewer - Authentication")
    Sleep(150)
    Send(GUICtrlRead($cPassword) & "{Enter}")
    EndFunc ;==>vncstart

    [/autoit]

    Einmal editiert, zuletzt von m-obi (5. März 2013 um 09:56)

  • Probiere dieses mal aus:

    Spoiler anzeigen
    [autoit]


    ;coded by UEZ 2013
    #include <EditConstants.au3>
    #include <WinAPI.au3>
    #include <WindowsConstants.au3>
    #include <GUIConstantsEx.au3>
    Opt("MustDeclareVars", 1)

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

    Global $sInputText = "Bitte Passwort eingeben"
    Global $sInputIP = "IP Adresse"
    Global Const $hGUI = GUICreate("Password", 329, 116)
    Global Const $idLabelHeadline = GUICtrlCreateLabel("VNC Starter", 110, 10, 150)
    GUICtrlSetFont(-1, 18, 400, 0, "Arial", 4)
    Global Const $idLabelIP = GUICtrlCreateLabel("IP Adr.", 30, 54, 44, 29)
    Global Const $idInputIP = GUICtrlCreateInput($sInputIP, 68, 52, 151, 21)
    GUICtrlSetColor(-1, 0xA0A0A0)
    Global Const $hInputIP = GUICtrlGetHandle($idInputIP)
    Global Const $idLabelPWD = GUICtrlCreateLabel("Passwort:", 18, 84, 44, 19)
    Global Const $idInputPWD = GUICtrlCreateInput($sInputText, 68, 82, 151, 21)
    GUICtrlSetColor(-1, 0xA0A0A0)
    Global Const $hInputPWD = GUICtrlGetHandle($idInputPWD)
    Global Const $idButtonGO = GUICtrlCreateButton("Start VNC", 241, 80, 75, 25)
    ControlFocus($hGUI, "", $idLabelPWD)
    GUISetState(@SW_SHOW)

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

    GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")

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

    While 1
    Switch GUIGetMsg()
    Case $GUI_EVENT_CLOSE
    GUIRegisterMsg($WM_COMMAND, "")
    GUIDelete()
    Exit
    Case $idButtonGO
    If Not IPChk(GUICtrlRead($idInputIP)) Then
    MsgBox(16, "FEHLER", "Bitte IP Adresse überprüfen!", 30)
    ContinueLoop
    EndIf
    If GUICtrlRead($idInputPWD) = "" Or GUICtrlRead($idInputPWD) = $sInputText Then
    MsgBox(16, "FEHLER", "Passwort ist gleich '" & $sInputText & "'", 30)
    ContinueLoop
    EndIf
    GUIRegisterMsg($WM_COMMAND, "")
    vncstart(GUICtrlRead($idInputIP), GUICtrlRead($idInputPWD))
    GUIDelete()
    Exit
    EndSwitch
    WEnd

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

    Func IPChk($sIP)
    Local $sRegExPattern = _
    "^([01]?\d\d?|2[0-4]\d|25[0-5])\." & _
    "([01]?\d\d?|2[0-4]\d|25[0-5])\." & _
    "([01]?\d\d?|2[0-4]\d|25[0-5])\." & _
    "([01]?\d\d?|2[0-4]\d|25[0-5])$"
    Local $a = StringRegExp($sIP, $sRegExPattern, 3)
    If @error Then Return 0
    Return 1
    EndFunc

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

    Func vncstart($sIP, $sPwd)
    ShellExecute("C:\Programme\RealVNC\VNC Viewer\vncviewer.exe")
    WinActivate("VNC Viewer")
    Sleep(200)
    Send($sIP & "{Enter}")
    WinWaitActive("VNC Viewer - Authentication")
    Sleep(150)
    Send($sPwd & "{Enter}")
    EndFunc ;==>vncstart

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

    Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam)
    #forceref $hWnd, $iMsg
    Local $iIDFrom = _WinAPI_LoWord($iwParam)
    Local $iCode = _WinAPI_HiWord($iwParam)
    Switch $ilParam
    Case $hInputPWD
    Switch $iCode
    Case $EN_KILLFOCUS
    If GUICtrlRead($iIDFrom) = "" Then
    GUICtrlSendMsg($iIDFrom, $EM_SETPASSWORDCHAR, 0, 0)
    GUICtrlSetData($iIDFrom, $sInputText)
    GUICtrlSetColor($iIDFrom, 0xA0A0A0)
    EndIf
    Case $EN_SETFOCUS
    GUICtrlSetColor($iIDFrom, 0)
    GUICtrlSetData($iIDFrom, "")
    GUICtrlSendMsg($iIDFrom, $EM_SETPASSWORDCHAR, 9679, 0)
    EndSwitch
    Case $hInputIP
    Switch $iCode
    Case $EN_KILLFOCUS
    If GUICtrlRead($iIDFrom) = "" Then
    GUICtrlSetData($iIDFrom, $sInputIP)
    GUICtrlSetColor($iIDFrom, 0xA0A0A0)
    EndIf
    Case $EN_SETFOCUS
    GUICtrlSetColor($iIDFrom, 0)
    If GUICtrlRead($iIDFrom) = "" Or GUICtrlRead($iIDFrom) = $sInputIP Then GUICtrlSetData($iIDFrom, "")
    EndSwitch
    EndSwitch
    Return "GUI_RUNDEFMSG"
    EndFunc ;==>WM_COMMAND

    [/autoit]

    Gruß,
    UEZ

    Auch am Arsch geht ein Weg vorbei...

    ¯\_(ツ)_/¯