Mit GUICtrlRead mehrere input felder auslesen

  • Hallo ich habe eine Frage bezüglich der Funktion GUICtrlRead.
    Wie kann ich mit dieser funktion mehrere input felder auslesen?

    Vielen Dank im Vorraus schonmal für eure Antworten. :rock:

    Einmal editiert, zuletzt von Molaynox (19. September 2010 um 20:16)

  • "Beispiel"
    [autoit]

    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>
    #include <array.au3>
    Global $aInput[4]
    $Form1 = GUICreate("Form1", 500, 500, -1, -1)
    $aInput[0] = GUICtrlCreateInput("", 20, 20)
    $aInput[1] = GUICtrlCreateInput("", 20, 40)
    $aInput[2] = GUICtrlCreateInput("", 20, 60)
    $aInput[3] = GUICtrlCreateInput("", 20, 80)
    $Button1 = GUICtrlCreateButton("start", 260, 50)
    GUISetState(@SW_SHOW)

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $Button1
    Dim $aOut[1]
    For $i = 0 To UBound($aInput)-1
    _ArrayAdd($aOut, GUICtrlRead($aInput[$i]))
    Next
    _ArrayDisplay($aOut)
    EndSwitch
    WEnd

    [/autoit] [autoit][/autoit] [autoit][/autoit]
  • dann musst du für jedes auszulesende Input eine Variable erstellen und mit GuiCtrlRead auslesen bzw. die Rückgaben mit & in einer Variablen verknüpfen, wo ist das Problem,

    Edit: auf Verknüpfun abgeändertes Beispiel von i2c angehängt:

    [autoit]

    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>
    #include <array.au3>
    Global $aInput[4]
    $Form1 = GUICreate("Form1", 500, 500, -1, -1)
    $aInput[0] = GUICtrlCreateInput("", 20, 20)
    $aInput[1] = GUICtrlCreateInput("", 20, 40)
    $aInput[2] = GUICtrlCreateInput("", 20, 60)
    $aInput[3] = GUICtrlCreateInput("", 20, 80)
    $Button1 = GUICtrlCreateButton("start", 260, 50)
    GUISetState(@SW_SHOW)

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $Button1
    $Out = ""
    For $i = 0 To UBound($aInput)-1
    $Out &= GUICtrlRead($aInput[$i])
    Next
    MsgBox(0,"",""$Out)
    EndSwitch
    WEnd

    [/autoit]

    mfg autoBert

    Einmal editiert, zuletzt von autoBert (19. September 2010 um 19:38)

  • Also das hier ist der script für den ich dass brauche. (den habe ich im internet gefunden):

    Spoiler anzeigen
    [autoit]

    #include <ButtonConstants.au3>
    #include <EditConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>
    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Form1", 292, 315, 192, 124)
    $Absenden = GUICtrlCreateButton("Absenden", 40, 264, 201, 33, $WS_GROUP)
    $Input1 = GUICtrlCreateInput("Vorname", 72, 24, 137, 21)
    $Input2 = GUICtrlCreateInput("Nachnahme", 72, 64, 137, 21)
    $Input3 = GUICtrlCreateInput("Betreff", 72, 104, 137, 21)
    $Edit1 = GUICtrlCreateEdit("", 72, 136, 137, 105)
    GUICtrlSetData(-1, "Text")
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

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

    Func _Senden ()
    ProgressOn ("E-mail","Email wird versendet! Bitte warten!","Einstellungen auslesen.",-1,-1,2)

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

    $Bericht = GUICtrlRead($Input)
    $Bericht2 = GUICtrlRead($Input2)
    $Bericht3 = GUICtrlRead($Input3)
    $Bericht4 = GUICtrlRead($Edit1)
    ;
    ;##################################
    ; Include
    ;##################################

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

    ;##################################
    ; Variables
    ;##################################
    $SmtpServer = "" ; address for the smtp-server to use - REQUIRED
    $FromName = "" ; name from who the email was sent
    $FromAddress = "" ; address from where the mail should come
    $ToAddress = "" ; destination address of the email - REQUIRED
    $Subject = "" ; subject from the email - can be anything you want it to be
    $Body = $Bericht ; the messagebody from the mail - can be left blank but then you get a blank mail
    $AttachFiles = "" ; the file you want to attach- leave blank if not needed
    $CcAddress = "" ; address for cc - leave blank if not needed
    $BccAddress = "" ; address for bcc - leave blank if not needed
    $Importance = "Normal" ; Send message priority: "High", "Normal", "Low"
    $Username = "" ; username for the account used from where the mail gets sent - REQUIRED
    $Password = "" ; password for the account used from where the mail gets sent - REQUIRED
    $IPPort = 25 ; port used for sending the mail
    $ssl = 0 ; enables/disables secure socket layer sending - put to 1 if using httpS
    ;~ $IPPort=465 ; GMAIL port used for sending the mail
    ;~ $ssl=1 ; GMAILenables/disables secure socket layer sending - put to 1 if using httpS

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

    ;##################################
    ; Script
    ;##################################

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

    ProgressSet (50 , "E-mail wird versendet!")
    $rc = _INetSmtpMailCom($SmtpServer, $FromName, $FromAddress, $ToAddress, $Subject, $Body, $AttachFiles, $CcAddress, $BccAddress, $Importance, $Username, $Password, $IPPort, $ssl)
    If @error Then
    MsgBox(0, "Error sending message", "Error code:" & @error & " Description:" & $rc)
    EndIf
    ProgressSet (100 , "Fertig!")
    Sleep (100)
    MsgBox (64,"E-mail","E-mail erfolgreich versendet!")
    ProgressOff ()
    EndFunc
    ;
    ; The UDF
    Func _INetSmtpMailCom($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject = "", $as_Body = "", $s_AttachFiles = "", $s_CcAddress = "", $s_BccAddress = "", $s_Importance="Normal", $s_Username = "", $s_Password = "", $IPPort = 25, $ssl = 0)
    Local $objEmail = ObjCreate("CDO.Message")
    $objEmail.From = '"' & $s_FromName & '" <' & $s_FromAddress & '>'
    $objEmail.To = $s_ToAddress
    Local $i_Error = 0
    Local $i_Error_desciption = ""
    If $s_CcAddress <> "" Then $objEmail.Cc = $s_CcAddress
    If $s_BccAddress <> "" Then $objEmail.Bcc = $s_BccAddress
    $objEmail.Subject = $s_Subject
    If StringInStr($as_Body, "<") And StringInStr($as_Body, ">") Then
    $objEmail.HTMLBody = $as_Body
    Else
    $objEmail.Textbody = $as_Body & @CRLF
    EndIf
    If $s_AttachFiles <> "" Then
    Local $S_Files2Attach = StringSplit($s_AttachFiles, ";")
    For $x = 1 To $S_Files2Attach[0]
    $S_Files2Attach[$x] = _PathFull($S_Files2Attach[$x])
    ConsoleWrite('@@ Debug(62) : $S_Files2Attach = ' & $S_Files2Attach & @LF & '>Error code: ' & @error & @LF) ;### Debug Console
    If FileExists($S_Files2Attach[$x]) Then
    $objEmail.AddAttachment ($S_Files2Attach[$x])
    Else
    ConsoleWrite('!> File not found to attach: ' & $S_Files2Attach[$x] & @LF)
    SetError(1)
    Return 0
    EndIf
    Next
    EndIf
    $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
    $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = $s_SmtpServer
    If Number($IPPort) = 0 then $IPPort = 25
    $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = $IPPort
    ;Authenticated SMTP
    If $s_Username <> "" Then
    $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
    $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") = $s_Username
    $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = $s_Password
    EndIf
    If $ssl Then
    $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
    EndIf
    ;Update settings
    $objEmail.Configuration.Fields.Update
    ; Set Email Importance
    Switch $s_Importance
    Case "High"
    $objEmail.Fields.Item ("urn:schemas:mailheader:Importance") = "High"
    Case "Normal"
    $objEmail.Fields.Item ("urn:schemas:mailheader:Importance") = "Normal"
    Case "Low"
    $objEmail.Fields.Item ("urn:schemas:mailheader:Importance") = "Low"
    EndSwitch
    $objEmail.Fields.Update
    ; Sent the Message
    $objEmail.Send
    If @error Then
    SetError(2)
    Return $oMyRet[1]
    EndIf
    $objEmail=""
    EndFunc ;==>_INetSmtpMailCom
    ;
    ;
    ; Com Error Handler
    Func MyErrFunc()
    $HexNumber = Hex($oMyError.number, 8)
    $oMyRet[0] = $HexNumber
    $oMyRet[1] = StringStripWS($oMyError.description, 3)
    ConsoleWrite("### COM Error ! Number: " & $HexNumber & " ScriptLine: " & $oMyError.scriptline & " Description:" & $oMyRet[1] & @LF)
    SetError(1); something to check for when this function returns
    Return
    EndFunc ;==>MyErrFunc

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

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

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

    EndSwitch
    WEnd

    [/autoit]


    Was muss ich hier noch ändern damit er funktioniert???? (die felder wo ich smtp server und so eintragen muss mache ich später)

  • Keine Ahnung warum du da eine einzelne Variable benötigst.

    Spoiler anzeigen
    [autoit]

    #include <ButtonConstants.au3>
    #include <EditConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>
    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Form1", 292, 315, 192, 124)
    $Absenden = GUICtrlCreateButton("Absenden", 40, 264, 201, 33, $WS_GROUP)
    $Input1 = GUICtrlCreateInput("An", 72, 24, 137, 21)
    ;$Input2 = GUICtrlCreateInput("Nachnahme", 72, 64, 137, 21)
    $Input3 = GUICtrlCreateInput("Betreff", 72, 104, 137, 21)
    $Edit1 = GUICtrlCreateEdit("", 72, 136, 137, 105)
    GUICtrlSetData(-1, "Text")
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

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

    Func _Senden ()
    ProgressOn ("E-mail","Email wird versendet! Bitte warten!","Einstellungen auslesen.",-1,-1,2)
    ;
    ;##################################
    ; Include
    ;##################################

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

    ;##################################
    ; Variables
    ;##################################
    $SmtpServer = "" ; address for the smtp-server to use - REQUIRED
    $FromName = "" ; name from who the email was sent
    $FromAddress = "" ; address from where the mail should come
    $ToAddress = GUICtrlRead($input1) ; destination address of the email - REQUIRED
    $Subject = GUICtrlRead($input3) ; subject from the email - can be anything you want it to be
    $Body = GUICtrlRead($Edit1) ; the messagebody from the mail - can be left blank but then you get a blank mail
    $AttachFiles = "" ; the file you want to attach- leave blank if not needed
    $CcAddress = "" ; address for cc - leave blank if not needed
    $BccAddress = "" ; address for bcc - leave blank if not needed
    $Importance = "Normal" ; Send message priority: "High", "Normal", "Low"
    $Username = "" ; username for the account used from where the mail gets sent - REQUIRED
    $Password = "" ; password for the account used from where the mail gets sent - REQUIRED
    $IPPort = 25 ; port used for sending the mail
    $ssl = 0 ; enables/disables secure socket layer sending - put to 1 if using httpS
    ;~ $IPPort=465 ; GMAIL port used for sending the mail
    ;~ $ssl=1 ; GMAILenables/disables secure socket layer sending - put to 1 if using httpS

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

    ;##################################
    ; Script
    ;##################################

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

    ProgressSet (50 , "E-mail wird versendet!")
    $rc = _INetSmtpMailCom($SmtpServer, $FromName, $FromAddress, $ToAddress, $Subject, $Body, $AttachFiles, $CcAddress, $BccAddress, $Importance, $Username, $Password, $IPPort, $ssl)
    If @error Then
    MsgBox(0, "Error sending message", "Error code:" & @error & " Description:" & $rc)
    EndIf
    ProgressSet (100 , "Fertig!")
    Sleep (100)
    MsgBox (64,"E-mail","E-mail erfolgreich versendet!")
    ProgressOff ()
    EndFunc
    ;
    ; The UDF
    Func _INetSmtpMailCom($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject = "", $as_Body = "", $s_AttachFiles = "", $s_CcAddress = "", $s_BccAddress = "", $s_Importance="Normal", $s_Username = "", $s_Password = "", $IPPort = 25, $ssl = 0)
    Local $objEmail = ObjCreate("CDO.Message")
    $objEmail.From = '"' & $s_FromName & '" <' & $s_FromAddress & '>'
    $objEmail.To = $s_ToAddress
    Local $i_Error = 0
    Local $i_Error_desciption = ""
    If $s_CcAddress <> "" Then $objEmail.Cc = $s_CcAddress
    If $s_BccAddress <> "" Then $objEmail.Bcc = $s_BccAddress
    $objEmail.Subject = $s_Subject
    If StringInStr($as_Body, "<") And StringInStr($as_Body, ">") Then
    $objEmail.HTMLBody = $as_Body
    Else
    $objEmail.Textbody = $as_Body & @CRLF
    EndIf
    If $s_AttachFiles <> "" Then
    Local $S_Files2Attach = StringSplit($s_AttachFiles, ";")
    For $x = 1 To $S_Files2Attach[0]
    $S_Files2Attach[$x] = _PathFull($S_Files2Attach[$x])
    ConsoleWrite('@@ Debug(62) : $S_Files2Attach = ' & $S_Files2Attach & @LF & '>Error code: ' & @error & @LF) ;### Debug Console
    If FileExists($S_Files2Attach[$x]) Then
    $objEmail.AddAttachment ($S_Files2Attach[$x])
    Else
    ConsoleWrite('!> File not found to attach: ' & $S_Files2Attach[$x] & @LF)
    SetError(1)
    Return 0
    EndIf
    Next
    EndIf
    $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
    $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = $s_SmtpServer
    If Number($IPPort) = 0 then $IPPort = 25
    $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = $IPPort
    ;Authenticated SMTP
    If $s_Username <> "" Then
    $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
    $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") = $s_Username
    $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = $s_Password
    EndIf
    If $ssl Then
    $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
    EndIf
    ;Update settings
    $objEmail.Configuration.Fields.Update
    ; Set Email Importance
    Switch $s_Importance
    Case "High"
    $objEmail.Fields.Item ("urn:schemas:mailheader:Importance") = "High"
    Case "Normal"
    $objEmail.Fields.Item ("urn:schemas:mailheader:Importance") = "Normal"
    Case "Low"
    $objEmail.Fields.Item ("urn:schemas:mailheader:Importance") = "Low"
    EndSwitch
    $objEmail.Fields.Update
    ; Sent the Message
    $objEmail.Send
    If @error Then
    SetError(2)
    Return $oMyRet[1]
    EndIf
    $objEmail=""
    EndFunc ;==>_INetSmtpMailCom
    ;
    ;
    ; Com Error Handler
    Func MyErrFunc()
    $HexNumber = Hex($oMyError.number, 8)
    $oMyRet[0] = $HexNumber
    $oMyRet[1] = StringStripWS($oMyError.description, 3)
    ConsoleWrite("### COM Error ! Number: " & $HexNumber & " ScriptLine: " & $oMyError.scriptline & " Description:" & $oMyRet[1] & @LF)
    SetError(1); something to check for when this function returns
    Return
    EndFunc ;==>MyErrFunc

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

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

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

    EndSwitch
    WEnd

    [/autoit]
  • Dann warst du bei der Suche nicht sehr erfolgreich bzw.:

    • du hast vergessen etwas zu kopieren
    • nachträglich etwas aus versehen gelöscht

    ,
    denn das Skript kann so nicht laufen. Suche hier im Forum da gibt es schon fertige Lösungen z.B.

    • schau in @Schnuffels Signatur
    • nono hat hier auf der selben UDF-Basis afair eine lauffähige Version hinbekommen

    einfach die boardeigene SuFu benutzen,

    mfg autoBert