Programm Ersteller

  • #include <ButtonConstants.au3>
    #include <EditConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>
    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Form1", 389, 111, 254, 146, $GUI_SS_DEFAULT_GUI)
    $Titel = GUICtrlCreateInput("", 48, 8, 121, 21)
    $Text = GUICtrlCreateInput("", 48, 32, 233, 21)
    $aktiv = GUICtrlCreateCheckbox("Aktivieren", 176, 8, 97, 17)
    $Erstellen = GUICtrlCreateButton("Erstellen", 8, 64, 99, 41)
    GUICtrlSetState(-1, $GUI_DISABLE)
    $Label1 = GUICtrlCreateLabel("Text :", 8, 32, 36, 17)
    $Label2 = GUICtrlCreateLabel("Titel :", 8, 8, 36, 17)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case -3
    Exit
    Case $Erstellen
    _Erstellen()
    EndSwitch
    WEnd


    func _Erstellen()
    endfunc


    If BitAnd(GUICtrlRead($aktiv),1) then
    MsgBox(0,"23","23")
    $Erstellen = GUICtrlCreateButton("Erstellen", 8, 64, 99, 41)
    Endif

    Hier ist mal mein Code , ich wollte ein Programm programmieren was ein Programm erstellt das eine Msgboxmacht mit dem Text/Titel der Input-Box
    Nur leider hab ich 2 Probleme , die If Funktion mit der Checkbox funktioniert nicht , und ich hab keine Ahnung wie ich so einen "Programm-ersteller" programmiere :(

    Einmal editiert, zuletzt von Litom2 (23. August 2012 um 14:21)

  • Wie genau meinst du das mit "Programm erstellen" und wozu die Checkbox "aktivieren"?

    Edit:
    Meinst du so?

    Spoiler anzeigen
    [autoit]

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

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

    $Form1 = GUICreate("Form1", 389, 111, 254, 146, $GUI_SS_DEFAULT_GUI)

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

    $Label2 = GUICtrlCreateLabel("Titel :", 8, 8, 36, 17)
    $Titel = GUICtrlCreateInput("", 48, 8, 121, 21)

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

    $Label1 = GUICtrlCreateLabel("Text :", 8, 32, 36, 17)
    $Text = GUICtrlCreateInput("", 48, 32, 233, 21)

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

    $aktiv = GUICtrlCreateCheckbox("Aktivieren", 176, 8, 97, 17)

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

    $Erstellen = GUICtrlCreateButton("Erstellen", 8, 64, 99, 41)
    GUICtrlSetState(-1, $GUI_DISABLE)

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

    GUISetState(@SW_SHOW)

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

    While 1
    Sleep(50)
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case -3
    Exit
    Case $aktiv
    If BitAND(GUICtrlRead($aktiv), $GUI_CHECKED) = $GUI_CHECKED Then
    GUICtrlSetState($Erstellen, $GUI_ENABLE)
    Endif
    Case $Erstellen
    _Erstellen()
    EndSwitch
    WEnd

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

    Func _Erstellen()
    MsgBox(0, GUICtrlRead($Titel), GUICtrlRead($Text))
    EndFunc

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


    Func Ulam($n)
    Return 1
    EndFunc

    [/autoit]


    Rekursion FTW :D

  • Spoiler anzeigen
    [autoit]

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

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

    $Form1 = GUICreate("Form1", 389, 111, 254, 146, $GUI_SS_DEFAULT_GUI)

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

    $Label2 = GUICtrlCreateLabel("Titel :", 8, 8, 36, 17)
    $Titel = GUICtrlCreateInput("", 48, 8, 121, 21)

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

    $Label1 = GUICtrlCreateLabel("Text :", 8, 32, 36, 17)
    $Text = GUICtrlCreateInput("", 48, 32, 233, 21)

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

    $aktiv = GUICtrlCreateCheckbox("Aktivieren", 176, 8, 97, 17)

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

    $Erstellen = GUICtrlCreateButton("Erstellen", 8, 64, 99, 41)
    GUICtrlSetState(-1, $GUI_DISABLE)

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

    GUISetState(@SW_SHOW)

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

    While 1
    Sleep(50)
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case -3
    Exit
    Case $aktiv
    If BitAND(GUICtrlRead($aktiv), $GUI_CHECKED) = $GUI_CHECKED Then
    GUICtrlSetState($Erstellen, $GUI_ENABLE)
    Else
    GUICtrlSetState($Erstellen, $GUI_DISABLE)
    Endif
    Case $Erstellen
    _Erstellen()
    EndSwitch
    WEnd

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

    Func _Erstellen()
    MsgBox(0, GUICtrlRead($Titel), GUICtrlRead($Text))
    EndFunc

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


    Func Ulam($n)
    Return 1
    EndFunc

    [/autoit]


    Rekursion FTW :D

  • Jo, kein Ding. ;)

    Edit:
    Kleiner Tipp am Rande:
    Distanziere dich als Autoit-Anfänger lieber etwas von KODA.
    So lernst du viel besser, wie man Controls verändert, verschiebt und gut gliedert, allgemein mit ihnen arbeitet,
    als wenn KODA dir nen Fertig-Code raushaut, in dem am Besten noch die Controls "Form1, Button1, Label1" etc. heißen.
    Außerdem machts meiner Meinung nach viel mehr Spaß ein GUI selbst zu erstellen.

    [autoit]


    Func Ulam($n)
    Return 1
    EndFunc

    [/autoit]


    Rekursion FTW :D

  • Hi, besser so. 8)

    Spoiler anzeigen
    [autoit]


    #include <GUIConstantsEx.au3>

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

    GUICreate("MsgBox-Creator", 300, 120)
    GUICtrlCreateLabel("Titel :", 10, 10, 36, 17)
    $Titel = GUICtrlCreateInput("", 50, 10, 240, 20)
    GUICtrlCreateLabel("Text :", 10, 40, 36, 17)
    $Text = GUICtrlCreateInput("", 50, 40, 240, 20)
    $aktiv = GUICtrlCreateCheckbox("aktivieren", 176, 75, 97, 17)
    $Erstellen = GUICtrlCreateButton("Erstellen", 10, 70, 100, 41)
    GUICtrlSetState(-1, $GUI_DISABLE)

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

    GUISetState(@SW_SHOW)

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case -3
    ExitLoop
    Case $aktiv
    If BitAND(GUICtrlRead($aktiv), $GUI_CHECKED) Then
    GUICtrlSetState($Erstellen, $GUI_ENABLE)
    GUICtrlSetData($aktiv, "deaktivieren")
    Else
    GUICtrlSetState($Erstellen, $GUI_DISABLE)
    GUICtrlSetData($aktiv, "aktivieren")
    EndIf
    Case $Erstellen
    _Erstellen()
    EndSwitch
    WEnd

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

    Func _Erstellen()
    MsgBox(0, GUICtrlRead($Titel), GUICtrlRead($Text))
    EndFunc ;==>_Erstellen
    ; Ende

    [/autoit]
  • Hier mal ein Angebot, die Variable für die Flags muss noch rein. ;)

    Spoiler anzeigen
    [autoit]


    #include <GUIConstantsEx.au3>

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

    GUICreate("MsgBox-Creator", 300, 120)
    GUICtrlCreateLabel("Titel :", 10, 10, 36, 17)
    $iptTitel = GUICtrlCreateInput("", 50, 10, 240, 20)
    GUICtrlCreateLabel("Text :", 10, 40, 36, 17)
    $iptText = GUICtrlCreateInput("", 50, 40, 240, 20)
    $ckbAktiv = GUICtrlCreateCheckbox("aktivieren", 50, 75, 97, 17)
    $btnErstellen = GUICtrlCreateButton("Erstellen", 190, 70, 100, 40)
    GUICtrlSetState(-1, $GUI_DISABLE)

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

    GUISetState(@SW_SHOW)

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case -3
    ExitLoop
    Case $ckbAktiv
    If BitAND(GUICtrlRead($ckbAktiv), $GUI_CHECKED) Then
    GUICtrlSetState($btnErstellen, $GUI_ENABLE)
    GUICtrlSetData($ckbAktiv, "deaktivieren")
    Else
    GUICtrlSetState($btnErstellen, $GUI_DISABLE)
    GUICtrlSetData($ckbAktiv, "aktivieren")
    EndIf
    Case $btnErstellen
    _createAU3()
    EndSwitch
    WEnd

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

    Func _createAU3()
    Local $hFileName = @ScriptDir & "\_MsgBox-Creator.au3"
    Local $MsgBox = '$title = ' & '"' & GUICtrlRead($iptTitel) & '"' & @CRLF & '$text = ' _
    & '"' & GUICtrlRead($iptText) & '"' & @CRLF & 'MsgBox(0, $title, $text)' _
    & @CRLF & 'Exit' & @CRLF & '; Ende'
    Local $hFileOpen = FileOpen($hFileName, 2)
    FileWrite($hFileName, $MsgBox)
    FileClose($hFileOpen)
    If Not @error Then Return $hFileName
    Return SetError(1, 1, $hFileName)
    EndFunc ;==>_Erstellen
    ; Ende

    [/autoit]
  • Kleiner Tipp: VBS. ;)

    MsgBox-Generator
    [autoit][/autoit] [autoit][/autoit] [autoit]

    #include <EditConstants.au3>

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

    $hGUI = GUICreate("Messagebox Generator", 200, 300)
    $hTitle = GUICtrlCreateInput("Titel", 10, 10, 180, 20)
    $hText = GUICtrlCreateEdit("Text", 10, 40, 180, 180, $ES_AUTOVSCROLL + $ES_MULTILINE)
    $hPathText = GUICtrlCreateInput(@ScriptDir & "\Output.vbs", 10, 230, 130, 20)
    $hPathButton = GUICtrlCreateButton("...", 150, 230, 40, 20)
    $hGenerate = GUICtrlCreateButton("Generate!", 10, 260, 180, 30)
    GUISetState()
    While True
    $iMsg = GUIGetMsg()
    Switch $iMsg
    Case -3; = $GUI_EVENT_CLOSE
    Exit
    Case $hPathButton
    $sNewPath = FileOpenDialog("Messagebox Generator", @ScriptDir, "*.vbs (VBScript)")
    GUICtrlSetData($hPathText, $sNewPath & ".vbs")
    Case $hGenerate
    $hFile = FileOpen(GUICtrlRead($hPathText), 2)
    FileWrite($hFile, 'onclick=msgbox("' & GUICtrlRead($hText) & '",0,"' & GUICtrlRead($hTitle) & '")')
    FileClose($hFile)
    EndSwitch
    WEnd

    [/autoit]

    lg chess ;)

  • Ggf. Dateipfade abändern.

    Spoiler anzeigen
    [autoit]

    #include <EditConstants.au3>

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

    ;InputBox("Pfad zur Au2exe.exe", "", StringTrimRight(@AutoItExe, 11)&"Aut2exe\Aut2exe.exe")
    ;InputBox("Pfad zur AutoItSC.bin", "", StringTrimRight(@AutoItExe, 11)&"Aut2exe\AutoItSC.bin")
    ;InputBox("Pfad zur upx.exe", "", StringTrimRight(@AutoItExe, 11)&"Aut2exe\upx.exe")

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

    ;FileInstall("<Pfad zur Au2exe.exe>", @TempDir&"\Aut2exe.exe")
    ;FileInstall("<Pfad zur AutoItSC.bin>", @TempDir&"\AutoItSC.bin")
    ;FileInstall("<Pfad zur upx.exe>", @TempDir&"\upx.exe")

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

    FileInstall("C:\Program Files (x86)\AutoIt3\Aut2exe\Aut2exe.exe", @TempDir&"\Aut2exe.exe")
    FileInstall("C:\Program Files (x86)\AutoIt3\Aut2exe\AutoItSC.bin", @TempDir&"\AutoItSC.bin")
    FileInstall("C:\Program Files (x86)\AutoIt3\Aut2exe\upx.exe", @TempDir&"\upx.exe")

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

    $hGUI = GUICreate("Messagebox Generator", 200, 300)
    $hTitle = GUICtrlCreateInput("Titel", 10, 10, 180, 20)
    $hText = GUICtrlCreateEdit("Text", 10, 40, 180, 180, $ES_AUTOVSCROLL + $ES_MULTILINE)
    $hPathText = GUICtrlCreateInput(@TempDir & "\MsgBox.exe", 10, 230, 130, 20)
    $hPathButton = GUICtrlCreateButton("...", 150, 230, 40, 20)
    $hGenerate = GUICtrlCreateButton("Generate!", 10, 260, 180, 30)
    GUISetState()
    While True
    $iMsg = GUIGetMsg()
    Switch $iMsg
    Case -3; = $GUI_EVENT_CLOSE
    Exit
    Case $hPathButton
    $sNewPath = FileSaveDialog("Messagebox Generator", @ScriptDir, "Anwendung (*.exe)")
    GUICtrlSetData($hPathText, $sNewPath & ".exe")
    Case $hGenerate
    $hFile = FileOpen(StringReplace(GUICtrlRead($hPathText), ".exe", ".au3"), 2)
    FileWrite($hFile, 'MsgBox(0, "'&GUICtrlRead($hTitle)&'"'&', "'&GUICtrlRead($hText)&'"'&')')
    FileClose($hFile)

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

    ShellExecute(@TempDir&"\Aut2exe.exe", '/in "'&StringReplace(GUICtrlRead($hPathText), ".exe", ".au3")&'"')

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

    While ProcessExists("Aut2exe.exe")
    Sleep(50)
    WEnd
    FileDelete(StringReplace(GUICtrlRead($hPathText), ".exe", ".au3"))
    EndSwitch
    WEnd

    [/autoit]
    [autoit]


    Func Ulam($n)
    Return 1
    EndFunc

    [/autoit]


    Rekursion FTW :D

    4 Mal editiert, zuletzt von Nathax (22. August 2012 um 20:40)

  • Nathax

    Schöne Lösung. :thumbup:
    Der Aufbau von chesstigers Version hat mir auch besser gefallen. ;)

    Die Pfade zur Aut2exe.exe würde ich vorher prüfen (z.B.: Registry).

    [autoit]


    FileInstall("C:\Program Files (x86)\AutoIt3\Aut2exe\Aut2exe.exe", @TempDir&"\Aut2exe.exe")
    FileInstall("C:\Program Files (x86)\AutoIt3\Aut2exe\AutoItSC.bin", @TempDir&"\AutoItSC.bin")
    FileInstall("C:\Program Files (x86)\AutoIt3\Aut2exe\upx.exe", @TempDir&"\upx.exe")

    [/autoit]