Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #AutoIt3Wrapper_icon=1998_low_cost_clock.ico
- #include <Misc.au3>
- Sleep(250)
- If _Singleton("X-Lorem Ipsum",1) = 0 Then
- Msgbox(0,"Warning","An occurence of X-Lorem Ipsum is already running", 3)
- Exit
- EndIf
- #include <File.au3>
- #include <Date.au3>
- #include <String.au3>
- #include <GuiTab.au3>
- #include <Constants.au3>
- #include <EditConstants.au3>
- ;#include <Winamp_Library.au3> ; http://www.autoitscript.com/forum/topic/71187-winamp-library-on-pure-autoit/
- #include <GUIConstantsEx.au3>
- #include <ComboConstants.au3>
- #include <SliderConstants.au3>
- #include <ButtonConstants.au3>
- #include <WindowsConstants.au3>
- #include <ProgressConstants.au3>
- #include <DateTimeConstants.au3>
- #Region ### START Opts and Declarations section ###
- Opt("TrayMenuMode", 3)
- Opt("SendKeyDelay", 150)
- ;Opt("TrayIconDebug", 1)
- Opt("MouseCoordMode", 2)
- Opt("GUIOnEventMode", 1)
- Opt("TrayOnEventMode", 1)
- Opt("MustDeclareVars", 1)
- Opt("WinTitleMatchMode", 2)
- Local $TrayToggleHide, $TrayRestart, $TrayExit, $TrayToggleHotKey
- Local $Form, $Tab, $Tab0, $Tab1, $Tab2, $Tab2_Label1, $Tab2_Label2, $Tab2_Label3, $Tab2_Label4, $Tab2_Label5, $Tab2_Label6, $Tab2_Label7, $Tab2_Label8
- Global $Input_PlaylistorFile, $Input_Snooze, $Input_Time, $Input_Title, $Button_Restart, $Button_Quit
- Global $Combo_WinAmpStop, $Combo_Shutdown, $Combo_TimeFrame, $Combo_WinAmpStart, $Input_SeekTime
- Global $Slider_Fadein_Time, $Slider_Fadein_Time_Value, $Old_Slider1_Value, $Slider_MaxVol, $Slider_MaxVol_Value, $Old_Slider2_Value
- Global $Countdown, $CountdownTotal, $CountdownToDate, $CurrentVolume, $MaxVolume, $Button_Begin, $Button_GetTitle, $Progressbar
- Global $SelectedSong, $FadeTime, $CountdownTime, $Input_AlarmTime, $AlarmTimeData, $FileList, $RandomFile, $Folder
- Global $IniFile = @ScriptDir & "\X-Lorem.ini"
- Global $RndORSel, $MusicPath, $Restart, $Position, $HotKeyAble = 1, $Checkbox_Fade, $Checkbox2_Fade, $Interrupt = 0, $Label8
- #EndRegion ### END Opts and Declarations section ###
- #Region ### START HotKeySet and INI section ###
- HotKeySet("{F2}", "VolUpDownMute") ;ToggleMute
- HotKeySet("{F3}", "VolUpDownMute") ;VolDown
- HotKeySet("{F4}", "VolUpDownMute") ;VolUp
- HotKeySet("{F10}", "ToggleHide")
- $AlarmTimeData = IniRead($IniFile, "Alarm Time", "AlarmTime", @HOUR & ":" & @MIN)
- $Position = StringSplit(IniRead($IniFile, "Position", "Position", "10,420"), ",", 2)
- #EndRegion ### END HotKeySet and INI section section ###
- #Region ### START Koda GUI section ###
- ;$WS_EX_TOPMOST +
- If $Position[0] <> 10 And $Position[1] <> 420 Then
- $Form = GUICreate("X-Lorem Ipsum", 450, 230, $Position[0], $Position[1], Default, $WS_EX_TOOLWINDOW)
- Else
- $Form = GUICreate("X-Lorem Ipsum", 450, 230, 10, 420, Default, $WS_EX_TOOLWINDOW)
- EndIf
- GUISetOnEvent($GUI_EVENT_CLOSE, "Quit")
- GUISetIcon("1998_low_cost_clock.ico")
- GUISetBkColor(0xc0c0c0)
- $Tab = GUICtrlCreateTab(-1, -1, 450, 200)
- GUICtrlSetResizing($Tab, $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT)
- ;
- $Tab0 = GUICtrlCreateTabItem("Lullaby")
- $Combo_WinAmpStop = GUICtrlCreateCombo(" WinAmp ", 15, 40, 135, 20)
- GUICtrlSetData($Combo_WinAmpStop, " Just Stop | Fadeout | Stop-n-Play | Stop When Done | End Program ")
- GUICtrlSetOnEvent($Combo_WinAmpStop, "CheckWinampStop")
- GUICtrlSetTip($Combo_WinAmpStop, " Just Stop " & @LF & " Stop-n-Play - Stop playing, go right to Wakeup " & @LF & " Stop When Done - Stop after the current song ends " & @LF & " End Program ", " How To Stop Winamp.. ", 1)
- $Combo_TimeFrame = GUICtrlCreateCombo(" Lullaby Time ", 170, 40, 115, 20)
- GUICtrlSetData($Combo_TimeFrame, " Specific Time | Hour.Hour | Hour,Minute | Minute ")
- GUICtrlSetOnEvent($Combo_TimeFrame, "CheckTimeCombo")
- GUICtrlSetTip($Combo_TimeFrame, " Specific Time - 4:20 " & @LF & " Hour.Hour - 2.5 - 2 hours 30 minutes " & @LF & " Hour,Minute - 2,30 - 2 hours 30 minutes " & @LF & " Minute - 150 - 2 hours 30 minutes ", " Lullaby Time ", 1)
- $Input_Time = GUICtrlCreateInput("", 340, 40, 65, 25, $ES_CENTER)
- GUICtrlSetState($Input_Time, $GUI_DISABLE)
- $Combo_Shutdown = GUICtrlCreateCombo(" Shutdown Options ", 100, 95, 200, 20)
- GUICtrlSetData($Combo_Shutdown, " Lock | Standby | Hibernate | Reboot | Shutdown")
- GUICtrlSetTip($Combo_Shutdown, " Lock " & @LF & " Standby " & @LF & " Hibernate " & @LF & " Reboot " & @LF & " Shutdown ", " Shutdown Options ", 1)
- $Input_Title = GUICtrlCreateInput("Close Title", 100, 150, 250, 25, $ES_CENTER)
- GUICtrlSetState($Input_Title, $GUI_DISABLE)
- $Button_GetTitle = GUICtrlCreateButton("Title", 20, 150, 60, 25)
- GUICtrlSetOnEvent($Button_GetTitle, "GetTitle")
- ;
- $Tab1 = GUICtrlCreateTabItem("Wakeup")
- $Combo_WinAmpStart = GUICtrlCreateCombo(" WinAmp ", 190, 35, 115, 20)
- GUICtrlSetData($Combo_WinAmpStart, " Start Playing | Select | Random ")
- GUICtrlSetOnEvent($Combo_WinAmpStart, "CheckStartCombo")
- GUICtrlSetTip($Combo_WinAmpStart, "Start Playing - Whatever is on the Playlist" & @LF & "Select - A particular song to play" & @LF & "Random - Choose a directory, a random song is selected ")
- $Input_AlarmTime = GUICtrlCreateInput($AlarmTimeData, 158, 125, 65, 25, $ES_CENTER)
- GUICtrlSetState($Input_AlarmTime, $GUI_DISABLE)
- GUICtrlSetOnEvent($Input_AlarmTime, "WriteAlarmTime")
- GUICtrlCreateLabel("Wakeup", 100, 126)
- $Input_PlaylistorFile = GUICtrlCreateInput("Playlist or File", 80, 90, 250, 25, $ES_CENTER)
- GUICtrlSetState($Input_PlaylistorFile, $GUI_DISABLE)
- $Input_SeekTime = GUICtrlCreateInput("Seek", 350, 90, 50, 25, $ES_CENTER)
- GUICtrlSetState($Input_SeekTime, $GUI_DISABLE)
- $Input_Snooze = GUICtrlCreateInput(IniRead($IniFile, "Snooze Time", "SnoozeTime", 9), 285, 125, 25, 25, $ES_CENTER)
- GUICtrlSetState($Input_Snooze, $GUI_DISABLE)
- GUICtrlSetOnEvent($Input_Snooze, "WriteSnoozeTime")
- GUICtrlCreateLabel("Snooze", 230, 126)
- GUICtrlCreateLabel("Minute(s)", 315, 126)
- $Slider_Fadein_Time = GUICtrlCreateSlider(10, 55, 15, 85, $TBS_VERT)
- GUICtrlCreateLabel("Fade In Time", 10, 35)
- GUICtrlSetOnEvent($Slider_Fadein_Time, "Update_FadeInTime")
- GUICtrlSetLimit($Slider_Fadein_Time, 20, 0)
- GUICtrlSetData($Slider_Fadein_Time, IniRead($IniFile, "Levels", "FadeInTime", 5))
- $Slider_Fadein_Time_Value = GUICtrlCreateLabel(GUICtrlRead($Slider_Fadein_Time), 135, 35)
- $Slider_MaxVol = GUICtrlCreateSlider(40, 75, 15, 85, $TBS_VERT)
- GUICtrlCreateLabel("Max Volume", 40, 55)
- GUICtrlSetOnEvent($Slider_MaxVol, "Update_MaxVolume")
- GUICtrlSetLimit($Slider_MaxVol, 100, 0)
- GUICtrlSetData($Slider_MaxVol, IniRead($IniFile, "Levels", "MaxVolume", 85))
- $Slider_MaxVol_Value = GUICtrlCreateLabel(GUICtrlRead($Slider_MaxVol), 135, 55)
- ;
- $Tab2 = GUICtrlCreateTabItem("Info")
- $Tab2_Label3 = GUICtrlCreateLabel("SPACE - Snooze, Restart" & @LF & @LF & "F2/F3/F4 - Volume Mute/Down/Up" & @LF & "F10 - Show/Hide this Window", 10, 125)
- $Tab2_Label5 = GUICtrlCreateLabel("Text", 10, 35, 500)
- $Tab2_Label6 = GUICtrlCreateLabel("Text", 10, 60, 500)
- $Tab2_Label7 = GUICtrlCreateLabel(" >- Enabled", 240, 165)
- $Tab2_Label8 = GUICtrlCreateLabel(" - Not Enabled", 240, 125, 200)
- $Progressbar = GUICtrlCreateProgress(50, 85, 335, 22, -1, $PBS_SMOOTH)
- GUICtrlSetColor($Progressbar, 0x00f000)
- ;
- GUICtrlCreateTabItem("")
- ;
- $Checkbox_Fade = GUICtrlCreateCheckbox("Fade", 45, 203, 60, 20)
- $Button_Begin = GUICtrlCreateButton("Begin", 110, 203, 75, 25)
- GUICtrlSetOnEvent($Button_Begin, "Lullaby")
- $Button_Restart = GUICtrlCreateButton("Restart", 195, 203, 75, 25)
- GUICtrlSetOnEvent($Button_Restart, "Restart")
- $Button_Quit = GUICtrlCreateButton("Quit", 280, 203, 75, 25)
- GUICtrlSetOnEvent($Button_Quit, "Quit")
- GUISetState(@SW_SHOW)
- #EndRegion ### END Koda GUI section ###
- #Region ### START Tray section ###
- $TrayToggleHide = TrayCreateItem("Show/Hide")
- TrayItemSetOnEvent(-1, "ToggleHide")
- $TrayToggleHotKey = TrayCreateItem("Disable Hotkeys")
- TrayItemSetOnEvent(-1, "ToggleHotKey")
- $TrayRestart = TrayCreateItem("Restart")
- TrayItemSetOnEvent(-1, "Restart")
- $TrayExit = TrayCreateItem("Exit")
- TrayItemSetOnEvent(-1, "Quit")
- ;
- TraySetState()
- TraySetClick(9)
- TraySetIcon(@ScriptDir & "\1998_low_cost_clock.ico")
- TraySetToolTip("X-Lorem Ipsum - Click here for the menu..")
- TraySetOnEvent($TRAY_EVENT_MOUSEOVER,"MouseOverTray")
- #EndRegion ### END Tray section ###
- GUIRegisterMsg($WM_COMMAND, "_WM_COMMAND")
- While 1
- Sleep(100)
- WEnd
- Func Lullaby()
- ControlClick("X-Lorem Ipsum", "", "SysTabControl321", "left", 1, 135, 10)
- If StringStripWS(GUICtrlRead($Combo_WinAmpStop), 3) = "Stop-n-Play" And StringStripWS(GUICtrlRead($Combo_WinAmpStart), 3) = "WinAmp" Then
- GUICtrlSetData($Tab2_Label5, "You must select a wakeup thing too you know..")
- Return
- EndIf
- If BitAnd(GUICtrlRead($Checkbox_Fade), $GUI_CHECKED) Then
- For $iTransValue = 250 To 5 Step -15
- WinSetTrans("X-Lorem Ipsum", "", $iTransValue)
- Sleep(10)
- Next
- WinSetState("X-Lorem Ipsum", "", @SW_HIDE)
- WinSetTrans("X-Lorem Ipsum", "", 255)
- EndIf
- Local $TimeFraction, $ConvertedHour, $ConvertedMinutes, $Timesplit
- If StringStripWS(GUICtrlRead($Combo_TimeFrame), 3) <> "Lullaby Time" Then
- Switch StringStripWS(GUICtrlRead($Combo_TimeFrame), 3)
- Case "Hour.Hour"
- If StringInStr(GUICtrlRead($Input_Time), ".") Then
- $TimeFraction = StringSplit(GUICtrlRead($Input_Time), ".")
- $CountdownToDate = _DateAdd('n', (60 * $TimeFraction[1]) + ((60 * $TimeFraction[2]) / 10), _NowCalc())
- GUICtrlSetData($Tab2_Label5, "$Input_Time - " & GUICtrlRead($Input_Time) & " Hour.Hour - " & StringTrimLeft($CountdownToDate, 11))
- ;MsgBox(0, "", "$Input_Time - " & GUICtrlRead($Input_Time) & " Hour.Hour" & @LF & "$TimeFraction[1] - " & $TimeFraction[1] & @LF & "$TimeFraction[2] - " & $TimeFraction[2] & @LF & $CountdownToDate & @LF)
- Else
- $CountdownToDate = _DateAdd('h', GUICtrlRead($Input_Time), _NowCalc())
- GUICtrlSetData($Tab2_Label5, "$Input_Time - " & GUICtrlRead($Input_Time) & " Hour.Hour - " & StringTrimLeft($CountdownToDate, 11))
- ;MsgBox(0, "", "$Input_Time - " & GUICtrlRead($Input_Time) & @LF & $CountdownToDate & @LF)
- EndIf
- Case "Hour,Minute"
- If StringInStr(GUICtrlRead($Input_Time), ",") Then
- $TimeFraction = StringSplit(GUICtrlRead($Input_Time), ",")
- $CountdownToDate = _DateAdd('n', (60 * $TimeFraction[1]) + $TimeFraction[2], _NowCalc())
- GUICtrlSetData($Tab2_Label5, "$Input_Time - " & GUICtrlRead($Input_Time) & " Hour,Minute - " & StringTrimLeft($CountdownToDate, 11))
- Else
- $CountdownToDate = _DateAdd('h', GUICtrlRead($Input_Time), _NowCalc())
- GUICtrlSetData($Tab2_Label5, "$Input_Time - " & GUICtrlRead($Input_Time) & " Hour,Minute - " & StringTrimLeft($CountdownToDate, 11))
- EndIf
- Case "Minute"
- If StringInStr(GUICtrlRead($Input_Time), ".") Then
- $TimeFraction = StringSplit(GUICtrlRead($Input_Time), ".")
- $CountdownToDate = _DateAdd('s', (60 * $TimeFraction[1]) + ((60 * $TimeFraction[2]) / 10), _NowCalc())
- GUICtrlSetData($Tab2_Label5, "$Input_Time - " & GUICtrlRead($Input_Time) & " Minute - " & StringTrimLeft($CountdownToDate, 11))
- Else
- $CountdownToDate = _DateAdd('n', GUICtrlRead($Input_Time), _NowCalc())
- GUICtrlSetData($Tab2_Label5, _NowCalc() & " - " & GUICtrlRead($Input_Time) & " Minute - " & StringTrimLeft($CountdownToDate, 11))
- EndIf
- Case "Specific Time"
- $Timesplit = StringSplit(Number(StringFormat("%04d",StringRegExpReplace(GUICtrlRead($Input_Time), "\D", ""))), "")
- If StringInStr(GUICtrlRead($Input_Time), "p") Then
- Switch $Timesplit[0]
- Case 3
- $ConvertedHour = $Timesplit[1] + 12
- $ConvertedMinutes = $Timesplit[2] & $Timesplit[3]
- If $ConvertedHour = 24 Then $ConvertedHour = 00
- GUICtrlSetData($Tab2_Label5, "Lullaby Switch 3a, Waiting till " & $ConvertedHour & ":" & $ConvertedMinutes)
- Case 4
- If ($Timesplit[1] & $Timesplit[2]) = 12 Then
- $ConvertedHour = $Timesplit[1] & $Timesplit[2]
- Else
- $ConvertedHour = ($Timesplit[1] & $Timesplit[2]) + 12
- EndIf
- $ConvertedMinutes = $Timesplit[3] & $Timesplit[4]
- If $ConvertedHour = 24 Then $ConvertedHour = 00
- GUICtrlSetData($Tab2_Label5, "Lullaby Switch 4a, Waiting till " & $ConvertedHour & ":" & $ConvertedMinutes)
- EndSwitch
- Else
- Switch $Timesplit[0]
- Case 3
- $ConvertedHour = $Timesplit[1]
- $ConvertedMinutes = $Timesplit[2] & $Timesplit[3]
- GUICtrlSetData($Tab2_Label5, "Lullaby Switch 3b, Waiting till " & $ConvertedHour & ":" & $ConvertedMinutes)
- Case 4
- If ($Timesplit[1] & $Timesplit[2]) = 12 Then
- $ConvertedHour = 0
- Else
- $ConvertedHour = $Timesplit[1] & $Timesplit[2]
- EndIf
- $ConvertedMinutes = $Timesplit[3] & $Timesplit[4]
- GUICtrlSetData($Tab2_Label5, "Lullaby Switch 4b, Waiting till " & $ConvertedHour & ":" & $ConvertedMinutes)
- EndSwitch
- EndIf
- Local $DateDiffCalc = _DateDiff( 's', StringTrimRight(_NowCalc(), 8) & $ConvertedHour & ":" & $ConvertedMinutes & ":" & "00", _NowCalc())
- Local $TotalDateDiffCalc = $DateDiffCalc
- GUICtrlSetData($Progressbar, ($DateDiffCalc / $TotalDateDiffCalc) * 100)
- Do
- If $Interrupt = 1 Then Restart()
- If $Interrupt = 2 Then Quit()
- ;If $Interrupt = 3 Then Quit()
- $DateDiffCalc = _DateDiff( 's', StringTrimRight(_NowCalc(), 8) & $ConvertedHour & ":" & $ConvertedMinutes & ":" & "00", _NowCalc())
- If $DateDiffCalc <> $TotalDateDiffCalc Then GUICtrlSetData($Progressbar, ($DateDiffCalc / $TotalDateDiffCalc) * 100)
- Sleep(10)
- Until Number($ConvertedHour & $ConvertedMinutes) = @Hour & @Min
- GUICtrlSetData($Progressbar, 0)
- EndSwitch
- ;GUICtrlSetData($Tab2_Label5, GUICtrlRead($Input_Time) & " " & StringStripWS(GUICtrlRead($Combo_TimeFrame), 3) & " (" & StringTrimLeft($CountdownToDate, 11) & ") - " & GUICtrlRead($Combo_WinAmpStop))
- GUICtrlSetData($Tab2_Label6, GUICtrlRead($Input_AlarmTime) & " " & GUICtrlRead($Combo_WinAmpStart) & " " & GUICtrlRead($Input_PlaylistorFile))
- If StringStripWS(GUICtrlRead($Combo_TimeFrame), 3) <> "Specific Time" Then
- Local $DateDiffCalc = _DateDiff( 's', _NowCalc(), $CountdownToDate)
- Local $TotalDateDiffCalc = $DateDiffCalc
- GUICtrlSetData($Progressbar, ($DateDiffCalc / $TotalDateDiffCalc) * 100)
- Do
- If $Interrupt = 1 Then Restart()
- If $Interrupt = 2 Then Quit()
- $DateDiffCalc = _DateDiff( 's', _NowCalc(), $CountdownToDate)
- If $DateDiffCalc <> $TotalDateDiffCalc Then GUICtrlSetData($Progressbar, ($DateDiffCalc / $TotalDateDiffCalc) * 100)
- Sleep(10)
- ;Until StringTrimRight(StringTrimLeft($CountdownToDate, 11), 3) & ":00" = StringTrimRight(StringTrimLeft(_NowCalc(), 11), 3) & ":00"
- Until StringTrimLeft($CountdownToDate, 11) = StringTrimLeft(_NowCalc(), 11)
- GUICtrlSetData($Progressbar, 0)
- EndIf
- EndIf
- RunAfterLullaby()
- EndFunc ;==>Lullaby
- Func RunAfterLullaby()
- GUICtrlSetData($Tab2_Label5, "Lullaby Done..")
- If StringStripWS(GUICtrlRead($Combo_WinAmpStop), 3) <> "WinAmp" Then
- Switch StringStripWS(GUICtrlRead($Combo_WinAmpStop), 3)
- Case "Just Stop"
- _Winamp_Stop()
- Case "Fadeout"
- ;ControlSend("Winamp", "", "", "+!v")
- Send("+!v")
- Case "Stop-n-Play"
- WakeupNow()
- Case "Stop When Done"
- ControlSend("Winamp", "", "", "^v")
- Case "End Program"
- _Winamp_Close()
- EndSwitch
- EndIf
- If GUICtrlRead($Input_Title) <> "Close Title" Or GUICtrlRead($Input_Title) <> "" Then WinClose(GUICtrlRead($Input_Title)) ;WinKill(GUICtrlRead($Input_Title))
- If StringStripWS(GUICtrlRead($Combo_Shutdown), 3) <> "Winamp" Then
- Switch StringStripWS(GUICtrlRead($Combo_Shutdown), 3)
- Case "Lock"
- Run("rundll32.exe user32.dll, LockWorkStation")
- Case "Standby"
- Shutdown(32)
- Case "Hibernate"
- Shutdown(64)
- Case "Reboot"
- Shutdown(18)
- Case "Shutdown"
- Shutdown(13)
- EndSwitch
- EndIf
- If StringStripWS(GUICtrlRead($Combo_WinAmpStart), 3) <> "WinAmp" Then WaitforWakeup()
- EndFunc ;==>RunAfterLullaby
- Func WaitforWakeup()
- Local $ConvertedHour, $ConvertedMinutes, $Timesplit
- ;ControlClick("X-Lorem Ipsum", "", "SysTabControl321", "left", 1, 75, 10)
- $Timesplit = StringSplit(Number(StringFormat("%04d",StringRegExpReplace(GUICtrlRead($Input_AlarmTime), "\D", ""))), "")
- If StringInStr(GUICtrlRead($Input_AlarmTime), "p") Then
- Switch $Timesplit[0]
- Case 3
- $ConvertedHour = $Timesplit[1] + 12
- $ConvertedMinutes = $Timesplit[2] & $Timesplit[3]
- If $ConvertedHour = 24 Then $ConvertedHour = 0
- GUICtrlSetData($Tab2_Label5, "Wakeup Case 3a, waiting till " & $ConvertedHour & $ConvertedMinutes)
- Case 4
- If ($Timesplit[1] & $Timesplit[2]) = 12 Then
- $ConvertedHour = $Timesplit[1] & $Timesplit[2]
- Else
- $ConvertedHour = ($Timesplit[1] & $Timesplit[2]) + 12
- EndIf
- $ConvertedMinutes = $Timesplit[3] & $Timesplit[4]
- If $ConvertedHour = 24 Then $ConvertedHour = 0
- GUICtrlSetData($Tab2_Label5, "Wakeup Case 4a, waiting till " & $ConvertedHour & $ConvertedMinutes)
- EndSwitch
- Else
- Switch $Timesplit[0]
- Case 3
- $ConvertedHour = $Timesplit[1]
- $ConvertedMinutes = $Timesplit[2] & $Timesplit[3]
- GUICtrlSetData($Tab2_Label5, "Wakeup Case 3b, waiting till " & $ConvertedHour & $ConvertedMinutes & " (" & @HOUR & ":" & @MIN & ")")
- Case 4
- If ($Timesplit[1] & $Timesplit[2]) = 12 Then
- $ConvertedHour = 0
- Else
- $ConvertedHour = $Timesplit[1] & $Timesplit[2]
- EndIf
- $ConvertedMinutes = $Timesplit[3] & $Timesplit[4]
- GUICtrlSetData($Tab2_Label5, "Wakeup Case 4b, waiting till " & $ConvertedHour & $ConvertedMinutes & " (" & @HOUR & ":" & @MIN & ")")
- EndSwitch
- EndIf
- Local $DateDiffCalc = _DateDiff( 's', StringTrimRight(_NowCalc(), 8) & $ConvertedHour & ":" & $ConvertedMinutes & ":" & "00", _NowCalc())
- Local $TotalDateDiffCalc = $DateDiffCalc
- GUICtrlSetData($Progressbar, ($DateDiffCalc / $TotalDateDiffCalc) * 100)
- Do
- If $Interrupt = 1 Then Restart()
- If $Interrupt = 2 Then Quit()
- $DateDiffCalc = _DateDiff( 's', StringTrimRight(_NowCalc(), 8) & $ConvertedHour & ":" & $ConvertedMinutes & ":" & "00", _NowCalc())
- If $DateDiffCalc <> $TotalDateDiffCalc Then GUICtrlSetData($Progressbar, ($DateDiffCalc / $TotalDateDiffCalc) * 100)
- Sleep(10)
- Until Number($ConvertedHour & $ConvertedMinutes) = @Hour & @Min
- GUICtrlSetData($Progressbar, 0)
- WakeupNow()
- EndFunc ;==>WaitforWakeup
- Func WakeupNow()
- If _Winamp_GetCurrentTrackPlayStatus() Then _Winamp_Stop()
- HotKeySet("{SPACE}", "Snooze")
- GUICtrlSetData($Tab2_Label8, " - {SPACE} to Snooze") ;Spacebar (snooze)
- GUICtrlSetData($Tab2_Label5, "Time to start..")
- _Winamp_SetVolume(0)
- If StringStripWS(GUICtrlRead($Combo_WinAmpStart), 3) <> "WinAmp" Then
- Switch StringStripWS(GUICtrlRead($Combo_WinAmpStart), 3)
- Case "Start Playing"
- _Winamp_Play()
- Case "Select"
- _Winamp_ClearPlayList()
- _Winamp_AddFile($SelectedSong)
- _Winamp_Play()
- Case "Random"
- _Winamp_ClearPlayList()
- _Winamp_AddFile(StringReplace($MusicPath[0], ";", ":"))
- _Winamp_Play()
- EndSwitch
- EndIf
- ;ControlClick("X-Lorem Ipsum", "", "SysTabControl321", "left", 1, 115, 10)
- GUICtrlSetData($Tab2_Label5, "Fade In..")
- Fadein(GUICtrlRead($Slider_Fadein_Time), GUICtrlRead($Slider_MaxVol))
- GUICtrlSetData($Tab2_Label5, "Done for now..")
- ;GUICtrlSetData($Tab2_Label8, " - Disabled") ; Spacebar (snooze)
- ;HotKeySet("{SPACE}")
- EndFunc ;==>WakeupNow
- Func Fadein($FadeTime, $MaxVolume)
- ; If Main is muted, un-mute it
- PixelSearch(1260, 780, 1275, 790, 0xFF0000)
- If Not @error Then Send("{VOLUME_MUTE}")
- ;
- Switch @OSVersion
- Case "WIN_VISTA", "WIN_7"
- Run("sndvol.exe", "", @SW_HIDE)
- Case "WIN_XP"
- Run("sndvol32.exe", "", @SW_HIDE)
- EndSwitch
- WinWaitActive("Volume Mixer")
- ControlSend("Volume Mixer", "", "msctls_trackbar321", "{HOME}") ; Max system volume
- WinClose("Volume Mixer")
- If _Winamp_GetVolume() = 0 Then
- Do
- If $Interrupt = 1 Then Restart()
- If $Interrupt = 2 Then Quit()
- _Winamp_SetVolume(-1, 1)
- Sleep($FadeTime * 35)
- GUICtrlSetData($Progressbar, _Winamp_GetVolume())
- Until _Winamp_GetVolume() / 255 * 100 >= $MaxVolume
- Else
- MsgBox(0, "", ";==>Fadein: Winamp has volume, Quitting Fadein.", 2)
- EndIf
- EndFunc ;==>Fadein
- Func Update_FadeInTime()
- If GUICtrlRead($Slider_Fadein_Time) <> $Old_Slider1_Value Then
- GUICtrlSetData($Slider_Fadein_Time_Value, GUICtrlRead($Slider_Fadein_Time))
- $Old_Slider1_Value = GUICtrlRead($Slider_Fadein_Time)
- IniWrite($IniFile, "Levels", "FadeInTime", GUICtrlRead($Slider_Fadein_Time))
- EndIf
- EndFunc ;==>Update_FadeInTime
- Func Update_MaxVolume()
- If GUICtrlRead($Slider_MaxVol) <> $Old_Slider2_Value Then
- GUICtrlSetData($Slider_MaxVol_Value, GUICtrlRead($Slider_MaxVol))
- $Old_Slider2_Value = GUICtrlRead($Slider_MaxVol)
- IniWrite($IniFile, "Levels", "MaxVolume", GUICtrlRead($Slider_MaxVol))
- EndIf
- EndFunc ;==>Update_MaxVolume
- Func VolUpDownMute()
- Switch @HotKeyPressed
- Case "{F2}"
- Send("{VOLUME_MUTE}")
- Case "{F3}"
- Send("{VOLUME_DOWN}")
- Case "{F4}"
- Send("{VOLUME_UP}")
- EndSwitch
- EndFunc
- Func Snooze()
- HotKeySet("{SPACE}", "Quit")
- ;HotKeySet("{SPACE}", "Restart")
- GUICtrlSetData($Tab2_Label8, " - {SPACE} to quit")
- If _Winamp_GetCurrentTrackPlayStatus() Then
- Local $SnoozeTime = Number(GUICtrlRead($Input_Snooze))
- Local $SnoozeTill = _DateAdd('n', $SnoozeTime, _NowCalc())
- GUICtrlSetData($Tab2_Label5, "Snoozing for " & $SnoozeTime & " minutes, since " & @HOUR & ":" & @MIN & ", to " & StringTrimLeft(StringTrimRight($SnoozeTill, 3), 11))
- If Not BitAND(WinGetState("X-Lorem Ipsum"), 2) Then SplashTextOn("", "Snoozing for " & $SnoozeTime & " minutes, since " & @HOUR & ":" & @MIN & ", to " & StringTrimLeft(StringTrimRight($SnoozeTill, 3), 11), 850, 55, 200, 630, 33, "Comic Sans MS", 20)
- _Winamp_Stop()
- Do
- If $Interrupt = 1 Then Restart()
- If $Interrupt = 2 Then Quit()
- Sleep(10)
- Until @HOUR & ":" & @MIN & ":" & @SEC = StringTrimLeft($SnoozeTill, 11)
- GUICtrlSetData($Tab2_Label5, "Fade In..")
- SplashOff()
- _Winamp_SetVolume(0)
- _Winamp_Play()
- HotKeySet("{SPACE}", "Snooze")
- GUICtrlSetData($Tab2_Label8, " - {SPACE} to Snooze") ;Spacebar (snooze)
- Fadein(GUICtrlRead($Slider_Fadein_Time), GUICtrlRead($Slider_MaxVol))
- EndIf
- EndFunc ;==>Snooze
- Func PickMusic()
- $RndORSel = 0
- GUICtrlSetState($Input_PlaylistorFile, $GUI_ENABLE)
- Local $Drive, $Dir, $FName, $Ext
- $SelectedSong = FileOpenDialog("Select Song", "C:\Users\Public\Music\Music", "Media files (*.mp3;*.m4a;*.m3u) | All (*.*)")
- If @error Then
- $SelectedSong = IniRead($IniFile, "Wakeup File", "SoundFile", "NotFound")
- Else
- IniWriteSection($IniFile, "Wakeup File", "SoundFile=" & $SelectedSong)
- EndIf
- $MusicPath = StringSplit($SelectedSong, "\")
- GUICtrlSetData($Input_PlaylistorFile, StringTrimRight($MusicPath[$MusicPath[0]], 4))
- EndFunc ;==>PickMusic
- Func RndMusic()
- $RndORSel = 1
- GUICtrlSetState($Input_PlaylistorFile, $GUI_ENABLE)
- Local $Folder, $Drive, $Dir, $FName, $Ext
- $Folder = FileSelectFolder("Select A Music Folder", "C:\Users\Public\Music\Music", 6)
- $FileList = _FileListToArray($Folder, "*", 1)
- If @error = 1 Then
- MsgBox(0, "", "No Files\Folders Found.")
- Exit
- EndIf
- Do
- $RandomFile = Random(1, $FileList[0], 1)
- $MusicPath = _PathSplit($Folder & "\" & $FileList[$RandomFile], $Drive, $Dir, $FName, $Ext)
- Until $MusicPath[4] = ".mp3" Or $MusicPath[4] = ".m4a" Or $MusicPath[4] = ".m3u"
- GUICtrlSetData($Input_PlaylistorFile, $FileList[$RandomFile])
- EndFunc ;==>RndMusic
- Func ToggleHide()
- If BitAND(WinGetState("X-Lorem Ipsum", ""), 2) Then
- WinSetState("X-Lorem Ipsum", "", @SW_HIDE)
- Else
- WinSetState("X-Lorem Ipsum", "", @SW_SHOW)
- EndIf
- EndFunc ;==>ToggleHide
- Func CheckStartCombo()
- Switch StringStripWS(GUICtrlRead($Combo_WinAmpStart), 3)
- Case "Winamp"
- GUICtrlSetState($Input_AlarmTime, $GUI_DISABLE)
- GUICtrlSetState($Input_Snooze, $GUI_DISABLE)
- GUICtrlSetData($Input_PlaylistorFile, "Playlist or File")
- GUICtrlSetState($Input_PlaylistorFile, $GUI_DISABLE)
- Case "Start Playing"
- If StringStripWS(GUICtrlRead($Combo_WinAmpStop), 3) <> "Stop-n-Play" Then GUICtrlSetState($Input_AlarmTime, $GUI_ENABLE)
- GUICtrlSetState($Input_Snooze, $GUI_ENABLE)
- Case "Select"
- If StringStripWS(GUICtrlRead($Combo_WinAmpStop), 3) <> "Stop-n-Play" Then GUICtrlSetState($Input_AlarmTime, $GUI_ENABLE)
- GUICtrlSetState($Input_Snooze, $GUI_ENABLE)
- PickMusic()
- Case "Random"
- If StringStripWS(GUICtrlRead($Combo_WinAmpStop), 3) <> "Stop-n-Play" Then GUICtrlSetState($Input_AlarmTime, $GUI_ENABLE)
- GUICtrlSetState($Input_Snooze, $GUI_ENABLE)
- RndMusic()
- EndSwitch
- EndFunc
- Func GetTitle()
- Local $dll = DllOpen("user32.dll")
- GUICtrlSetState($Input_Title, $GUI_ENABLE)
- While 1
- ToolTip("Click on the App now")
- Sleep(50)
- If _IsPressed("01", $dll) Then ExitLoop
- WEnd
- DllClose($dll)
- ToolTip("")
- GUICtrlSetData($Input_Title, WinGetTitle("[active]"))
- EndFunc ;==>GetTitle
- Func CheckTimeCombo()
- Switch StringStripWS(GUICtrlRead($Combo_TimeFrame), 3)
- Case "Specific Time"
- GUICtrlSetState($Input_Time, $GUI_ENABLE)
- GUICtrlSetData($Input_Time, "4:20")
- Case "Hour.Hour"
- GUICtrlSetState($Input_Time, $GUI_ENABLE)
- GUICtrlSetData($Input_Time, "2.5")
- Case "Hour,Minute"
- GUICtrlSetState($Input_Time, $GUI_ENABLE)
- GUICtrlSetData($Input_Time, "2,30")
- Case "Minute"
- GUICtrlSetState($Input_Time, $GUI_ENABLE)
- GUICtrlSetData($Input_Time, "150")
- Case "Lullaby Time"
- GUICtrlSetState($Input_Time, $GUI_DISABLE)
- GUICtrlSetData($Input_Time, "")
- EndSwitch
- EndFunc ;==>CheckTimeCombo
- Func SlidersSave()
- IniWrite($IniFile, "Levels", "FadeInTime", GUICtrlRead($Slider_Fadein_Time))
- IniWrite($IniFile, "Levels", "MaxVolume", GUICtrlRead($Slider_MaxVol))
- EndFunc
- Func WriteSnoozeTime()
- IniWrite($IniFile, "Snooze Time", "SnoozeTime", GUICtrlRead($Input_Snooze))
- ;MsgBox(0, "Snooze Time", "$Input_Snooze = " & $Input_Snooze & " GUI_CtrlId = " & @GUI_CtrlId & @LF)
- EndFunc
- Func WriteAlarmTime()
- IniWrite($IniFile, "Alarm Time", "AlarmTime", GUICtrlRead($Input_AlarmTime))
- ;MsgBox(0, "Alarm Time", "GUI_CtrlId = " & @GUI_CtrlId & @LF)
- EndFunc
- Func MouseOverTray()
- If BitAND(WinGetState("X-Lorem Ipsum", ""), 2) Then
- TrayItemSetText($TrayToggleHide, "Hide Window")
- Else
- TrayItemSetText($TrayToggleHide, "Show Window")
- EndIf
- EndFunc
- Func ToggleHotKey()
- Switch $HotKeyAble
- Case 0
- TrayItemSetText($TrayToggleHotKey, "Disable Hotkeys")
- GUICtrlSetData($Tab2_Label7, " >- Enabled")
- GUICtrlSetData($Tab2_Label8, $Label8) ;Spacebar (snooze)
- HotKeySet("{F2}", "VolUpDownMute")
- HotKeySet("{F3}", "VolUpDownMute")
- HotKeySet("{F4}", "VolUpDownMute")
- HotKeySet("{F10}", "ToggleHide")
- HotKeySet("{SPACE}", "Snooze")
- $HotKeyAble = 1
- Case 1
- Switch GUICtrlRead($Tab2_Label8)
- Case " - Not Enabled"
- $Label8 = " - Not Enabled"
- Case " - {SPACE} to Snooze"
- $Label8 = " - {SPACE} to Snooze"
- EndSwitch
- TrayItemSetText($TrayToggleHotKey, "Enable Hotkeys")
- GUICtrlSetData($Tab2_Label7, " |- Disabled")
- GUICtrlSetData($Tab2_Label8, " - Disabled") ;Spacebar (snooze)
- HotKeySet("{F2}")
- HotKeySet("{F3}")
- HotKeySet("{F4}")
- HotKeySet("{F10}")
- HotKeySet("{SPACE}")
- $HotKeyAble = 0
- EndSwitch
- EndFunc ;==>ToggleHotKey
- Func CheckWinampStop()
- If StringStripWS(GUICtrlRead($Combo_WinAmpStop), 3) <> "Stop-n-Play" Then GUICtrlSetState($Input_AlarmTime, $GUI_DISABLE)
- EndFunc
- Func _WM_COMMAND($hWnd, $Msg, $wParam, $lParam)
- If BitAND($wParam, 0x0000FFFF) = $Button_Restart Then $Interrupt = 1
- If BitAND($wParam, 0x0000FFFF) = $Button_Quit Or BitAND($wParam, 0x0000FFFF) = $GUI_EVENT_CLOSE Then $Interrupt = 2
- ;If BitAND($wParam, 0x0000FFFF) = $GUI_EVENT_CLOSE Then $Interrupt = 3
- EndFunc ;==>_WM_COMMAND
- Func Restart()
- If @HotKeyPressed = "{SPACE}" Then _Winamp_Play()
- $Position = WinGetPos("X-Lorem Ipsum")
- If $Position[0] <> 10 And $Position[1] <> 420 Then IniWrite($IniFile, "Position", "Position", $Position[0] & "," & $Position[1])
- ; Restart your program - http://www.autoitscript.com/forum/index.php?s=&showtopic=19370&view=findpost&p=199608
- ; Author UP_NORTH
- If @Compiled = 1 Then
- Run(FileGetShortName(@ScriptFullPath))
- Else
- Run(FileGetShortName(@AutoItExe) & " " & FileGetShortName(@ScriptFullPath))
- EndIf
- Exit
- EndFunc ;==>Restart
- Func Quit()
- If @HotKeyPressed = "{SPACE}" Then _Winamp_Play()
- $Position = WinGetPos("X-Lorem Ipsum")
- If $Position[0] <> 10 And $Position[1] <> 420 Then IniWrite($IniFile, "Position", "Position", $Position[0] & "," & $Position[1])
- Exit
- EndFunc ;==>Quit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement