GUI während Sleep abfragen

  • hi,

    ich hab mal ein kleines Problem.
    Und zwar hab ich z.B. sowas hier:

    [autoit]


    #include <ButtonConstants.au3>
    #include <EditConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>
    $send = False

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

    $Form1 = GUICreate("Form1", 214, 244, 193, 125)
    $Input2 = GUICtrlCreateInput("Interval", 40, 48, 121, 21)
    $Input1 = GUICtrlCreateInput("Titel", 40, 88, 121, 21)
    $Button1 = GUICtrlCreateButton("Send Blahs", 56, 136, 75, 25, 0)
    GUISetState(@SW_SHOW)

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $Button1
    If WinExists(GUICtrlRead($Input1)) = False Then
    ToolTip('Es wurde kein Fenster mit dem eingegebenen Titel gefunden!', 0, 0)
    Sleep(1500)
    ToolTip("")
    Else

    If Not WinActive(GUICtrlRead($Input1)) Then WinActivate(GUICtrlRead($Input1))
    WinWaitActive(GUICtrlRead($Input1))
    ControlFocus(GUICtrlRead($Input1), "", "")
    $fucus = ControlGetFocus(GUICtrlRead($Input1))

    $send = Not $send
    If $send Then
    GUICtrlSetData($Button1, "Aufhörn")
    Else
    GUICtrlSetData($Button1, "Send Blahs")
    EndIf
    EndIf
    EndSwitch

    If $send Then
    ControlSend(GUICtrlRead($Input1), "", $fucus, "Blah")
    Sleep(GUICtrlRead($Input2))
    EndIf
    WEnd

    [/autoit]

    Theoretisch müsste man das senden beenden können indem man nochma auf den Button drückt, aber irgentwie funktioniert es nicht, genauso wie $GUI_EVENT_CLOSE.
    Meiner meinung nach liegs am Sleep befehl... Hat jemand eine ahnung wie man das GUI betätigen könnte?

    Einmal editiert, zuletzt von Worfox (23. August 2008 um 20:00)

  • Ja der SLEEP ist Schuld. Probier's mal so:

    [autoit]

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

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

    Global $Pause = 0
    $send = False

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

    $Form1 = GUICreate("Form1", 214, 244, 193, 125)
    $Input2 = GUICtrlCreateInput("Interval", 40, 48, 121, 21)
    $Input1 = GUICtrlCreateInput("Titel", 40, 88, 121, 21)
    $Button1 = GUICtrlCreateButton("Send Blahs", 56, 136, 75, 25, 0)
    GUISetState(@SW_SHOW)

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $Button1
    If WinExists(GUICtrlRead($Input1)) = False Then
    ToolTip('Es wurde kein Fenster mit dem eingegebenen Titel gefunden!', 0, 0)
    Sleep(1500)
    ToolTip("")
    Else

    If Not WinActive(GUICtrlRead($Input1)) Then WinActivate(GUICtrlRead($Input1))
    WinWaitActive(GUICtrlRead($Input1))
    ControlFocus(GUICtrlRead($Input1), "", "")
    $fucus = ControlGetFocus(GUICtrlRead($Input1))

    $send = Not $send
    If $send Then
    GUICtrlSetData($Button1, "Aufhörn")
    ControlSend(GUICtrlRead($Input1), "", $fucus, "Blah")
    Else
    GUICtrlSetData($Button1, "Send Blahs")
    EndIf
    EndIf
    EndSwitch

    If $send Then
    If $Pause > GUICtrlRead($Input2) Then
    ControlSend(GUICtrlRead($Input1), "", $fucus, "Blah")
    $Pause = 0
    EndIf
    Sleep(10)
    $Pause += 10
    EndIf
    WEnd

    [/autoit]
  • Jap funktioniert, aber jetzt ist da das eigenartige problem das der interval immer größer wird...
    Erst ganz normal dann doppel so groß..

    [autoit]


    If $send Then
    If $Pause >= GUICtrlRead($Input2) Then ; <- Noch ein = eingefügt
    ControlSend(GUICtrlRead($Input1), "", $fucus, "Blah")
    $Pause = 0
    EndIf
    Sleep(5); <-v- Ein bisschen runtergesetzt
    $Pause += 5
    EndIf

    [/autoit]

    Und noch Opt("WinWaitDelay", 15) drangeschrieben, hat aber alles nix gebracht.

  • Und wie sieht's jetzt aus

    [autoit]

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

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

    Global $Pause = 0
    $send = False

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

    $Form1 = GUICreate("Form1", 214, 244, 193, 125)
    $Input2 = GUICtrlCreateInput("Interval", 40, 48, 121, 21)
    $Input1 = GUICtrlCreateInput("Titel", 40, 88, 121, 21)
    $Button1 = GUICtrlCreateButton("Send Blahs", 56, 136, 75, 25, 0)
    GUISetState(@SW_SHOW)

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $Button1
    If WinExists(GUICtrlRead($Input1)) = False Then
    ToolTip('Es wurde kein Fenster mit dem eingegebenen Titel gefunden!', 0, 0)
    Sleep(1500)
    ToolTip("")
    Else

    If Not WinActive(GUICtrlRead($Input1)) Then WinActivate(GUICtrlRead($Input1))
    WinWaitActive(GUICtrlRead($Input1))
    ControlFocus(GUICtrlRead($Input1), "", "")
    $fucus = ControlGetFocus(GUICtrlRead($Input1))

    $send = Not $send
    If $send Then
    GUICtrlSetData($Button1, "Aufhörn")
    ControlSend(GUICtrlRead($Input1), "", $fucus, "Blah")
    $Start= TimerInit()
    Else
    GUICtrlSetData($Button1, "Send Blahs")
    EndIf
    EndIf
    EndSwitch

    If $send Then
    $Dif = TimerDiff($Start)
    If $Dif > GUICtrlRead($Input2) Then
    ControlSend(GUICtrlRead($Input1), "", $fucus, "Blah")
    $Start= TimerInit()
    EndIf
    EndIf
    WEnd

    [/autoit]