Wer findet den Fehler oO

  • hey,

    ich habe gerade auf die schnelle ein script geschrieben, was eine macke hat, ich weiss aber nicht warum.
    und zwar soll beim ersten start ein gui erscheinen wo man verschiedene einstellungen machen kann. beim klick auf ok wird alles in eine ini gespeichert.
    bei den nächsten aufrufen soll nun nur noch alles aus der ini gelesen, und danach die daraus resultierenden angaben ausgeführt werden.
    aber das gui schließt sich sofort nach 1 sek immer.

    wenn ich aber Select Case zu $cancel und $ok rausnehme, geht es.
    nehme ich nur $cancel raus, speichert er sofort die ini. nehme ich $ok raus, poppt das gui wieder nur 1 sek auf.

    why ?

    Spoiler anzeigen
    [autoit]

    ;
    ;S.T.A.R.T.E.R_V.1
    ;

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

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

    ;Settings
    ;#NoTrayIcon
    #include<guiconstants.au3>
    $ini = "S.T.A.R.T.E.R_Settings.ini"

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

    ;if ini exist
    If FileExists(@scriptdir & "\" & $ini) Then

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

    call("_run")

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

    Else

    $gui = GUICreate("S.T.A.R.T.E.R_V.1 by plutod", 300, 185)
    $ok = GUICtrlCreateButton("&OK", 40, 155, 70)
    $cancel = GUICtrlCreateButton("&Cancel", 190, 155, 70)
    GUICtrlCreateTab(0, 0, 300, 150)
    GUICtrlCreateTabItem(" Kill on Start ")
    $cbportal = GUICtrlCreateCheckbox("Kill Portal", 30, 40)
    $cbinfo = GUICtrlCreateCheckbox("Kill HDINFO", 30, 70)
    $cbinstall = GUICtrlCreateCheckbox("Kill Install/Error Msg", 30, 100)
    GUICtrlCreateTab(-1, -1, 300, 150)
    GUICtrlCreateTabItem(" Run on Start ")
    $cbbackup = GUICtrlCreateCheckbox("Run Lotus Notes Backup", 30, 60)
    $cbnotes = GUICtrlCreateCheckbox("Run Lotus Notes", 30, 90)
    GUICtrlCreateTab(-1, -1, 300, 150)
    GUICtrlCreateTabItem("Run on Shutdown")
    $cbshutdown = GUICtrlCreateCheckbox("Message before Shutdown", 30, 40)
    $editmsg = GUICtrlCreateEdit("Put here your text you want to see before Shutdown", 10, 70, 270, 50)

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

    GUISetState(@SW_SHOW)

    While 1
    $msg = GUIGetMsg()
    Select
    case $msg = $gui_event_close
    ExitLoop
    Exit
    Case $cancel
    ExitLoop
    Exit
    Case $ok
    If GUICtrlRead($cbportal) = 1 Then
    IniWrite($ini, "Kill on Start", "portal", "1")
    Else
    IniWrite($ini, "Kill on Start", "portal", "0")
    EndIf
    If GUICtrlRead($cbinfo) = 1 Then
    IniWrite($ini, "Kill on Start", "info", "1")
    Else
    IniWrite($ini, "Kill on Start", "info", "0")
    EndIf
    If GUICtrlRead($cbinstall) = 1 Then
    IniWrite($ini, "Kill on Start", "install", "1")
    Else
    IniWrite($ini, "Kill on Start", "install", "0")
    EndIf
    If GUICtrlRead($cbbackup) = 1 Then
    IniWrite($ini, "Run on Start", "backup", "1")
    Else
    IniWrite($ini, "Run on Start", "backup", "0")
    EndIf
    If GUICtrlRead($cbnotes) = 1 Then
    IniWrite($ini, "Run on Start", "notes", "1")
    Else
    IniWrite($ini, "Run on Start", "notes", "0")
    EndIf
    If GUICtrlRead($cbshutdown) = 1 Then
    IniWrite($ini, "Run End", "end", "1")
    IniWrite($ini, "Run End", "msg", $editmsg)
    Else
    IniWrite($ini, "Run End", "end", "0")
    IniWrite($ini, "Run End", "msg", $editmsg)
    EndIf
    call("_run")
    GUIDelete($gui)
    EndSelect
    WEnd

    EndIf

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

    Func _run()
    $portal = IniRead(@scriptdir & "\" & $ini, "Kill on Start", "portal", "")
    $info = IniRead(@scriptdir & "\" & $ini, "Kill on Start", "info", "")
    $install = IniRead(@scriptdir & "\" & $ini, "Kill on Start", "install", "")
    $backup = IniRead(@scriptdir & "\" & $ini, "Run on Start", "backup", "")
    $notes = IniRead(@scriptdir & "\" & $ini, "Run on Start", "notes", "")
    $end = IniRead(@scriptdir & "\" & $ini, "Run End", "end", "")
    $msg = IniRead(@scriptdir & "\" & $ini, "Run End", "msg", "")

    If $portal = 1 Then
    WinKill("Portal")
    Else
    EndIf

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

    If $info = 1 Then
    WinKill("HDInfo2k")
    Else
    EndIf

    If $install = 1 Then
    WinMinimizeAll()
    ToolTip("")
    WinKill("Install")
    WinKill("Error")
    Else
    EndIf

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

    If $backup = 1 Then
    runwait(@programfilesdir & "\IBM\Lotus Notes\BackupNotesData.EXE", "", @SW_HIDE)
    Else
    EndIf

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

    If $notes = 1 Then
    runwait(@programfilesdir & "\IBM\Lotus Notes\notes.exe", "", @SW_MAXIMIZE)
    Else
    EndIf

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

    If $end = 1 Then
    $msg = IniRead(@scriptdir & "\" & $ini, "Run End", "msg", "")
    Opt("OnExitFunc", "endscript")
    Else
    Exit
    EndIf
    EndFunc

    Func endscript()
    Do
    WinWaitActive("Windows herunterfahren")
    until ProcessExists("shutdown.exe")
    MsgBox(0, "Remember", "$msg")
    EndFunc

    [/autoit]
    • Offizieller Beitrag

    es muss heissen

    [autoit]

    Case $msg = $cancel

    [/autoit]

    und

    [autoit]

    Case $msg = $okl

    [/autoit]
  • Wie Ber670 schon gesagt hat, ist das in dieser Form nicht richtig.
    Aber du kannst ja auch

    [autoit]

    ..

    While 1
    Switch GUIGetMsg()
    Case $gui_event_close
    Exit
    Case $cancel
    Exit
    Case $ok
    If GUICtrlRead($cbportal) = 1 Then ..
    Case Else
    ;-)))
    EndSwitch
    WEnd
    ..

    [/autoit]

    benutzen..
    [edit]
    Wow, zum gelösten Problem gepostet, aber wenigstens nix Falsches :D
    Gruß
    ytwinky

    (Ich) benutze stets die aktuelle (Beta) und SciTE..

    Einmal editiert, zuletzt von ytwinky (11. Mai 2007 um 20:57)

  • hey, auch ein guter tip, danke ...

    hab aber ein neues prob.
    und zwar hab ich 3 inputboxen, die entweder einen pfad zu nem file enthalten, oder leer sind. auswahl geht über fileopendialog, der danach per guictrlsetdata in die inputbox eingefügt wird.

    das ganze soll später in ne ini geschrieben werden.
    er kann auch die inputbox auslesen. wenn diese leer ist, schreibt er die ini und nichts hinter den key.
    is dort was enthalten, kann er es testweise per msgbox ausgeben, aber er schreibt es einfach nicht in die ini.
    weiss wer wieso ?

    Spoiler anzeigen
    [autoit]


    ;S.T.A.R.T.E.R_V.2
    ;

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

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

    ;Settings
    #NoTrayIcon
    #include<guiconstants.au3>

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

    $script = "S.T.A.R.T.E.R_V2"
    $ini = ($script & "_Settings.ini")

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

    ;if ini exist
    If FileExists(@scriptdir & "\" & $ini) Then
    ;read ini
    $portal = IniRead(@scriptdir & "\" & $ini, "Kill on Start", "portal", "")
    $info = IniRead(@scriptdir & "\" & $ini, "Kill on Start", "info", "")
    $install = IniRead(@scriptdir & "\" & $ini, "Kill on Start", "install", "")
    $backup = IniRead(@scriptdir & "\" & $ini, "Run on Start", "backup", "")
    $notes = IniRead(@scriptdir & "\" & $ini, "Run on Start", "notes", "")
    $end = IniRead(@scriptdir & "\" & $ini, "Run End", "end", "")
    $inimsg = IniRead(@scriptdir & "\" & $ini, "Run End", "msg", "")
    $tool1 = IniRead(@scriptdir & "\" & $ini, "Own Tools", "Tool1", "")
    $tool2 = IniRead(@scriptdir & "\" & $ini, "Own Tools", "Tool2", "")
    $tool3 = IniRead(@scriptdir & "\" & $ini, "Own Tools", "Tool3", "")

    ;kill & start
    If $portal = 1 Then
    WinKill("Portal")
    Else
    EndIf
    If $info = 1 Then
    WinKill("HDInfo2k")
    Else
    EndIf
    If $install = 1 Then
    WinMinimizeAll()
    ToolTip("")
    WinKill("Error")
    ControlSend("Install", "E&xit Setup", "Button2", "!x")
    WinKill("Error")
    ControlSend("Install", "E&xit Setup", "Button2", "!x")
    Else
    EndIf
    If $backup = 1 Then
    runwait(@programfilesdir & "\IBM\Lotus Notes\BackupNotesData.EXE", "", @SW_HIDE)
    Else
    EndIf
    If $notes = 1 Then
    runwait(@programfilesdir & "\IBM\Lotus Notes\nlnotes.exe", "", @SW_MAXIMIZE)
    Else
    EndIf
    If $tool1 <> 0 Then
    RunWait('"' & $tool1 & '"')
    Else
    EndIf
    If $tool2 <> 0 Then
    RunWait('"' & $tool2 & '"')
    Else
    EndIf
    If $tool3 <> 0 Then
    RunWait('"' & $tool3 & '"')
    Else
    EndIf
    If $end = 1 Then
    $msg = StringReplace($inimsg, "[CRLF]", @CRLF)
    Opt("OnExitFunc", "endscript")
    Else
    Exit
    EndIf

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

    ;ini does not exist
    Else

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

    ;gui
    $gui = GUICreate($script, 400, 205, -1, -1, -1, $WS_EX_ACCEPTFILES)
    $ok = GUICtrlCreateButton("&OK", 40, 155, 70)
    $cancel = GUICtrlCreateButton("&Cancel", 290, 155, 70)
    $label = GUICtrlCreateLabel("© ", 160, 170)
    GUICtrlSetColor(-1, 0x9E9E9E)
    GUICtrlSetFont($label, 7)
    $menu = GUICtrlCreateMenu("&more")
    $help = GUICtrlCreateMenuitem("&help", $menu)
    $info = GUICtrlCreateMenuitem("&info", $menu)

    ;tab1 "kill"
    GUICtrlCreateTab(0, 0, 400, 150)
    GUICtrlCreateTabItem(" Kill on Start ")
    GUICtrlCreatePic("Henkel2.jpg", 180, 30, 180, 110)
    $cbportal = GUICtrlCreateCheckbox("Kill Portal", 30, 40)
    GUICtrlSetTip($cbportal, "Kills the Portal if you don´t need it")
    $cbinfo = GUICtrlCreateCheckbox("Kill HDINFO", 30, 70)
    GUICtrlSetTip($cbinfo, "Kills the HDInfo-Window if you don´t need it")
    $cbinstall = GUICtrlCreateCheckbox("Kill Install/Error Msg", 30, 100)
    GUICtrlSetTip($cbinstall, "Kills some Error/Install-Windows, which sometimes appear")
    ;tab1 "run"
    GUICtrlCreateTab(-1, -1, 400, 150)
    GUICtrlCreateTabItem(" Run on Start ")
    $cbbackup = GUICtrlCreateCheckbox("Run Lotus Notes Backup", 30, 60)
    GUICtrlSetTip($cbbackup, "Runs the Backup-my-Data-Function for Lotus Notes")
    $cbnotes = GUICtrlCreateCheckbox("Run Lotus Notes", 30, 90)
    GUICtrlSetTip($cbnotes, "Runs Lotus Notes (after the Backup)")
    ;tab3 "shutdown"
    GUICtrlCreateTab(-1, -1, 400, 150)
    GUICtrlCreateTabItem("Run on Shutdown")
    $cbshutdown = GUICtrlCreateCheckbox("Message before Shutdown", 30, 40)
    GUICtrlSetTip($cbshutdown, "Shows a MsgBox with some Information for a few Seconds, if you Turn off, Reboot, or Logout")
    $edit = GUICtrlCreateEdit("Put here your text you want to see before Shutdown", 10, 70, 270, 50, $ES_AUTOVSCROLL+$ES_AUTOHSCROLL+$ES_WANTRETURN+$ES_MULTILINE)
    ;tab4 "own tools"
    GUICtrlCreateTab(-1, -1, 400, 150)
    GUICtrlCreateTabItem("Start own Tools")
    $input1 = GUICtrlCreateInput("", 30, 40, 250, 25)
    GUICtrlSetState(-1, $GUI_ACCEPTFILES)
    $button1 = GUICtrlCreateButton("Browse&1", 300, 40, 70)
    $input2 = GUICtrlCreateInput("", 30, 70, 250, 25)
    GUICtrlSetState(-1, $GUI_ACCEPTFILES)
    $button2 = GUICtrlCreateButton("Browse&2", 300, 70, 70)
    $input3 = GUICtrlCreateInput("", 30, 100, 250, 25)
    GUICtrlSetState(-1, $GUI_ACCEPTFILES)
    $button3 = GUICtrlCreateButton("Browse&3", 300, 100, 70)

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

    GUISetState(@SW_SHOW)

    While 1
    $msg = GUIGetMsg()
    Select
    case $msg = $gui_event_close
    Exit
    ExitLoop
    Case $msg = $cancel
    Exit
    ExitLoop
    case $msg = $help
    MsgBox(32, "Help", "This little Program will help you, to modify your systemstart and shutdown with different settings" & @CRLF & "You are also able to customize this tool, by starting your own programs")
    case $msg = $info
    MsgBox(64, "Info", "This tools is written by ..." & @CRLF & @CRLF & " ----------- 2005 -----------")
    case $msg = $button1
    $file1 = FileOpenDialog("Open File", "", "Alle (*.*)" , 1 + 2)
    GUICtrlSetData($input1, $file1)
    case $msg = $button2
    $file2 = FileOpenDialog("Open File", "", "Alle (*.*)" , 1 + 2)
    GUICtrlSetData($input2, $file2)
    case $msg = $button3
    $file3 = FileOpenDialog("Open File", "", "Alle (*.*)" , 1 + 2)
    GUICtrlSetData($input3, $file3)
    Case $msg = $ok
    If GUICtrlRead($cbportal) = 1 Then
    IniWrite($ini, "Kill on Start", "portal", "1")
    Else
    IniWrite($ini, "Kill on Start", "portal", "0")
    EndIf
    If GUICtrlRead($cbinfo) = 1 Then
    IniWrite($ini, "Kill on Start", "info", "1")
    Else
    IniWrite($ini, "Kill on Start", "info", "0")
    EndIf
    If GUICtrlRead($cbinstall) = 1 Then
    IniWrite($ini, "Kill on Start", "install", "1")
    Else
    IniWrite($ini, "Kill on Start", "install", "0")
    EndIf
    If GUICtrlRead($cbbackup) = 1 Then
    IniWrite($ini, "Run on Start", "backup", "1")
    Else
    IniWrite($ini, "Run on Start", "backup", "0")
    EndIf
    If GUICtrlRead($cbnotes) = 1 Then
    IniWrite($ini, "Run on Start", "notes", "1")
    Else
    IniWrite($ini, "Run on Start", "notes", "0")
    EndIf
    If GUICtrlRead($cbshutdown) = 1 Then
    IniWrite($ini, "Run End", "end", "1")
    $editmsg = GUICtrlRead($edit, 1)
    IniWrite($ini, "Run End", "msg", StringReplace($editmsg, @CRLF, "[CRLF]"))
    Else
    IniWrite($ini, "Run End", "end", "0")
    EndIf
    $1 = GUICtrlRead($input1)
    $2 = GUICtrlRead($input2)
    $3 = GUICtrlRead($input3)
    IniWrite($ini, "Own Tools", "Tool1", $1)
    IniWrite($ini, "Own Tools", "Tool2", $2)
    IniWrite($ini, "Own Tools", "Tool3", $3)
    FileCreateShortcut(@AutoItExe, @StartupDir & "\" & $script & ".ink")
    Exit
    EndSelect
    WEnd

    EndIf

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

    Do
    WinWaitActive("Windows herunterfahren")
    until ProcessExists("shutdown.exe")

    Func endscript()
    $cu = MsgBox(0, "Remember", $msg)
    WinSetOnTop($cu, "Remeber", 1)
    EndFunc

    [/autoit]
    • Offizieller Beitrag

    Besteht das Problem noch? Die Frage wurde, glaube ich, erst gestellt nach dem das Thema auf gelöst gesetzt wurde. Wenn ja, dann bitte das Thema wieder auf offen stellen.

    Ich konnte auf jeden Fall keinen Fehler feststellen, bei mir werden die Dateiname korrekt in die Ini geschrieben.

    Ein paar Anmerkungen habe ich aber denn noch:

    Folgende Anweisung ist unötig:

    [autoit]


    Case $msg = $gui_event_close
    Exit
    ExitLoop

    [/autoit]

    Weil nach dem Exit-Befehl nichts mehr ausgeführt wird, ExitLoop wird also nie erreicht.
    __________________________________________________________

    Die Funktion

    [autoit]


    Func endscript()
    $cu = MsgBox(0, "Remember", $msg)
    WinSetOnTop($cu, "Remeber", 1) ; muss übrigens "Remember" heissen
    EndFunc

    [/autoit]

    kann man auch so schreiben

    [autoit]


    Func endscript()
    $cu = MsgBox(262144, "Remember", $msg)
    EndFunc

    [/autoit]


    Einfach mal in der Hilfe lesen was es für Mögiichkeiten gibt. ;)
    __________________________________________________

    Und zu letzt noch ein Schreibfehler:

    [autoit]


    FileCreateShortcut(@AutoItExe, @StartupDir & "\" & $script & ".ink")

    [/autoit]

    es muss "lnk" heissen und nicht "ink".

  • hiho,

    ok, hab mal den thread wieder geöffnet.
    also das prob besteht immernoch.
    hab deine änderungen aber mal alle übernommen *g*, thx

    aber sobald ich ein prog auswähle, legt er keine ini an, nur wenn ich die tools leer lasse. ich verstehe es nicht.
    die variablen sind auch gefüllt (bzw speichert er ja dann auch "" ab, was er ja auch soll.
    hab auch schon verschiedene wege getestet, aber bei allen bestand das gleiche prob

    PS: komisch, wenn ich das script kompiliere, geht es, nur wenn ich es aus scite ausführe, erstellt er keine ini sofern ich ein tool ausgewählt habe.
    naja, warum weiss ich nicht, aber dann scheint es ja doch zu laufen =)
    PPS: ahso, er speichert die ini dann immer im ordner, wo ich das "tool" ausgewählt habe.

    • Offizieller Beitrag

    Dafür hast Du doch @ScriptDir genommen, oder?

    Ich werde jetzt das Thema wieder auf gelöst setzen, es funktioniert ja! ;)