GUI Case danach wie weiter?

  • Hallo ich habe noch einmal eine Frage...

    Wenn ich eine GUI erstelle (mache ich mit Koda) dann kann ich ja den Text in meine au3 Datein übertragen...

    Dann taucht dort dieses Case auf...ich habe das schon gegoogelt usw. Da muss dann also case Button1 then hin oder so... Kann ich dann danach einfach weiter schreiben also z.B.

    Case Button1 then
    If Zahl1 = ... Then
    Blalalalal
    Else
    Blalalal
    Endif


    Kann ich das dort einfach dann so weiterschreiben?? ?(


    Danke

  • Ja!

    Und googeln brauchst du da nix. Musst dir nur die Hilfe ansehen, z.B. zu GUICreate.

  • so ich habe jetzt mal en bissle rumprobiert:

    [autoit]


    #include <GUIConstants.au3>

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

    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Vertretungsplan abrufen ", 257, 71, 193, 125)
    $Code = GUICtrlCreateInput("Code", 128, 8, 121, 21)
    $Label1 = GUICtrlCreateLabel("Startcode eingeben:", 24, 8, 100, 17)
    $Button1 = GUICtrlCreateButton("Skript Starten", 152, 32, 75, 25)
    $Label2 = GUICtrlCreateLabel("by Bastian Matthies", 0, 48, 104, 17)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $Button1
    If $Code = 1 Then
    MsgBox (0,"richtig","hghj")
    Else
    MsgBox (0,"Falsch","hjgjb")
    EndIf
    EndSwitch
    WEnd

    [/autoit]

    es kommt immer Falsch... ;(

    wie kann ich über die inputbox + Button ne Abfrage machen?
    danke :)

  • an welche stelle im skript muss das dann?

    ich habe mir die hilfe mal angesehen aber net gefunden wo das dann ein gefügt werden muss, damit z.B. die msgbox den Text anzeigt...

    also am ende will ich den wert aus der Box mit einem festgelegten vergleichen und das nur dann wenn der Button gedrückt wurde so als ok quasi...

  • Spoiler anzeigen
    [autoit]

    #include <GUIConstants.au3>

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

    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Vertretungsplan abrufen ", 257, 71, 193, 125)
    $Code = GUICtrlCreateInput("Code", 128, 8, 121, 21)
    $Label1 = GUICtrlCreateLabel("Startcode eingeben:", 24, 8, 100, 17)
    $Button1 = GUICtrlCreateButton("Skript Starten", 152, 32, 75, 25)
    $Label2 = GUICtrlCreateLabel("by Bastian Matthies", 0, 48, 104, 17)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $Button1
    If GUICtrlRead ($Code) = 1 Then ; <!--
    MsgBox (0,"richtig","hghj")
    Else
    MsgBox (0,"Falsch","hjgjb")
    EndIf
    EndSwitch
    WEnd

    [/autoit]

    Übrigens würde ich dir an dieser Stelle mal vom Koda abraten.
    Variablen wie "$Button1" sind schwerer zu lesen, als Braille mit Füßen.

  • Spoiler anzeigen
    [autoit]


    #include <GUIConstants.au3>
    #include <Array.au3>
    #include <String.au3>
    #include <Date.au3>
    #include <File.au3>

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

    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Vertretungsplan abrufen ", 257, 71, 193, 125)
    $Code = GUICtrlCreateInput("Code", 128, 8, 121, 21)
    $Label1 = GUICtrlCreateLabel("Startcode eingeben:", 24, 8, 100, 17)
    $Button1 = GUICtrlCreateButton("Skript Starten", 152, 32, 75, 25)
    $Label2 = GUICtrlCreateLabel("by Bastian Matthies", 0, 48, 104, 17)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $Button1
    $Zahl1 = GUICtrlRead ($Code, 1)
    If $Zahl1 <> 1542 Then
    Exit
    Else
    _1542 ()
    EndIf
    Case $GUI_EVENT_CLOSE
    Exit
    EndSwitch
    WEnd

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

    Func _1542 ()

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

    Global $aTimetable[1][7][1], $aDay[1], $sText, $sLastText
    Global $oMyRet[2]
    Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc")
    Global $sSmtpServer = "mail.gmx.net"
    Global $sFromName = "Tellkampfschule Vertretungsplan"
    Global $sFromAddress = "Vertretungsplan-Tellkampfschule@gmx.de"
    Global $sToAddress = "bastian.[email='matthies@web.de'][/email], bastian.matthies@me.com"
    Global $sSubject = "Update Vertretungsplan"
    Global $sUsername = "Vertretungsplan-Tellkampfschule@gmx.de"
    Global $sPassword = "Hannover96"

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

    $Zahl12 = InputBox ("Password zum starten des Programmes","Eingabe:", "Passwort", "*",300, 100,1,1)

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

    If $Zahl12 <> "Hannover961542" Then
    MsgBox (0,"Falsche Eingabe","Programmstart wird abgebrochen")
    Exit
    EndIf

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

    # Hier wurden die Variablen festgelegt die für die e-mail wichtig sind und die Passwort abfrage durchgeführt

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

    HotKeySet("{ESC}", "_Exit")

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

    # ESC ist zum beenden des Programmes festgelegt worden

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

    AdlibRegister("_GetChart", 5000)

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

    While 1
    Sleep(100)
    WEnd

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

    Func _GetChart()
    Local $sCol1 = " "
    Local $sCol2 = " "
    Local $sCol3 = " "
    Local $sCol4 = " "
    Local $sCol5 = " "
    Local $sCol6 = " "
    Local $sCol7 = " "
    Local $sSource = InetRead("http://tellkampf1.dyndns.org/Vertretungsplan_SuS/" & _WeekNumberISO() & "/w/w00017.htm")
    Local $iThirdDim = 0
    $sText = ""
    # Inetread überprüft den Vertretungsplan für die 10b und setzt für weeknumberiso den wert der wochen nummer der zutrifft ein
    Local $aSB_1 = _StringBetween(BinaryToString($sSource), "<b>", "</b>")
    Local $aSB_2 = _StringBetween(BinaryToString($sSource), '<table class="subst" >', "</table>")

    # Stringbetween durchsucht inetread nach bestimmten abschnitten

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

    For $i = 0 To UBound($aSB_2) - 1
    If StringInStr($aSB_2[$i], "Klasse")Then
    $iThirdDim += 1
    ReDim $aDay[$iThirdDim]
    $aDay[$iThirdDim - 1] = $aSB_1[$i]
    Local $aSB_3 = _StringBetween($aSB_2[$i], '" >', "</td>")
    ReDim $aTimetable[(UBound($aSB_3) / 7) + 1][7][$iThirdDim]
    $aTimetable[0][0][$iThirdDim - 1] = "Klasse(n)"
    $aTimetable[0][1][$iThirdDim - 1] = "Stunde"
    $aTimetable[0][2][$iThirdDim - 1] = "(Fach)"
    $aTimetable[0][3][$iThirdDim - 1] = "Vertreter"
    $aTimetable[0][4][$iThirdDim - 1] = "Fach"
    $aTimetable[0][5][$iThirdDim - 1] = "Raum"
    $aTimetable[0][6][$iThirdDim - 1] = "Art"
    For $k = 0 To UBound($aSB_3) - 1
    $aTimetable[Int($k / 7) + 1][$k - (Int($k / 7) * 7)][$iThirdDim - 1] = $aSB_3[$k]
    Next
    EndIf

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

    Next

    # eine Tabelle wird erstellt

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

    For $i = 0 To UBound($aDay) - 1
    $sText &= $aDay[$i] & @CRLF
    For $k = 0 To UBound($aTimetable) - 1
    $sText &= "|" & $aTimetable[$k][0][$i] & StringTrimLeft($sCol1, StringLen($aTimetable[$k][0][$i])) & "|"
    $sText &= $aTimetable[$k][1][$i] & StringTrimLeft($sCol2, StringLen($aTimetable[$k][1][$i])) & "|"
    $sText &= $aTimetable[$k][2][$i] & StringTrimLeft($sCol3, StringLen($aTimetable[$k][2][$i])) & "|"
    $sText &= $aTimetable[$k][3][$i] & StringTrimLeft($sCol4, StringLen($aTimetable[$k][3][$i])) & "|"
    $sText &= $aTimetable[$k][4][$i] & StringTrimLeft($sCol5, StringLen($aTimetable[$k][4][$i])) & "|"
    $sText &= $aTimetable[$k][5][$i] & StringTrimLeft($sCol6, StringLen($aTimetable[$k][5][$i])) & "|"
    $sText &= $aTimetable[$k][6][$i] & StringTrimLeft($sCol7, StringLen($aTimetable[$k][6][$i])) & "|" & @CRLF
    Next
    $sText &= @CRLF
    Next

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

    If $sLastText <> $sText And StringInStr($sText, "Klasse") Then
    $sLastText = $sText
    _SendEmail()
    EndIf
    EndFunc

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

    # Die e-mail wird nur gesendet wenn der Vertretungsplan anders aussieht als bei der letzten überprüfung

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

    Func _SendEmail()
    _INetSmtpMailCom($sSmtpServer, $sFromName, $sFromAddress, $sToAddress, $sSubject, $sText, "", "", "", $sUsername, $sPassword)
    ConsoleWrite(">> Gesendet" & @CRLF)
    EndFunc

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

    # die variablen vom anfang werden genutz um die e-mail zu versenden

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

    Func _Exit()
    Exit
    EndFunc

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

    Func _INetSmtpMailCom($sSmtpServer, $sFromName, $sFromAddress, $sToAddress, $sSubject = "", $sBody = "", $sAttachFiles = "", $sCcAddress = "", $sBccAddress = "", $sUsername = "", $sPassword = "", $iPort = 25, $xSSL = False)
    Local $iError = 0, $iErrorDesciption = "", $aSS

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

    $objEmail = ObjCreate("CDO.Message")
    $objEmail.From = '"' & $sFromName & '" <' & $sFromAddress & '>'
    $objEmail.To = $sToAddress
    If $sCcAddress <> "" Then $objEmail.Cc = $sCcAddress
    If $sBccAddress <> "" Then $objEmail.Cc = $sBccAddress
    $objEmail.Subject = $sSubject
    If StringInStr($sBody,"<") and StringInStr($sBody,">") Then
    $objEmail.HTMLBody = $sBody
    Else
    $objEmail.Textbody = $sBody & @CRLF
    EndIf
    If $sAttachFiles <> "" Then
    Local $aSS = StringSplit($sAttachFiles, ";")
    For $i = 1 To $aSS[0]
    $aSS[$i] = _PathFull($aSS[$i])
    If FileExists($aSS[$i]) Then
    $objEmail.AddAttachment($aSS[$i])
    Else
    $iErrorDesciption = $iErrorDesciption & @lf & 'File not found to attach: ' & $aSS[$i]
    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") = $sSmtpServer
    $objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = $iPort
    ;Authenticated SMTP
    If $sUsername <> "" Then
    $objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
    $objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = $sUsername
    $objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = $sPassword
    EndIf
    If $xSSL Then
    $objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
    EndIf
    ;Update settings
    $objEmail.Configuration.Fields.Update
    ; Sent the Message
    $objEmail.Send
    if @error then
    SetError(2)
    return $oMyRet[1]
    EndIf
    EndFunc ;==>_INetSmtpMailCom

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

    Func MyErrFunc()
    Local $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)
    Return
    EndFunc ;==>skript ende
    EndFunc

    [/autoit]

    ich habe das jetzt mit einem Skript...auch hier aus dem Forum... zusammen gefügt... :)
    die abfrage geht auch! :)

    aber beim starten zeit er mir plötzlich das in Zeile 76 ein Func ohne endfunc steht das ist aber da wird nur nicht erkannt...warum??

    danke

  • kann ich das so machen und springt er dann nach der msgbox weiter im Skript??? :?:

    [autoit]

    Func _1542 ()
    MsgBox (0,"fgtf","gczgcv")
    EndFunc

    [/autoit]
  • oder wie komme ich sonst nach der abfrage zu der stelle wo es weiter geht im Text...? :)

  • hey basti2022...

    deine funktion wird aufgerufen wenn du in der while - schleife bist ;)
    die funktion läuft dann kurz durch und die schleife dreht weiter ihrer
    runden ;) erst wenn du die erste while schleife beendet hast, geht es weiter im text :P ich hoffe mal das ich dein problem richtig verstanden habe 8|

  • Ne hast du leider nicht...

    Gibt es einen Befehl in autoit ähnlich wie goto oder so der zu einer stelle im Skript springt?

    Ic möchte nach eichtiger eingabe des Passwortes den rest starten und bei falscheingabe exit...

    Hat da jemand nen vorschlag?
    Danke