2 GUI in 1 Skript?!?

  • Hallo,
    Ich habe ein Skript wobei ein Button existiert...
    "Upload"
    Wenn man diesen Button drückt, dann soll dieses Skript hier verwendet werden:

    [autoit]


    #include <GUIConstantsEx.au3>

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

    $Form2 = GUICreate("Musik Uploader", 301, 89, 185, 188)
    $Input1 = GUICtrlCreateInput("", 40, 32, 121, 21)
    $Button1 = GUICtrlCreateButton("Durchsuchen", 176, 32, 75, 25, 0)
    GUISetState(@SW_SHOW)

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $Button1
    GUICtrlSetData($Input1, FileOpenDialog("Datei öffnen", @ScriptDir, 'Alle Dateien (*.*)'))
    EndSwitch
    WEnd

    [/autoit]

    Wie kann ich das einbinden???
    Irgendwie komme ich nicht drauf.. =(


    Ich bitte um Hilfe

    Mfg
    Benne

    Einmal editiert, zuletzt von PokerFace (24. Februar 2009 um 22:34)

  • [autoit]

    #include <GUIConstants.au3>
    #include <Array.au3>
    #include <string.au3>
    #include <INet.au3>
    #Include <file.au3>
    #include <FTP.au3>

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

    ; Url zum Webverzeichnis
    Dim $ServerUrl = "http://bennes-music.no-ip.biz/Files/"
    ;Dim $ServerUrl = "http://testuser:qwert@http://www.kroegers-web.de/testdaten/"

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

    ; Dateiliste die runtergeladen werden soll
    Dim $FileList = "files.txt"

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

    ;Speicherpfad für die Liste
    Dim $SaveFileList = @TempDir & "\files.txt"

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

    ;Textdatei laden
    If InetGet($ServerUrl & $FileList, $SaveFileList, 1) = 0 Then
    MsgBox(48, "Fehlr...", "Fehler beim download der Dateiliste")
    Exit 1
    EndIf

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

    ;Dateiliste zum lesen öffnen
    Dim $fso = FileOpen($SaveFileList, 0)

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

    ;Inhalt der Datei einlesen
    Dim $txt = FileRead($fso)

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

    ;Dateiliste schliessen
    FileClose($fso)

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

    ;@CRLF aus der $txt Variabele entfernen
    $txt = StringReplace($txt, @CRLF, "|")

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

    ;##################################
    ; Variables
    ;##################################
    $SmtpServer = "smtp.googlemail.com" ; address for the smtp-server to use - REQUIRED
    $FromName = "MusicLoader" ; name from who the email was sent
    $FromAddress = "******" ; address from where the mail should come
    $ToAddress = "*******" ; destination address of the email - REQUIRED
    $Subject = "Neuer Titel!" ; subject from the email - can be anything you want it to be
    $Body = "Nachrichtentext" ; 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]

    Global $oMyRet[2]
    Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc")

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

    ;#######################################
    ;Upload Variables
    ;#######################################
    $server = 'bennes-music.no-ip.biz'
    $username = '******'
    $pass = '*******'

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

    ;$Open = _FTPOpen('bennes-music.no-ip.biz Control')
    ;$Conn = _FTPConnect($Open, $server, $username, $pass)
    ;$Ftpp = _FtpPutFile($Conn, 'C:\WINDOWS\Notepad.exe', '/Files/')
    ;$Ftpc = _FTPClose($Open)

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

    $txtList = StringSplit($txt, "|")

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

    $txt = ""
    For $i = 1 To $txtList[0]
    $txtlistlen = StringLen($txtList[$i]) + 1
    $txtliststart = StringInStr($txtList[$i], "/") + 1
    If $txtliststart = 0 Then
    $txt = $txt & $i & "-" & $txtlist[$i] & "|"
    Else
    $txtlistcount = $txtlistlen - $txtliststart
    $txtlistresult = StringMid($txtList[$i], $txtliststart, $txtlistcount)
    $txt = $txt & $i & "-" & $txtlistresult & "|"
    EndIf
    Next

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

    $txt = StringTrimRight($txt, 1)

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

    ;Form
    $frmMain = GUICreate("Musik Loader", 285, 210, 993, 325)
    $UploadButton = GUICtrlCreateButton ("Upload", 24, 185, 234, 25, 0)
    $SongAskInput = GUICtrlCreateInput ("Welches Lied fehlt?", 24, 132, 233, 20, 0)
    $SongAskSend =GUICtrlCreateButton ("Absenden", 24, 155, 234, 25, 0)
    $pcbDownload = GUICtrlCreateProgress(24, 64, 233, 17)
    $infoLabel = GUICtrlCreateLabel("", 24, 84, 233, 25);, $SS_CENTER )
    $cmdButton = GUICtrlCreateButton("Start Download", 24, 103, 233, 25, 0)
    GUICtrlSetState(-1, $GUI_DISABLE)
    $FileList = GUICtrlCreateCombo("FileList", 24, 24, 233, 25)
    GUICtrlSetData(-1, $txt)

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

    GUISetState(@SW_SHOW)

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

    ;Variable für die derzeit Ausgewählte Datei
    Dim $selectet

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

    ;Variable für die Dateiendung
    Dim $mediaformat

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

    ;Speicherort
    Dim $SaveFile

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $cmdButton
    $SaveFile = FileSaveDialog("Datei Speichern...", @DesktopDir, "Musik (*." & $mediaformat & ")", 2, GUICtrlRead($FileList))
    If Not @error Then RunDownload()

    Case $FileList
    GUICtrlSetData($infoLabel,"")
    $id = StringLeft(GUICtrlRead($FileList),StringInStr(GUICtrlRead($FileList),"-")- 1)
    $selectet = $ServerUrl & $txtList[$id]
    InetGetSize($selectet)
    If @error Then
    GUICtrlSetState($cmdButton, $GUI_DISABLE)
    Else
    GUICtrlSetState($cmdButton, $GUI_ENABLE)
    EndIf
    $mediaformat = StringRight(GUICtrlRead($FileList), 3)
    Case $SongAskSend
    $rc = _INetSmtpMailCom($SmtpServer, $FromName, $FromAddress, $ToAddress, $Subject, "Hey, der neue Titel:" & GUICtrlRead($SongAskInput), $AttachFiles, $CcAddress, $BccAddress, $Importance, $Username, $Password, $IPPort, $ssl)
    If @error Then
    MsgBox(0, "Error!", "E-mail konnte nicht gesandt werden!")
    Else
    MsgBox(0, "Song Mail!", "Die E-mail wurde erfolgreich versand an:" & $ToAddress)
    EndIf
    Case $UploadButton
    Exit

    EndSwitch


    WEnd

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

    Func RunDownload()
    GUISetState(@SW_DISABLE)
    $FileSize = InetGetSize($selectet)
    InetGet($selectet, $SaveFile, 1, 1)
    $curSize = 0
    Do
    GUICtrlSetData($pcbDownload, $curSize)
    $curFileSize = FileGetSize($SaveFile)
    $curSize = $curFileSize * 100
    $curSize = $curSize / $FileSize
    $curSize = Ceiling($curSize)
    $curFileSize = Round($curFileSize / 1024 / 1024, 2)
    GUICtrlSetData($infoLabel, $curFileSize & " - " & Round($FileSize / 1024 / 1024, 2) & " MB (" & $curSize & "%)")
    Sleep(200)
    Until $curSize >= 99
    GUISetState(@SW_ENABLE)
    GUICtrlSetData($infoLabel, "Download beendet!!!")
    GUICtrlSetData($pcbDownload, 0)
    EndFunc ;==>RunDownload

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

    ; 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]


    In dieses soll eben das kleine Obige Eingesetzt werden, dass es bei "Upload" geöffnet wird udn wenn man die Datei ausgewählt hat, der Pfad in einer Variabel ist und dann sich der zweite GUI wieder schließt.

    Button Drücken -> GUI 2 geht auf -> Pfad in Variabel -> GUI 2 schließt.
    =)

    Einmal editiert, zuletzt von PokerFace (24. Februar 2009 um 22:32)

  • statt

    [autoit]

    Case $UploadButton
    Exit

    [/autoit]


    schreibst du:

    das hier
    [autoit]


    $Form2 = GUICreate("Musik Uploader", 301, 89, 185, 188)
    $Input1 = GUICtrlCreateInput("", 40, 32, 121, 21)
    $Button1 = GUICtrlCreateButton("Durchsuchen", 176, 32, 75, 25, 0)
    GUISetState(@SW_SHOW)

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $Button1
    $sFile=FileOpenDialog("Datei öffnen", @ScriptDir, 'Alle Dateien (*.*)')
    Exit
    EndSwitch
    WEnd

    [/autoit]


    , oder, was ich für besser halte:

    [autoit]

    $sFile=FileOpenDialog("Datei öffnen", @ScriptDir, 'Alle Dateien (*.*)')

    [/autoit]


    Dann gibt es gar keine zweite GUI...

    Twitter: @L3viathan2142
    Benutze AutoIt persönlich nicht mehr, da ich keinen Windows-Rechner mehr besitze.

    • Offizieller Beitrag

    PokerFace nimm mal deine Zugangsdaten aus deinem Script. Ich denk du willst nicht das jeder auf deinem Server rumturnt.

  • man kann übrigens immer noch die User/Passwort abfrage bei deinem Musik Server umgehen! Auserdem würd ich keine Musi auf nen server laden! nur mal so als Tipp am rande

  • Ich weiß..
    Ist Illegal!
    Nur Test:
    Für meinen Informatik Kurs.
    Aufgabe: Einen funktionstüchtigen Uploader und Downloader machen ;)
    Musik ist dabei nur ein Beispiel da man ca. 3 MB große Dateien hat.
    Der Sinn liegt im Unttericht :D