Popup mit Timer einbauen

  • Hi also ich wollte fragen ob es möglich ist in das jetzige Script einen Timer aufbauen der wenn man das programm öffnet automatisch ein popup öffnet wo drin steht wie lange es noch bis zu einer bestimmten Uhrzeit ist.

    Spoiler anzeigen

    #include <GUIConstants.au3>
    #include <IE.au3>
    Opt("GUIOnEventMode", 1)

    $gui = GUICreate('', 250, 200, -1, -1)
    GUICtrlSetBkColor(Default, $GUI_BKCOLOR_TRANSPARENT)
    GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
    $button = GUICtrlCreateButton("Click on me !!!", 48, 164, 104, 17, 0)
    GUICtrlSetOnEvent(-1, "OnClick")
    GuiCtrlCreatepic("Hintergrund.JPG", 0 , 0 , 250, 200)
    $1 = GUICtrlCreateLabel("", 48, 124, 64, 17)
    $2 = GUICtrlCreateLabel("", 48, 144, 64, 17)
    GUISetState()

    AdlibEnable("_a1", 1000); aktualisiert jede sekunde das Datum und die Uhrzeit

    While 1
    sleep(1000)
    WEnd

    Func _a1() ; Datum und uhrzeit aktuell halten
    GUICtrlSetData($2, @HOUR & ":" & @MIN & ":" & @SEC)
    GUICtrlSetData($1, @MDAY & "." & @MON & "." & @YEAR)
    EndFunc ;==>_a1

    Func OKButton()
    MsgBox(0, "GUI Event", "You have clicked on OK!")
    Exit
    EndFunc ;==>OKButton

    Func CLOSEClicked()
    MsgBox(0, "GUI Event", "You have clicked on CLOSE! Program will be shut down ...")
    Exit
    EndFunc ;==>CLOSEClicked

    Func OnClick()
    Run("...")
    ShellExecute("www.autoit.de")
    Exit
    EndFunc ;==>OnClick

  • Spoiler anzeigen
    [autoit]

    #include <GUIConstants.au3>
    #include <IE.au3>
    #Include <Date.au3>
    #include <Array.au3>
    Opt("GUIOnEventMode", 1)

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

    $gui = GUICreate('', 250, 200, -1, -1)
    GUICtrlSetBkColor(Default, $GUI_BKCOLOR_TRANSPARENT)
    GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
    $button = GUICtrlCreateButton("Click on me !!!", 48, 164, 104, 17, 0)
    GUICtrlSetOnEvent(-1, "OnClick")
    GuiCtrlCreatepic("Hintergrund.JPG", 0 , 0 , 250, 200)
    $1 = GUICtrlCreateLabel("", 48, 124, 64, 17)
    $2 = GUICtrlCreateLabel("", 48, 144, 64, 17)
    GUISetState()

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

    AdlibEnable("_a1", 500); aktualisiert jede halbe sekunde das Datum und die Uhrzeit

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

    While 1 * Sleep (100)
    ToolTip(_CalcTimeTillTime("23:59:00"),MouseGetPos(0),MouseGetPos(1))
    WEnd

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

    Func _a1() ; Datum und uhrzeit aktuell halten
    GUICtrlSetData($2, @HOUR & ":" & @MIN & ":" & @SEC)
    GUICtrlSetData($1, @MDAY & "." & @MON & "." & @YEAR)

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

    EndFunc ;==>_a1

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

    Func _CalcTimeTillTime($sTime)
    Local $iNow = _TimeToTicks(), $iLater, $iLaterH, $iLaterM, $iLaterS
    $sTime = StringSplit($sTime,":",2)
    $iLater = _TimeToTicks($sTime[0],$sTime[1],$sTime[2])
    _TicksToTime($iLater - $iNow,$iLaterH, $iLaterM, $iLaterS)
    $iLater = StringFormat("%02i:%02i:%02i", $iLaterH, $iLaterM, $iLaterS)
    Return($iLater)
    EndFunc
    Func OKButton()
    MsgBox(0, "GUI Event", "You have clicked on OK!")
    Exit
    EndFunc ;==>OKButton

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

    Func CLOSEClicked()
    MsgBox(0, "GUI Event", "You have clicked on CLOSE! Program will be shut down ...")
    Exit
    EndFunc ;==>CLOSEClicked

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

    Func OnClick()
    Run("...")
    ShellExecute("www.autoit.de")
    Exit
    EndFunc ;==>OnClick

    [/autoit]
  • hey danke das klappt super nur eine sachen wäre noch und zwar die "uhr" steht ja jetzt auf 23.59.00 aber kann man das auch so ändern das man die zeit bis 12 , 16 , 20 uhr etc sieht ? Also das wenn es 16.01 ist man noch ca 4h sieht also immer bis zum nächsten "gesetzten zeitpunkt".

  • Musste ein bisschen umbasteln... doofe zeit muss ja unbedingt bei 24 wieder auf 0 springen >.>

    Spoiler anzeigen
    [autoit]

    #include <GUIConstants.au3>
    #include <IE.au3>
    #Include <Date.au3>
    #include <Array.au3>
    Opt("GUIOnEventMode", 1)

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

    $gui = GUICreate('', 250, 200, -1, -1)
    GUICtrlSetBkColor(Default, $GUI_BKCOLOR_TRANSPARENT)
    GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
    $button = GUICtrlCreateButton("Click on me !!!", 48, 164, 104, 17, 0)
    GUICtrlSetOnEvent(-1, "OnClick")
    GuiCtrlCreatepic("Hintergrund.JPG", 0 , 0 , 250, 200)
    $1 = GUICtrlCreateLabel("", 48, 124, 64, 17)
    $2 = GUICtrlCreateLabel("", 48, 144, 64, 17)
    GUISetState()

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

    AdlibEnable("_a1", 500); aktualisiert jede halbe sekunde das Datum und die Uhrzeit

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

    While 1 * Sleep (100)
    If @HOUR >= 12 AND @HOUR < 16 Then
    ToolTip("Bis 16 Uhr sinds noch: "&_CalcTimeTillTime("16:00:00"),MouseGetPos(0),MouseGetPos(1))
    ElseIf @HOUR >= 16 AND @HOUR < 20 Then
    ToolTip("Bis 20 Uhr sinds noch: "&_CalcTimeTillTime("20:00:00"),MouseGetPos(0),MouseGetPos(1))
    ElseIf (@HOUR >= 20 AND @HOUR <= 23) OR (@HOUR >= 0 AND @HOUR < 12) Then
    ToolTip("Bis 12 Uhr sinds noch: "&_CalcTimeTillTime("12:00:00"),MouseGetPos(0),MouseGetPos(1))
    EndIf
    WEnd

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

    Func _a1() ; Datum und uhrzeit aktuell halten
    GUICtrlSetData($2, @HOUR & ":" & @MIN & ":" & @SEC)
    GUICtrlSetData($1, @MDAY & "." & @MON & "." & @YEAR)

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

    EndFunc ;==>_a1

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

    Func _CalcTimeTillTime($sTime)
    Local $iNow = _TimeToTicks(), $iLater, $iLaterH, $iLaterM, $iLaterS
    $sTime = StringSplit($sTime,":",2)
    $iLater = _TimeToTicks($sTime[0],$sTime[1],$sTime[2])
    If $iLater < $iNow Then $iLater += (_TimeToTicks(23,59,59)+1000)
    _TicksToTime($iLater - $iNow,$iLaterH, $iLaterM, $iLaterS)
    ConsoleWrite("$iNow: "&$iNow&@CRLF&" $iLater: "&$iLater&@CRLF)
    $iLater = StringFormat("%02i:%02i:%02i", $iLaterH, $iLaterM, $iLaterS)
    Return($iLater)
    EndFunc
    Func OKButton()
    MsgBox(0, "GUI Event", "You have clicked on OK!")
    Exit
    EndFunc ;==>OKButton

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

    Func CLOSEClicked()
    MsgBox(0, "GUI Event", "You have clicked on CLOSE! Program will be shut down ...")
    Exit
    EndFunc ;==>CLOSEClicked

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

    Func OnClick()
    Run("...")
    ShellExecute("www.autoit.de")
    Exit
    EndFunc ;==>OnClick

    [/autoit]
  • cool super danke genau wie ich wollte vielen dank aber wie muss man die Koordinaten verändern das das Popup ein kleines stück neben der maus ist ?

    Einmal editiert, zuletzt von concepta (27. November 2009 um 21:17)

    • Offizieller Beitrag
    Spoiler anzeigen
    [autoit]

    #include <GUIConstants.au3>
    #include <IE.au3>
    #Include <Date.au3>
    #include <Array.au3>
    Opt("GUIOnEventMode", 1)

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

    $gui = GUICreate('', 250, 200, -1, -1)
    GUICtrlSetBkColor(Default, $GUI_BKCOLOR_TRANSPARENT)
    GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
    $button = GUICtrlCreateButton("Click on me !!!", 48, 164, 104, 17, 0)
    GUICtrlSetOnEvent(-1, "OnClick")
    GuiCtrlCreatepic("Hintergrund.JPG", 0 , 0 , 250, 200)
    $1 = GUICtrlCreateLabel("", 48, 124, 64, 17)
    $2 = GUICtrlCreateLabel("", 48, 144, 64, 17)
    GUISetState()

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

    AdlibEnable("_a1", 500); aktualisiert jede halbe sekunde das Datum und die Uhrzeit

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

    While 1 * Sleep (100)
    If @HOUR >= 12 AND @HOUR < 16 Then
    ToolTip("Bis 16 Uhr sinds noch: "&_CalcTimeTillTime("16:00:00"),MouseGetPos(0)+20,MouseGetPos(1))
    ElseIf @HOUR >= 16 AND @HOUR < 20 Then
    ToolTip("Bis 20 Uhr sinds noch: "&_CalcTimeTillTime("20:00:00"),MouseGetPos(0)+20,MouseGetPos(1))
    ElseIf (@HOUR >= 20 AND @HOUR <= 23) OR (@HOUR >= 0 AND @HOUR < 12) Then
    ToolTip("Bis 12 Uhr sinds noch: "&_CalcTimeTillTime("12:00:00"),MouseGetPos(0)+20,MouseGetPos(1))
    EndIf
    WEnd

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

    Func _a1() ; Datum und uhrzeit aktuell halten
    GUICtrlSetData($2, @HOUR & ":" & @MIN & ":" & @SEC)
    GUICtrlSetData($1, @MDAY & "." & @MON & "." & @YEAR)

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

    EndFunc ;==>_a1

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

    Func _CalcTimeTillTime($sTime)
    Local $iNow = _TimeToTicks(), $iLater, $iLaterH, $iLaterM, $iLaterS
    $sTime = StringSplit($sTime,":",2)
    $iLater = _TimeToTicks($sTime[0],$sTime[1],$sTime[2])
    If $iLater < $iNow Then $iLater += (_TimeToTicks(23,59,59)+1000)
    _TicksToTime($iLater - $iNow,$iLaterH, $iLaterM, $iLaterS)
    ConsoleWrite("$iNow: "&$iNow&@CRLF&" $iLater: "&$iLater&@CRLF)
    $iLater = StringFormat("%02i:%02i:%02i", $iLaterH, $iLaterM, $iLaterS)
    Return($iLater)
    EndFunc
    Func OKButton()
    MsgBox(0, "GUI Event", "You have clicked on OK!")
    Exit
    EndFunc ;==>OKButton

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

    Func CLOSEClicked()
    MsgBox(0, "GUI Event", "You have clicked on CLOSE! Program will be shut down ...")
    Exit
    EndFunc ;==>CLOSEClicked

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

    Func OnClick()
    Run("...")
    ShellExecute("www.autoit.de")
    Exit
    EndFunc ;==>OnClick

    [/autoit]