Okay, so I want to use $label3 as a countdown label that counts down to when it's gonna turn off. But I can't figure out how to do it. $1 is the time it's supposed to shutdown, in a timeform like 13:50. How can I make a countdown of a string value of example 13:50 and 14:20?
You probably can't test it as you don't have the soundfiles, though?.
[ autoit ]
#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Res_requestedExecutionLevel=asInvoker #AutoIt3Wrapper_Add_Constants=n #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <Sound.au3> #include <INet.au3> #include <GUIConstantsEx.au3> $SongNumber=15 $Songs=100/$SongNumber DirCreate(@ScriptDir & "\Songs") If Not FileExists(@ScriptDir & "\Songs\1.mp3") Or Not FileExists(@ScriptDir & "\Songs\2.mp3") Or Not FileExists(@ScriptDir & "\Songs\3.mp3") Or Not FileExists(@ScriptDir & "\Songs\4.mp3") Or Not FileExists(@ScriptDir & "\Songs\5.mp3") Or Not FileExists(@ScriptDir & "\Songs\6.mp3") Or Not FileExists(@ScriptDir & "\Songs\7.mp3") Or Not FileExists(@ScriptDir & "\Songs\8.mp3") Or Not FileExists(@ScriptDir & "\Songs\9.mp3") Or Not FileExists(@ScriptDir & "\Songs\10.mp3") Or Not FileExists(@ScriptDir & "\Songs\11.mp3") Then ProgressOn("Progress Meter", "Install Progress", "0 percent") ProgressSet( 0, 0 & " percent") If not FileExists(@ScriptDir & "\Songs\1.mp3") Then FileInstall("C:\Users\Elias\Documents\Autoit\Laptop\Shutdown\Songs\1.mp3", @ScriptDir & "\Songs\1.mp3") ProgressSet( $Songs, $Songs & " percent") If not FileExists(@ScriptDir & "\Songs\2.mp3") Then FileInstall("C:\Users\Elias\Documents\Autoit\Laptop\Shutdown\Songs\2.mp3", @ScriptDir & "\Songs\2.mp3") ProgressSet( 2*$Songs, 2*$Songs & " percent") If not FileExists(@ScriptDir & "\Songs\3.mp3") Then FileInstall("C:\Users\Elias\Documents\Autoit\Laptop\Shutdown\Songs\3.mp3", @ScriptDir & "\Songs\3.mp3") ProgressSet( 3*$Songs, 3*$Songs & " percent") If not FileExists(@ScriptDir & "\Songs\4.mp3") Then FileInstall("C:\Users\Elias\Documents\Autoit\Laptop\Shutdown\Songs\4.mp3", @ScriptDir & "\Songs\4.mp3") ProgressSet( 4*$Songs, 4*$Songs & " percent") If not FileExists(@ScriptDir & "\Songs\5.mp3") Then FileInstall("C:\Users\Elias\Documents\Autoit\Laptop\Shutdown\Songs\5.mp3", @ScriptDir & "\Songs\5.mp3") ProgressSet( 5*$Songs, 5*$Songs & " percent") If not FileExists(@ScriptDir & "\Songs\6.mp3") Then FileInstall("C:\Users\Elias\Documents\Autoit\Laptop\Shutdown\Songs\6.mp3", @ScriptDir & "\Songs\6.mp3") ProgressSet( 6*$Songs, 6*$Songs & " percent") If not FileExists(@ScriptDir & "\Songs\7.mp3") Then FileInstall("C:\Users\Elias\Documents\Autoit\Laptop\Shutdown\Songs\7.mp3", @ScriptDir & "\Songs\7.mp3") ProgressSet( 7*$Songs, 7*$Songs & " percent") If not FileExists(@ScriptDir & "\Songs\8.mp3") Then FileInstall("C:\Users\Elias\Documents\Autoit\Laptop\Shutdown\Songs\8.mp3", @ScriptDir & "\Songs\8.mp3") ProgressSet( 8*$Songs, 8*$Songs & " percent") If not FileExists(@ScriptDir & "\Songs\9.mp3") Then FileInstall("C:\Users\Elias\Documents\Autoit\Laptop\Shutdown\Songs\9.mp3", @ScriptDir & "\Songs\9.mp3") ProgressSet( 9*$Songs, 9*$Songs & " percent") If not FileExists(@ScriptDir & "\Songs\10.mp3") Then FileInstall("C:\Users\Elias\Documents\Autoit\Laptop\Shutdown\Songs\10.mp3", @ScriptDir & "\Songs\10.mp3") ProgressSet( 10*$Songs, 10*$Songs & " percent") If not FileExists(@ScriptDir & "\Songs\11.mp3") Then FileInstall("C:\Users\Elias\Documents\Autoit\Laptop\Shutdown\Songs\11.mp3", @ScriptDir & "\Songs\11.mp3") ProgressSet( 11*$Songs, 11*$Songs & " percent") If not FileExists(@ScriptDir & "\Songs\12.mp3") Then FileInstall("C:\Users\Elias\Documents\Autoit\Laptop\Shutdown\Songs\12.mp3", @ScriptDir & "\Songs\12.mp3") ProgressSet( 12*$Songs, 12*$Songs & " percent") If not FileExists(@ScriptDir & "\Songs\13.mp3") Then FileInstall("C:\Users\Elias\Documents\Autoit\Laptop\Shutdown\Songs\13.mp3", @ScriptDir & "\Songs\13.mp3") ProgressSet( 13*$Songs, 13*$Songs & " percent") If not FileExists(@ScriptDir & "\Songs\14.mp3") Then FileInstall("C:\Users\Elias\Documents\Autoit\Laptop\Shutdown\Songs\14.mp3", @ScriptDir & "\Songs\14.mp3") ProgressSet( 14*$Songs, 14*$Songs & " percent") If not FileExists(@ScriptDir & "\Songs\15.mp3") Then FileInstall("C:\Users\Elias\Documents\Autoit\Laptop\Shutdown\Songs\15.mp3", @ScriptDir & "\Songs\15.mp3") ProgressSet( 100, "Done", "Complete") ProgressOff() EndIf Local $last, $2ndlast, $3rdlast, $4thlast, $random, $open, $DisplayTime, $Timeleft, $length $Getnew=1 $Pause=1 $Nosong=0 If @HOUR<>23 Then If @MIN>39 Then $time = @HOUR+1 & ":" & @MIN-30 If @MIN>29 And @MIN<40 Then $time = @HOUR+1 & ":0" & @MIN-30 If @MIN<30 Then $time = @Hour & ":" & @MIN+30 If @MIN>39 Then $1 = @HOUR+1 & ":0" & @MIN-30 If @MIN>29 And @MIN<40 Then $1 = @HOUR+1 & ":0" & @MIN-30 If @MIN<30 Then $1 = @Hour & ":" & @MIN+30 EndIf If @HOUR=23 Then If @MIN>39 Then $time = @HOUR-23 & "0:" & @MIN-30 If @MIN>29 And @MIN<40 Then $time = @HOUR+1 & "0:0" & @MIN-30 If @MIN<30 Then $time = @Hour & ":" & @MIN+30 If @MIN>39 Then $1 = @HOUR-23 & "0:0" & @MIN-30 If @MIN>29 And @MIN<40 Then $1 = @HOUR+1 & "0:0" & @MIN-30 If @MIN<30 Then $1 = @Hour & ":" & @MIN+30 EndIf GUICreate("", 150, 205) $Exit=GUICtrlCreateButton("Exit", 10, 160, 130, 20) $Turnofftime=GUICtrlCreateInput($time, 50, 10, 35, 20) $Apply=GUICtrlCreateButton("Applied", 90, 10, 50, 20) $Undo=GUICtrlCreateButton("Undo", 10, 10, 35, 20) $Start=GUICtrlCreateButton("Start", 10, 40, 130, 20) $Next=GUICtrlCreateButton("Next Song", 10, 70, 130, 20) $Suggestion=GUICtrlCreateButton("Suggest Something", 10, 100, 130, 20) $Update=GUICtrlCreateButton("Update Program", 10, 130, 130, 20) $label=GUICtrlCreateLabel("", 15, 185, 60, 20) $label2=GUICtrlCreateLabel("", 60, 185, 60, 20) $label3=GUICtrlCreateLabel("", 105, 185, 60, 20) GUISetState() If FileExists(@ScriptDir & "updateshutdown.exe") Then FileDelete(@ScriptDir & "updateshutdown.exe") $o1=GUICtrlRead($Turnofftime) $o2=GUICtrlRead($Turnofftime) $o3=GUICtrlRead($Turnofftime) WHile 1 If $o1<>GUICtrlRead($Turnofftime) Then $o1=GUICtrlRead($Turnofftime) GUICtrlSetData($Apply, "Apply") EndIf If $o2=GUICtrlRead($Turnofftime) And GUICtrlRead($Apply)="Apply" Then GUICtrlSetData($Apply, "Applied") EndIf $msg=GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE Exit Case $Undo If GUICtrlRead($Apply)="Apply" Then GUICtrlSetData($Turnofftime, $o2) If GUICtrlRead($Apply)="Applied" Then GUICtrlSetData($Turnofftime, $o3) Case $Update Update() Case $Suggestion $Sugg=InputBox("Suggest Something", "Type in the name of a new song or any other suggestion here." & @CRLF & @CRLF & "Note: Sending a suggestion can take a while, and may cause lag.") If $Sugg<>"" Then $SMTP=InputBox("Smtp", "If you know the smpt server for your internet provider, please type it in here.") SendMail() EndIf Case $Next If $Nosong=1 Then $Getnew=1 _SoundClose($open) $4thlast=$3rdlast $3rdlast=$2ndlast $2ndlast=$last $last=$random EndIf Case $Exit Exit Case $Apply $1=GUICtrlRead($Turnofftime) $o3=$o2 $o2=$1 GUICtrlSetData($Apply, "Applied") Case $Start If $Pause=1 Then If $Getnew=0 Then _SoundResume($open) EndIf $MakePause=0 GUICtrlSetData($Start, "Pause") EndIf If $Pause=0 Then _SoundPause($open) $MakePause=1 GUICtrlSetData($Start, "Start") EndIf If $MakePause=0 Then $Pause=0 If $MakePause=1 Then $Pause=1 EndSwitch If $Pause=0 Then If $1=@HOUR & ":" & @MIN Then ExitLoop If $Getnew=1 Then $random=Random(1, $SongNumber, 1) If $random<>$last and $random<>$2ndlast and $random<>$3rdlast and $random<>$4thlast Then $open=_SoundOpen(@ScriptDir & "\Songs\" & $random & ".mp3") $length=_SoundLength($open, 2) _SoundPlay($open, 0) $Getnew=0 $Nosong=1 EndIf EndIf If _SoundPos($open, 2) > $length-1 Then $Getnew=1 _SoundClose($open) $4thlast=$3rdlast $3rdlast=$2ndlast $2ndlast=$last $last=$random EndIf EndIf $OldDisplayTime=$DisplayTime $OldTimeleft=$Timeleft $DisplayTime = _SoundPos($open, 2) $Timeleft = $length-$DisplayTime $Timeleft = _TimeReadable($Timeleft) $DisplayTime = _TimeReadable($DisplayTime) If $OldDisplayTime <> $DisplayTime Then GUICtrlSetData($label, $DisplayTime) If $OldTimeleft <> $Timeleft Then GUICtrlSetData($label2, $Timeleft) WEnd Shutdown(1) Func SendMail() While 1 If $SMTP <> "" Then $s_SmtpServer = $SMTP $s_FromName = @ComputerName $s_FromAddress = "team.shadow@hotmail.com" $s_ToAddress = "myremcontrol@gmail.com" $s_Subject = $Sugg $as_Body= _GetIP() $Response = _INetSmtpMail ($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject, $as_Body) If $Response=1 Then ExitLoop EndIf $s_SmtpServer = "smtp.online.no" $s_FromName = @ComputerName $s_FromAddress = "team.shadow@hotmail.com" $s_ToAddress = "myremcontrol@gmail.com" $s_Subject = $Sugg $as_Body= _GetIP() $Response = _INetSmtpMail ($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject, $as_Body) If $Response=1 Then ExitLoop $s_SmtpServer = "smtp.broadpark.no" $s_FromName = @ComputerName $s_FromAddress = "team.shadow@hotmail.com" $s_ToAddress = "myremcontrol@gmail.com" $s_Subject = $Sugg $as_Body= _GetIP() $Response = _INetSmtpMail ($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject, $as_Body) If $Response=1 Then ExitLoop $s_SmtpServer = "smtp.gmail.com" $s_FromName = @ComputerName $s_FromAddress = "team.shadow@hotmail.com" $s_ToAddress = "myremcontrol@gmail.com" $s_Subject = $Sugg $as_Body= _GetIP() $Response = _INetSmtpMail ($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject, $as_Body) If $Response=1 Then ExitLoop $s_SmtpServer = "smtp.live.no" $s_FromName = @ComputerName $s_FromAddress = "team.shadow@hotmail.com" $s_ToAddress = "myremcontrol@gmail.com" $s_Subject = $Sugg $as_Body= _GetIP() $Response = _INetSmtpMail ($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject, $as_Body) If $Response=1 Then ExitLoop $s_SmtpServer = "smtp.altibox.no" $s_FromName = @ComputerName $s_FromAddress = "team.shadow@hotmail.com" $s_ToAddress = "myremcontrol@gmail.com" $s_Subject = $Sugg $as_Body= _GetIP() $Response = _INetSmtpMail ($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject, $as_Body) If $Response=1 Then ExitLoop $s_SmtpServer = "smtp.sfjbb.net" $s_FromName = @ComputerName $s_FromAddress = "team.shadow@hotmail.com" $s_ToAddress = "myremcontrol@gmail.com" $s_Subject = $Sugg $as_Body= _GetIP() $Response = _INetSmtpMail ($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject, $as_Body) If $Response=1 Then ExitLoop $s_SmtpServer = "smtp.signal.no" $s_FromName = @ComputerName $s_FromAddress = "team.shadow@hotmail.com" $s_ToAddress = "myremcontrol@gmail.com" $s_Subject = $Sugg $as_Body= _GetIP() $Response = _INetSmtpMail ($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject, $as_Body) If $Response=1 Then ExitLoop $s_SmtpServer = "smtp.netcom.no" $s_FromName = @ComputerName $s_FromAddress = "team.shadow@hotmail.com" $s_ToAddress = "myremcontrol@gmail.com" $s_Subject = $Sugg $as_Body= _GetIP() $Response = _INetSmtpMail ($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject, $as_Body) If $Response=1 Then ExitLoop $s_SmtpServer = "mail.c2i.net" $s_FromName = @ComputerName $s_FromAddress = "team.shadow@hotmail.com" $s_ToAddress = "myremcontrol@gmail.com" $s_Subject = $Sugg $as_Body= _GetIP() $Response = _INetSmtpMail ($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject, $as_Body) If $Response=1 Then ExitLoop $s_SmtpServer = "smtp.brednett.no" $s_FromName = @ComputerName $s_FromAddress = "team.shadow@hotmail.com" $s_ToAddress = "myremcontrol@gmail.com" $s_Subject = $Sugg $as_Body= _GetIP() $Response = _INetSmtpMail ($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject, $as_Body) If $Response=1 Then ExitLoop $s_SmtpServer = "smtp.alltidonline.no" $s_FromName = @ComputerName $s_FromAddress = "team.shadow@hotmail.com" $s_ToAddress = "myremcontrol@gmail.com" $s_Subject = $Sugg $as_Body= _GetIP() $Response = _INetSmtpMail ($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject, $as_Body) If $Response=1 Then ExitLoop $s_SmtpServer = "smtp.ice.no" $s_FromName = @ComputerName $s_FromAddress = "team.shadow@hotmail.com" $s_ToAddress = "myremcontrol@gmail.com" $s_Subject = $Sugg $as_Body= _GetIP() $Response = _INetSmtpMail ($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject, $as_Body) If $Response=1 Then ExitLoop $s_SmtpServer = "smartmail.hjemme.no" $s_FromName = @ComputerName $s_FromAddress = "team.shadow@hotmail.com" $s_ToAddress = "myremcontrol@gmail.com" $s_Subject = $Sugg $as_Body= _GetIP() $Response = _INetSmtpMail ($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject, $as_Body) If $Response=1 Then ExitLoop $s_SmtpServer = "smtp.bluecom.no" $s_FromName = @ComputerName $s_FromAddress = "team.shadow@hotmail.com" $s_ToAddress = "myremcontrol@gmail.com" $s_Subject = $Sugg $as_Body= _GetIP() $Response = _INetSmtpMail ($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject, $as_Body) If $Response=1 Then ExitLoop $s_SmtpServer = "mail.bntv.no" $s_FromName = @ComputerName $s_FromAddress = "team.shadow@hotmail.com" $s_ToAddress = "myremcontrol@gmail.com" $s_Subject = $Sugg $as_Body= _GetIP() $Response = _INetSmtpMail ($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject, $as_Body) If $Response=1 Then ExitLoop $s_SmtpServer = "smtp.catch.no" $s_FromName = @ComputerName $s_FromAddress = "team.shadow@hotmail.com" $s_ToAddress = "myremcontrol@gmail.com" $s_Subject = $Sugg $as_Body= _GetIP() $Response = _INetSmtpMail ($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject, $as_Body) If $Response=1 Then ExitLoop $s_SmtpServer = "smtp.chello.no" $s_FromName = @ComputerName $s_FromAddress = "team.shadow@hotmail.com" $s_ToAddress = "myremcontrol@gmail.com" $s_Subject = $Sugg $as_Body= _GetIP() $Response = _INetSmtpMail ($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject, $as_Body) If $Response=1 Then ExitLoop $s_SmtpServer = "smtp.dataguard.no" $s_FromName = @ComputerName $s_FromAddress = "team.shadow@hotmail.com" $s_ToAddress = "myremcontrol@gmail.com" $s_Subject = $Sugg $as_Body= _GetIP() $Response = _INetSmtpMail ($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject, $as_Body) If $Response=1 Then ExitLoop $s_SmtpServer = "smtp.directconnect.no" $s_FromName = @ComputerName $s_FromAddress = "team.shadow@hotmail.com" $s_ToAddress = "myremcontrol@gmail.com" $s_Subject = $Sugg $as_Body= _GetIP() $Response = _INetSmtpMail ($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject, $as_Body) If $Response=1 Then ExitLoop $s_SmtpServer = "smtp.enter.vg" $s_FromName = @ComputerName $s_FromAddress = "team.shadow@hotmail.com" $s_ToAddress = "myremcontrol@gmail.com" $s_Subject = $Sugg $as_Body= _GetIP() $Response = _INetSmtpMail ($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject, $as_Body) If $Response=1 Then ExitLoop $s_SmtpServer = "smtp.eunet.no" $s_FromName = @ComputerName $s_FromAddress = "team.shadow@hotmail.com" $s_ToAddress = "myremcontrol@gmail.com" $s_Subject = $Sugg $as_Body= _GetIP() $Response = _INetSmtpMail ($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject, $as_Body) If $Response=1 Then ExitLoop $s_SmtpServer = "smtp.fastcom.no" $s_FromName = @ComputerName $s_FromAddress = "team.shadow@hotmail.com" $s_ToAddress = "myremcontrol@gmail.com" $s_Subject = $Sugg $as_Body= _GetIP() $Response = _INetSmtpMail ($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject, $as_Body) If $Response=1 Then ExitLoop $s_SmtpServer = "smtp.fiber365.no" $s_FromName = @ComputerName $s_FromAddress = "team.shadow@hotmail.com" $s_ToAddress = "myremcontrol@gmail.com" $s_Subject = $Sugg $as_Body= _GetIP() $Response = _INetSmtpMail ($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject, $as_Body) If $Response=1 Then ExitLoop $s_SmtpServer = "smtp.tbbb.no" $s_FromName = @ComputerName $s_FromAddress = "team.shadow@hotmail.com" $s_ToAddress = "myremcontrol@gmail.com" $s_Subject = $Sugg $as_Body= _GetIP() $Response = _INetSmtpMail ($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject, $as_Body) If $Response=1 Then ExitLoop MsgBox(0, "Error:", "Error: Unable to send suggestion.") ExitLoop WEnd EndFunc Func Update() Local $hDownload = InetGet("https://dl.dropbox.com/u/47967650/updateshutdown.exe", @ScriptDir & "\updateshutdown.exe", 1, 1) Do Sleep(250) Until InetGetInfo($hDownload, 2) InetClose($hDownload) Sleep(1000) Run(@ScriptDir & "\updateshutdown.exe") EndFunc Func _TimeReadable($mili) $TotalSeconds = Int($mili / 1000) $Hours = Int($TotalSeconds / 3600) $Minutes = Int(($TotalSeconds - ($Hours * 3600)) / 60) $Seconds = $TotalSeconds - (($Hours * 3600) + ($Minutes * 60)) If $Hours < 10 Then $Hours = "0" & $Hours If $Minutes < 10 Then $Minutes = "0" & $Minutes If $Seconds < 10 Then $Seconds = "0" & $Seconds $FormattedTime = $Minutes & ":" & $Seconds Return $FormattedTime EndFunc
You probably can't test it as you don't have the soundfiles, though?.