Zu lange kein Autoit- komme mit Buttons in GUIs nichtmehr kla

  • hallo,
    ich habe seit langer zeit nichtsmehr mit Autoit gemacht, da ich meinen Computer nach einem Virus komplett formatieren konnte.
    Nun wollte ich mal wieder etwas machen. Habe ich mir gedacht, machst du dir eine Stoppuhr. (zum einen bisschen nützlich- zum anderen um wieder mit Autoit kla zu kommen). Naja jetzt habe ich die Uhr schon fertig, allerdings funktioniert die Pause und die Rücksetz funktion noch nicht, da in der Schleife von der Uhr keine Buttons angenommen werden. Wäre nett wenn mir mal eben einer helfen könnte :P
    konnte über die SuFu nichts genaues oder verständliches Finden-

    MFG
    Lol11

    EDIT: sorry code ist auch da

    [autoit]

    #cs ----------------------------------------------------------------------------

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

    AutoIt Version: 3.3.6.1
    Author: myName

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

    Script Function:
    Template AutoIt script.

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

    #ce ----------------------------------------------------------------------------

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

    #include <GUIConstants.au3>

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

    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Uhr", 196, 135, 450, 336, 0x00002000)
    $Label1 = GUICtrlCreateLabel(0, 64, 8, 10, 17)
    $Label2 = GUICtrlCreateLabel(0, 72, 8, 10, 17)
    $Label3 = GUICtrlCreateLabel(":", 80, 8, 7, 17)
    $Label4 = GUICtrlCreateLabel(0, 88, 8, 10, 17)
    $Label5 = GUICtrlCreateLabel(0, 96, 8, 10, 17)
    $Label6 = GUICtrlCreateLabel(":", 104, 8, 7, 17)
    $Label7 = GUICtrlCreateLabel(0, 112, 8, 10, 17)
    $Label8 = GUICtrlCreateLabel(0, 121, 8, 10, 17)
    $Button1 = GUICtrlCreateButton("Start", 16, 40, 75, 25, 0)
    $Button2 = GUICtrlCreateButton("Stop", 104, 40, 75, 25, 0)
    $Button3 = GUICtrlCreateButton("Restart", 64, 72, 75, 25, 0)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $Button1
    uhrstart ()
    Case $Button2 ;==>hier sollte das ein Test sein. Den Button kann man anklicken wie man will, es passiert nichts..
    MsgBox (0,"","")
    Sleep (9999999999)
    Case $Button3;==> selbe hier
    Restart ()

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

    EndSwitch
    WEnd

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

    Func uhrstart ()
    $secs1=1
    $secs10=0
    $min1=0
    $min10=0
    $hour1=0
    $hour10=0
    While 1
    $Label8 = GUICtrlCreateLabel($secs1, 121, 8, 10, 17)
    $Label6 = GUICtrlCreateLabel(":", 104, 8, 7, 17)
    $Label7 = GUICtrlCreateLabel($secs10, 112, 8, 10, 17)
    $Label4 = GUICtrlCreateLabel($min10, 88, 8, 10, 17)
    $Label1 = GUICtrlCreateLabel($hour10, 64, 8, 10, 17)
    $Label2 = GUICtrlCreateLabel($hour1, 72, 8, 10, 17)
    $Label5 = GUICtrlCreateLabel($min1, 96, 8, 10, 17)
    $Label3 = GUICtrlCreateLabel(":", 80, 8, 7, 17)
    $secs1=$secs1+1
    Sleep (1000)
    If $secs1 = 10 THen
    $secs1 = 0
    $secs10=$secs10+1
    $Label7 = GUICtrlCreateLabel($secs10, 112, 8, 10, 17)
    EndIf
    If $secs10 = 6 Then
    $secs10 = 0
    $min1=$min1+1
    $Label5 = GUICtrlCreateLabel($min1, 96, 8, 10, 17)
    EndIf
    If $min1 =10 Then
    $min1 = 0
    $min10=$min10+1
    $Label4 = GUICtrlCreateLabel($min10, 88, 8, 10, 17)
    EndIf
    If $min10=6 Then
    $min10 =0
    $hour1 =$hour1+1
    $Label2 = GUICtrlCreateLabel($hour1, 72, 8, 10, 17)
    EndIf
    If $hour1=10 Then
    $hour10=$hour10+1
    $Label1 = GUICtrlCreateLabel($hour10, 64, 8, 10, 17)
    EndIf

    If $hour1=4 and $hour10=2 Then
    $secs1=1
    $secs10=0
    $min1=0
    $min10=0
    $hour1=0
    $hour10=0
    EndIf

    WEnd


    EndFunc

    Func Restart ()
    $secs=0
    $min=0
    $hour=0
    $Label3 = GUICtrlCreateLabel($secs, 112, 8, 16, 17)
    $Label5 = GUICtrlCreateLabel($min, 88, 8, 16, 17)
    $Label1 = GUICtrlCreateLabel($hour, 64, 8, 16, 17)
    EndFunc

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

    kann sein,dass das irgenteine zwischenversion ist, aber so ungefähr sollte das aussehen^^

    2 Mal editiert, zuletzt von Lol11 (7. Juni 2011 um 22:40)

  • Hallo Lol11,

    poste Script, dann kommt Antwort ;)

    MfG Schnuffel

    "Sarkasmus ist die niedrigste Form des Witzes, aber die höchste Form der Intelligenz."
    Val McDermid

    über mich...

    ich habe meine Erfahrungen hauptsächlich gesammelt in (grobe Übersicht):

    - RibbonBar Automation
    - MySQL Nutzung
    - GUIs in vielerlei Ausprägung
    - Nutzung von Powershell / Batch in AutoIt
    - Windows Automatisierung

    außerhalb von AutoIt:

    - Sprachen: PS, Batch, php, html(5), javascript, (perl eingeschränkt), vbs
    - Powershell (AD, WPF inkl. Multi-Threading, ...)
    - Deployment-Automatisierung ohne SCCM
    - Office-Nutzung mit COM-Object (AutoIt, PowerShell)
    - ActiveDirectory und alles was damit zusammenhängt
    - Hyper-V Clustering (Converged / Hyper Converged)
    - Serverhardware (Konfiguration, Aufbau, Architektur, Betrieb)

    Lieblingsthema:

    günstige Automatisierung von Vorgängen, für die andere Firmen viel Geld nehmen

    more to come ...

  • aber bevor du das mit ohne code geschrieben hast^^
    naja ist ja auch egal aber wie soll das mit adilibregister funktionieren?

  • Ist alles irgendwie sehr aufwendig programmiert...
    So würde ich das ungefähr machen:

    Spoiler anzeigen
    [autoit]

    #include <ButtonConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>
    #Include <Timers.au3>
    #include <Date.au3>
    Global $Timer, $ActTime = 0, $fRun = False, $Hour, $Mins, $Secs
    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Form1", 222, 92, 192, 124)
    $Label1 = GUICtrlCreateLabel("0:0:0", 0, 0, 100, 36)
    GUICtrlSetFont(-1, 20, 400, 0, "MS Sans Serif")
    $Button1 = GUICtrlCreateButton("Start", 0, 64, 75, 25, $WS_GROUP)
    $Button2 = GUICtrlCreateButton("Reset", 144, 64, 75, 25, $WS_GROUP)
    $Button3 = GUICtrlCreateButton("Stop", 72, 64, 75, 25, $WS_GROUP)
    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
    $Timer = _Timer_Init()
    $fRun = True
    Case $Button3
    $ActTime = $ActTime + _Timer_Diff($Timer)
    _Timer_KillTimer($Form1, $Timer)
    $fRun = False
    Case $Button2
    $ActTime = 0
    _Timer_KillTimer($Form1, $Timer)
    $fRun = False
    GuiCtrlSetData($Label1, "0:0:0")
    EndSwitch
    If $fRun Then
    _TicksToTime(Int(_Timer_Diff($Timer)+$ActTime), $Hour, $Mins, $Secs)
    GuiCtrlSetData($Label1, $Hour&":"&$Mins&":"&$Secs)
    EndIf
    Sleep(40)
    WEnd

    [/autoit]

    Ist ohne Adlib...