Jump to content

Search the Community

Showing results for tags 'time remaining'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Location


WWW


Interests

Found 1 result

  1. It's been a long time since I use autoit, and its time to share something and help to someone. Now I just wanna to share something from my work, to contribute to the community. This project is made on request from my friend. Maybe this will help someone to make something else like NewYear countdown #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon=blue_shutdown.ico #AutoIt3Wrapper_Outfile=Auto ShutDown.Exe #AutoIt3Wrapper_Res_Description=Auto Shutdown for PC #AutoIt3Wrapper_Res_Fileversion=1.1 #AutoIt3Wrapper_Res_LegalCopyright=Boris Kerkez - boriskerkez@hotmail.com #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** ; AutoIt Version: 3.3.12.0 #include <Constants.au3> #include <WindowsConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <ButtonConstants.au3> #include <Timers.au3> ; BUG: ako drzis pritisnut taster(broj) i stisnes ENTER moguce je da ce $Button1 ostati NEAKTIVAN posto $input1, $input1 su prazni ; Ako se vreme na PC promeni u toku tajmera, on to nece registrovati zato sto on odbrojava a ne proverava svake sekunde HH:MM Opt("TrayMenuMode", 1) Global $hGUI, $Active = 0, $FirstTime = 1 Global $remaining_min, $remaining_sec Global $timer_countdown, $calc_option = 1, $readInp_H, $readInp_M, $readInp_after_M $appTitle = "Auto ShutDown v1.1" $gui_w = 280 $gui_h = 150 $hGUI = GUICreate($appTitle, $gui_w, $gui_h) GUISetFont(10, 400, 0, "Verdana") ; Start at $Label1 = GUICtrlCreateLabel("Shutdown at (hh:mm):", 6, 8, 200, 20) $Input1 = GUICtrlCreateInput(@HOUR, 190, 5, 35, 24, BitOR($ES_CENTER, $ES_AUTOHSCROLL, $ES_NUMBER)) GUICtrlSetLimit(-1, 2) $Input2 = GUICtrlCreateInput(@MIN, 240, 5, 35, 24, BitOR($ES_CENTER, $ES_AUTOHSCROLL, $ES_NUMBER)) GUICtrlSetLimit(-1, 2) GUICtrlCreateLabel(":", 230, 8, 5, 20) ; After X minutes $Label2 = GUICtrlCreateLabel("Shutdown after (minutes):", 6, 40, 200, 20) $Input3 = GUICtrlCreateInput("", 190, 39, 85, 24, BitOR($ES_CENTER, $ES_AUTOHSCROLL, $ES_NUMBER)) GUICtrlSetLimit(-1, 6) $Label3 = GUICtrlCreateLabel("", 0, 80, $gui_w, 24, $ES_CENTER) GUICtrlSetFont(-1, 14, 600, 0, "Verdana", 5) GUICtrlSetColor(-1, 0x436EEE) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) ; fix label flickering $Button1 = GUICtrlCreateButton("Set", 5, 120, $gui_w-10, 25, $BS_DEFPUSHBUTTON) GUISetState(@SW_SHOW) While 1 If Not $Active Then Local $memoInp_H = $readInp_H, $memoInp_M = $readInp_M, $memoInp_after_M = $readInp_after_M $readInp_H = GUICtrlRead($Input1) $readInp_M = GUICtrlRead($Input2) $readInp_after_M = GUICtrlRead($Input3) If $memoInp_H <> $readInp_H OR $memoInp_M <> $readInp_M OR $memoInp_after_M <> $readInp_after_M Then ; proveri input1 & input2 + input3(mora biti prazan) | moraju da imaju minimalno 1 cifru (max2 ne treba, postavljen je input limit) | trebaju biti u range-u H=0-23, M=0-59 ; If ( StringLen($readInp_H) < 1 OR $readInp_H < 0 OR $readInp_H > 23 OR StringLen($readInp_M) < 1 OR $readInp_M < 0 OR $readInp_M > 59 AND StringLen($readInp_after_M) = 0 ) Then _Button1StateChange("DISABLE") If ($readInp_H < 0 OR $readInp_H > 23) Then GUICtrlSetData($Input1, "") EndIf If ($readInp_M < 0 OR $readInp_M > 59) Then GUICtrlSetData($Input2, "") EndIf Else If ( StringLen($readInp_after_M) = 0 ) Then $calc_option = 1 ; option: at HH:MM Else ; proveri $Input3 da ne bude 0 i da ne pocinje sa 0 If (StringLeft($readInp_after_M, 1) = 0) Then GUICtrlSetData($Input3, "") _Button1StateChange("DISABLE") Else $calc_option = 2 ; option: after X minutes GUICtrlSetData($Input1, "") GUICtrlSetData($Input2, "") EndIf EndIf _Button1StateChange("ENABLE") EndIf ; ;DEBUG ;ConsoleWrite( $readInp_H &":"& $readInp_M &" | opt:"& $calc_option &" |msec:"& @MSEC & @CRLF) EndIf EndIf ; TRAY msg $tMsg = TrayGetMsg() Switch $tMsg Case $TRAY_EVENT_PRIMARYDOWN _ShowGUI() EndSwitch ; GUI msg $gMsg = GUIGetMsg() Switch $gMsg Case $GUI_EVENT_CLOSE ; Stop the countdown _CountdownStop() Exit Case $GUI_EVENT_MINIMIZE ; Move GUI to tray _HideGUI() ; First time message If $FirstTime Then TrayTip($appTitle, $appTitle & " is minimized to the tray. Click on the tray icon here to restore the window.", 10, $TIP_ICONASTERISK) $FirstTime = 0 EndIf Case $Button1 If Not $Active Then _GUI_Ctrls_DISABLE() ; Calculate and register _CalculateRemainingTime() Else _GUI_Ctrls_ENABLE() ; Stop the countdown _CountdownStop() EndIf EndSwitch WEnd Func _ShowGUI() Opt("TrayIconHide", 1) GUISetState(@SW_SHOW) EndFunc Func _HideGUI() Opt("TrayIconHide", 0) GUISetState(@SW_HIDE) EndFunc Func _GUI_Ctrls_ENABLE() GUICtrlSetState($Input1, $GUI_ENABLE) GUICtrlSetState($Input2, $GUI_ENABLE) GUICtrlSetState($Input3, $GUI_ENABLE) GUICtrlSetData($Button1, "Set") $Active = 0 EndFunc Func _GUI_Ctrls_DISABLE() GUICtrlSetState($Input1, $GUI_DISABLE) GUICtrlSetState($Input2, $GUI_DISABLE) GUICtrlSetState($Input3, $GUI_DISABLE) GUICtrlSetData($Button1, "Cancel") $Active = 1 EndFunc Func _Button1StateChange($button1_state = "ENABLE") If $button1_state = "ENABLE" Then If ( GUICtrlGetState($Button1) = 144 ) Then GUICtrlSetState($Button1, $GUI_ENABLE) EndIf Elseif $button1_state = "DISABLE" Then If ( GUICtrlGetState($Button1) = 80 ) Then GUICtrlSetState($Button1, $GUI_DISABLE) EndIf EndIf EndFunc Func _CalculateRemainingTime() Do ; fix bug with milliseconds Until _MSec() <= 999 Switch $calc_option Case 1 ;OPTION: at HH:MM ; ispravi format - dodaj 0 ispred da bude HH:MM If ( StringLen($readInp_H) < 2 ) Then $readInp_H = 0 & $readInp_H EndIf If ( StringLen($readInp_M) < 2 ) Then $readInp_M = 0 & $readInp_M EndIf ; izracunaj preostale minute If ( $readInp_H >= @HOUR ) Then If ( $readInp_H = @HOUR AND $readInp_M < @MIN ) Then $remaining_min = 1440 - ((@HOUR - $readInp_H)*60 + (@MIN - $readInp_M)) ;(24h*60min=1440min) - (H razlika)*60 + (M razlika) ;ConsoleWrite ( " inH = @H AND inM < @M |min:" & $remaining_min &@CRLF) Else $remaining_min = ((@HOUR - $readInp_H)*60 + (@MIN - $readInp_M)) * -1 ;ConsoleWrite ( " inH >= @H |min:" & $remaining_min &@CRLF) EndIf Else $remaining_min = 1440 - ((@HOUR - $readInp_H)*60 + (@MIN - $readInp_M)) ;(24h*60min=1440min) - (H razlika)*60 + (M razlika) ;ConsoleWrite ( " inH < @H |min:" & $remaining_min &@CRLF) EndIf ; konvertuj u sekunde If ($remaining_min = 0) Then $remaining_sec = (60-@SEC) - $remaining_min * 60 Else $remaining_sec = $remaining_min * 60 - @SEC EndIf Case 2 ; OPTION: after X minutes $remaining_sec = $readInp_after_M * 60 - @SEC EndSwitch ; loading string GUICtrlSetData($Label3, "Loading...") ; fix input bug If ( $remaining_sec <= 0 ) Then GUICtrlSetData($Label3, "Don`t hack me bro!") _GUI_Ctrls_ENABLE() Return EndIf ; fix bug with milliseconds $remaining_sec -= 1 ; set timer for countdown function $timer_countdown = _Timer_Settimer($hGUI, 1000, "_Countdown") EndFunc ;==>CalculateRemainingTime Func _CountdownStop() _Timer_KillTimer($hGUI, $timer_countdown) GUICtrlSetData($Label3, "") EndFunc ;==>CountdownStop Func _Countdown($hWnd, $iMsg, $iIDTimer, $iTime) #forceref $hWnd, $iMsg, $iIDTimer, $iTime If $Active Then Local $sec, $min, $hr $sec = Mod($remaining_sec, 60) $min = Mod($remaining_sec / 60, 60) $hr = Floor($remaining_sec / 60 ^ 2) GUICtrlSetData($Label3, "Time left: " & StringFormat("%02i:%02i:%02i", $hr, $min, $sec)) EndIf If $remaining_sec = 300 Then ; 5min TrayTip($appTitle, "Attention: 5 minutes to shudown!", 10, $TIP_ICONEXCLAMATION) Elseif $remaining_sec = 120 Then ;2min TrayTip($appTitle, "Attention: 2 minutes to shudown!", 10, $TIP_ICONEXCLAMATION) Elseif $remaining_sec = 60 Then ;1min TrayTip($appTitle, "Attention: 1 minute to shudown!", 10, $TIP_ICONEXCLAMATION) ElseIf $remaining_sec <= 10 AND $remaining_sec > 0 Then _ShowGUI() GUICtrlSetColor($Label3, 0xEE4000) ElseIf $remaining_sec <= 0 Then _CountdownStop() ;ConsoleWrite("Shutdown " &@MSEC &@CRLF) ;EXECUTE SHUTDOWN Shutdown(1) Exit EndIf $remaining_sec -= 1 EndFunc ;==>Countdown Func _MSec() Local $stSystemTime = DllStructCreate('ushort;ushort;ushort;ushort;ushort;ushort;ushort;ushort') DllCall('kernel32.dll', 'none', 'GetSystemTime', 'ptr', DllStructGetPtr($stSystemTime)) $sMilliSeconds = StringFormat('%03d', DllStructGetData($stSystemTime, 8)) $stSystemTime = 0 Return $sMilliSeconds EndFunc ;==>Msec blue_shutdown.ico Auto ShutDown.rar
×
×
  • Create New...