Advertisement
somdcomputerguy

X-LoremIpsum.au3

Apr 16th, 2024
1,344
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 28.35 KB | Source Code | 0 0
  1. #AutoIt3Wrapper_icon=1998_low_cost_clock.ico
  2. #include <Misc.au3>
  3.  
  4. Sleep(250)
  5.  
  6. If _Singleton("X-Lorem Ipsum",1) = 0 Then
  7.     Msgbox(0,"Warning","An occurence of X-Lorem Ipsum is already running", 3)
  8.     Exit
  9. EndIf
  10.  
  11. #include <File.au3>
  12. #include <Date.au3>
  13. #include <String.au3>
  14. #include <GuiTab.au3>
  15. #include <Constants.au3>
  16. #include <EditConstants.au3>
  17. ;#include <Winamp_Library.au3> ; http://www.autoitscript.com/forum/topic/71187-winamp-library-on-pure-autoit/
  18. #include <GUIConstantsEx.au3>
  19. #include <ComboConstants.au3>
  20. #include <SliderConstants.au3>
  21. #include <ButtonConstants.au3>
  22. #include <WindowsConstants.au3>
  23. #include <ProgressConstants.au3>
  24. #include <DateTimeConstants.au3>
  25.  
  26. #Region ### START Opts and Declarations section ###
  27. Opt("TrayMenuMode", 3)
  28. Opt("SendKeyDelay", 150)
  29. ;Opt("TrayIconDebug", 1)
  30. Opt("MouseCoordMode", 2)
  31. Opt("GUIOnEventMode", 1)
  32. Opt("TrayOnEventMode", 1)
  33. Opt("MustDeclareVars", 1)
  34. Opt("WinTitleMatchMode", 2)
  35.  
  36. Local $TrayToggleHide, $TrayRestart, $TrayExit, $TrayToggleHotKey
  37. Local $Form, $Tab, $Tab0, $Tab1, $Tab2, $Tab2_Label1, $Tab2_Label2, $Tab2_Label3, $Tab2_Label4, $Tab2_Label5, $Tab2_Label6, $Tab2_Label7, $Tab2_Label8
  38. Global $Input_PlaylistorFile, $Input_Snooze, $Input_Time, $Input_Title, $Button_Restart, $Button_Quit
  39. Global $Combo_WinAmpStop, $Combo_Shutdown, $Combo_TimeFrame, $Combo_WinAmpStart, $Input_SeekTime
  40. Global $Slider_Fadein_Time, $Slider_Fadein_Time_Value, $Old_Slider1_Value, $Slider_MaxVol, $Slider_MaxVol_Value, $Old_Slider2_Value
  41. Global $Countdown, $CountdownTotal, $CountdownToDate, $CurrentVolume, $MaxVolume, $Button_Begin, $Button_GetTitle, $Progressbar
  42. Global $SelectedSong, $FadeTime, $CountdownTime, $Input_AlarmTime, $AlarmTimeData, $FileList, $RandomFile, $Folder
  43. Global $IniFile = @ScriptDir & "\X-Lorem.ini"
  44. Global $RndORSel, $MusicPath, $Restart, $Position, $HotKeyAble = 1, $Checkbox_Fade, $Checkbox2_Fade, $Interrupt = 0, $Label8
  45. #EndRegion ### END Opts and Declarations section ###
  46.  
  47. #Region ### START HotKeySet and INI section ###
  48. HotKeySet("{F2}", "VolUpDownMute") ;ToggleMute
  49. HotKeySet("{F3}", "VolUpDownMute") ;VolDown
  50. HotKeySet("{F4}", "VolUpDownMute") ;VolUp
  51. HotKeySet("{F10}", "ToggleHide")
  52.  
  53. $AlarmTimeData = IniRead($IniFile, "Alarm Time", "AlarmTime", @HOUR & ":" & @MIN)
  54. $Position      = StringSplit(IniRead($IniFile, "Position", "Position", "10,420"), ",", 2)
  55. #EndRegion ### END HotKeySet and INI section section ###
  56.  
  57. #Region ### START Koda GUI section ###
  58. ;$WS_EX_TOPMOST +
  59. If $Position[0] <> 10 And $Position[1] <> 420 Then
  60.     $Form = GUICreate("X-Lorem Ipsum", 450, 230, $Position[0], $Position[1], Default, $WS_EX_TOOLWINDOW)
  61. Else
  62.     $Form = GUICreate("X-Lorem Ipsum", 450, 230, 10, 420, Default, $WS_EX_TOOLWINDOW)
  63. EndIf
  64.  GUISetOnEvent($GUI_EVENT_CLOSE, "Quit")
  65.  GUISetIcon("1998_low_cost_clock.ico")
  66.  GUISetBkColor(0xc0c0c0)
  67. $Tab = GUICtrlCreateTab(-1, -1, 450, 200)
  68.  GUICtrlSetResizing($Tab, $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT)
  69. ;
  70. $Tab0 = GUICtrlCreateTabItem("Lullaby")
  71. $Combo_WinAmpStop = GUICtrlCreateCombo(" WinAmp ", 15, 40, 135, 20)
  72.  GUICtrlSetData($Combo_WinAmpStop, "  Just Stop |  Fadeout |  Stop-n-Play |  Stop When Done |  End Program ")
  73.  GUICtrlSetOnEvent($Combo_WinAmpStop, "CheckWinampStop")
  74.  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)
  75. $Combo_TimeFrame = GUICtrlCreateCombo(" Lullaby Time ", 170, 40, 115, 20)
  76.  GUICtrlSetData($Combo_TimeFrame, " Specific Time | Hour.Hour | Hour,Minute | Minute ")
  77.  GUICtrlSetOnEvent($Combo_TimeFrame, "CheckTimeCombo")
  78.  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)
  79. $Input_Time = GUICtrlCreateInput("", 340, 40, 65, 25, $ES_CENTER)
  80.  GUICtrlSetState($Input_Time, $GUI_DISABLE)
  81. $Combo_Shutdown = GUICtrlCreateCombo(" Shutdown Options ", 100, 95, 200, 20)
  82.  GUICtrlSetData($Combo_Shutdown, "  Lock  |  Standby  |  Hibernate  |  Reboot  |  Shutdown")
  83.  GUICtrlSetTip($Combo_Shutdown, "  Lock  " & @LF & "  Standby  " & @LF & "  Hibernate  " & @LF & "  Reboot  " & @LF & "  Shutdown ", " Shutdown Options ", 1)
  84. $Input_Title = GUICtrlCreateInput("Close Title", 100, 150, 250, 25, $ES_CENTER)
  85.  GUICtrlSetState($Input_Title, $GUI_DISABLE)
  86. $Button_GetTitle = GUICtrlCreateButton("Title", 20, 150, 60, 25)
  87.  GUICtrlSetOnEvent($Button_GetTitle, "GetTitle")
  88. ;
  89. $Tab1 = GUICtrlCreateTabItem("Wakeup")
  90. $Combo_WinAmpStart = GUICtrlCreateCombo(" WinAmp ", 190, 35, 115, 20)
  91.  GUICtrlSetData($Combo_WinAmpStart, "  Start Playing |  Select |  Random ")
  92.  GUICtrlSetOnEvent($Combo_WinAmpStart, "CheckStartCombo")
  93.  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 ")
  94. $Input_AlarmTime = GUICtrlCreateInput($AlarmTimeData, 158, 125, 65, 25, $ES_CENTER)
  95.  GUICtrlSetState($Input_AlarmTime, $GUI_DISABLE)
  96.  GUICtrlSetOnEvent($Input_AlarmTime, "WriteAlarmTime")
  97.  GUICtrlCreateLabel("Wakeup", 100, 126)
  98. $Input_PlaylistorFile = GUICtrlCreateInput("Playlist or File", 80, 90, 250, 25, $ES_CENTER)
  99.  GUICtrlSetState($Input_PlaylistorFile, $GUI_DISABLE)
  100. $Input_SeekTime = GUICtrlCreateInput("Seek", 350, 90, 50, 25, $ES_CENTER)
  101.  GUICtrlSetState($Input_SeekTime, $GUI_DISABLE)
  102. $Input_Snooze = GUICtrlCreateInput(IniRead($IniFile, "Snooze Time", "SnoozeTime", 9), 285, 125, 25, 25, $ES_CENTER)
  103.  GUICtrlSetState($Input_Snooze, $GUI_DISABLE)
  104.  GUICtrlSetOnEvent($Input_Snooze, "WriteSnoozeTime")
  105.  GUICtrlCreateLabel("Snooze", 230, 126)
  106.  GUICtrlCreateLabel("Minute(s)", 315, 126)
  107. $Slider_Fadein_Time = GUICtrlCreateSlider(10, 55, 15, 85, $TBS_VERT)
  108.  GUICtrlCreateLabel("Fade In Time", 10, 35)
  109.  GUICtrlSetOnEvent($Slider_Fadein_Time, "Update_FadeInTime")
  110.  GUICtrlSetLimit($Slider_Fadein_Time, 20, 0)
  111.  GUICtrlSetData($Slider_Fadein_Time, IniRead($IniFile, "Levels", "FadeInTime", 5))
  112. $Slider_Fadein_Time_Value = GUICtrlCreateLabel(GUICtrlRead($Slider_Fadein_Time), 135, 35)
  113. $Slider_MaxVol = GUICtrlCreateSlider(40, 75, 15, 85, $TBS_VERT)
  114.  GUICtrlCreateLabel("Max Volume", 40, 55)
  115.  GUICtrlSetOnEvent($Slider_MaxVol, "Update_MaxVolume")
  116.  GUICtrlSetLimit($Slider_MaxVol, 100, 0)
  117.  GUICtrlSetData($Slider_MaxVol, IniRead($IniFile, "Levels", "MaxVolume", 85))
  118. $Slider_MaxVol_Value = GUICtrlCreateLabel(GUICtrlRead($Slider_MaxVol), 135, 55)
  119. ;
  120. $Tab2 = GUICtrlCreateTabItem("Info")
  121. $Tab2_Label3 = GUICtrlCreateLabel("SPACE - Snooze, Restart" & @LF & @LF & "F2/F3/F4 - Volume Mute/Down/Up" & @LF & "F10           - Show/Hide this Window", 10, 125)
  122. $Tab2_Label5 = GUICtrlCreateLabel("Text", 10, 35, 500)
  123. $Tab2_Label6 = GUICtrlCreateLabel("Text", 10, 60, 500)
  124. $Tab2_Label7 = GUICtrlCreateLabel(" >-  Enabled", 240, 165)
  125. $Tab2_Label8 = GUICtrlCreateLabel("  -  Not Enabled", 240, 125, 200)
  126. $Progressbar = GUICtrlCreateProgress(50, 85, 335, 22, -1, $PBS_SMOOTH)
  127.  GUICtrlSetColor($Progressbar, 0x00f000)
  128. ;
  129. GUICtrlCreateTabItem("")
  130. ;
  131.  
  132. $Checkbox_Fade = GUICtrlCreateCheckbox("Fade", 45, 203, 60, 20)
  133. $Button_Begin = GUICtrlCreateButton("Begin", 110, 203, 75, 25)
  134.  GUICtrlSetOnEvent($Button_Begin, "Lullaby")
  135. $Button_Restart = GUICtrlCreateButton("Restart", 195, 203, 75, 25)
  136.  GUICtrlSetOnEvent($Button_Restart, "Restart")
  137. $Button_Quit = GUICtrlCreateButton("Quit", 280, 203, 75, 25)
  138.  GUICtrlSetOnEvent($Button_Quit, "Quit")
  139.  
  140. GUISetState(@SW_SHOW)
  141. #EndRegion ### END Koda GUI section ###
  142.  
  143. #Region ### START Tray section ###
  144. $TrayToggleHide = TrayCreateItem("Show/Hide")
  145.  TrayItemSetOnEvent(-1, "ToggleHide")
  146. $TrayToggleHotKey = TrayCreateItem("Disable Hotkeys")
  147.  TrayItemSetOnEvent(-1, "ToggleHotKey")
  148. $TrayRestart = TrayCreateItem("Restart")
  149.  TrayItemSetOnEvent(-1, "Restart")
  150. $TrayExit    = TrayCreateItem("Exit")
  151.  TrayItemSetOnEvent(-1, "Quit")
  152. ;
  153. TraySetState()
  154. TraySetClick(9)
  155. TraySetIcon(@ScriptDir & "\1998_low_cost_clock.ico")
  156. TraySetToolTip("X-Lorem Ipsum - Click here for the menu..")
  157. TraySetOnEvent($TRAY_EVENT_MOUSEOVER,"MouseOverTray")
  158. #EndRegion ### END Tray section ###
  159.  
  160. GUIRegisterMsg($WM_COMMAND, "_WM_COMMAND")
  161.  
  162. While 1
  163.     Sleep(100)
  164. WEnd
  165.  
  166. Func Lullaby()
  167.     ControlClick("X-Lorem Ipsum", "", "SysTabControl321", "left", 1, 135, 10)
  168.     If StringStripWS(GUICtrlRead($Combo_WinAmpStop), 3) = "Stop-n-Play" And StringStripWS(GUICtrlRead($Combo_WinAmpStart), 3) = "WinAmp" Then
  169.         GUICtrlSetData($Tab2_Label5, "You must select a wakeup thing too you know..")
  170.         Return
  171.     EndIf
  172.     If BitAnd(GUICtrlRead($Checkbox_Fade), $GUI_CHECKED) Then
  173.         For $iTransValue = 250 To 5 Step -15
  174.             WinSetTrans("X-Lorem Ipsum", "", $iTransValue)
  175.             Sleep(10)
  176.         Next
  177.         WinSetState("X-Lorem Ipsum", "", @SW_HIDE)
  178.         WinSetTrans("X-Lorem Ipsum", "", 255)
  179.     EndIf
  180.     Local $TimeFraction, $ConvertedHour, $ConvertedMinutes, $Timesplit
  181.     If StringStripWS(GUICtrlRead($Combo_TimeFrame), 3) <> "Lullaby Time" Then
  182.         Switch StringStripWS(GUICtrlRead($Combo_TimeFrame), 3)
  183.             Case "Hour.Hour"
  184.                 If StringInStr(GUICtrlRead($Input_Time), ".") Then
  185.                     $TimeFraction = StringSplit(GUICtrlRead($Input_Time), ".")
  186.                     $CountdownToDate = _DateAdd('n', (60 * $TimeFraction[1]) + ((60 * $TimeFraction[2]) / 10), _NowCalc())
  187.                     GUICtrlSetData($Tab2_Label5, "$Input_Time - " &  GUICtrlRead($Input_Time) & " Hour.Hour - " & StringTrimLeft($CountdownToDate, 11))
  188.                     ;MsgBox(0, "", "$Input_Time - " &  GUICtrlRead($Input_Time) & " Hour.Hour" & @LF & "$TimeFraction[1] - " & $TimeFraction[1] & @LF & "$TimeFraction[2] - " & $TimeFraction[2] & @LF & $CountdownToDate & @LF)
  189.                 Else
  190.                     $CountdownToDate = _DateAdd('h', GUICtrlRead($Input_Time), _NowCalc())
  191.                     GUICtrlSetData($Tab2_Label5, "$Input_Time - " &  GUICtrlRead($Input_Time) & " Hour.Hour - " & StringTrimLeft($CountdownToDate, 11))
  192.                     ;MsgBox(0, "", "$Input_Time - " &  GUICtrlRead($Input_Time) & @LF & $CountdownToDate & @LF)
  193.                 EndIf
  194.             Case "Hour,Minute"
  195.                 If StringInStr(GUICtrlRead($Input_Time), ",") Then
  196.                     $TimeFraction = StringSplit(GUICtrlRead($Input_Time), ",")
  197.                     $CountdownToDate = _DateAdd('n', (60 * $TimeFraction[1]) + $TimeFraction[2], _NowCalc())
  198.                     GUICtrlSetData($Tab2_Label5, "$Input_Time - " &  GUICtrlRead($Input_Time) & " Hour,Minute - " & StringTrimLeft($CountdownToDate, 11))
  199.                 Else
  200.                     $CountdownToDate = _DateAdd('h', GUICtrlRead($Input_Time), _NowCalc())
  201.                     GUICtrlSetData($Tab2_Label5, "$Input_Time - " &  GUICtrlRead($Input_Time) & " Hour,Minute - " & StringTrimLeft($CountdownToDate, 11))
  202.                 EndIf
  203.             Case "Minute"
  204.                 If StringInStr(GUICtrlRead($Input_Time), ".") Then
  205.                     $TimeFraction = StringSplit(GUICtrlRead($Input_Time), ".")
  206.                     $CountdownToDate = _DateAdd('s', (60 * $TimeFraction[1]) + ((60 * $TimeFraction[2]) / 10), _NowCalc())
  207.                     GUICtrlSetData($Tab2_Label5, "$Input_Time - " &  GUICtrlRead($Input_Time) & " Minute - " & StringTrimLeft($CountdownToDate, 11))
  208.                 Else
  209.                     $CountdownToDate = _DateAdd('n', GUICtrlRead($Input_Time), _NowCalc())
  210.                     GUICtrlSetData($Tab2_Label5, _NowCalc() & " - " & GUICtrlRead($Input_Time) & " Minute - " & StringTrimLeft($CountdownToDate, 11))
  211.                 EndIf
  212.             Case "Specific Time"
  213.                 $Timesplit = StringSplit(Number(StringFormat("%04d",StringRegExpReplace(GUICtrlRead($Input_Time), "\D", ""))), "")
  214.                 If StringInStr(GUICtrlRead($Input_Time), "p") Then
  215.                     Switch $Timesplit[0]
  216.                         Case 3
  217.                             $ConvertedHour = $Timesplit[1] + 12
  218.                             $ConvertedMinutes = $Timesplit[2] & $Timesplit[3]
  219.                             If $ConvertedHour = 24 Then $ConvertedHour = 00
  220.                             GUICtrlSetData($Tab2_Label5, "Lullaby Switch 3a, Waiting till " & $ConvertedHour & ":" & $ConvertedMinutes)
  221.                         Case 4
  222.                             If ($Timesplit[1] & $Timesplit[2]) = 12 Then
  223.                                 $ConvertedHour = $Timesplit[1] & $Timesplit[2]
  224.                             Else
  225.                                 $ConvertedHour = ($Timesplit[1] & $Timesplit[2]) + 12
  226.                             EndIf
  227.                             $ConvertedMinutes = $Timesplit[3] & $Timesplit[4]
  228.                             If $ConvertedHour = 24 Then $ConvertedHour = 00
  229.                             GUICtrlSetData($Tab2_Label5, "Lullaby Switch 4a, Waiting till " & $ConvertedHour & ":" & $ConvertedMinutes)
  230.                     EndSwitch
  231.                 Else
  232.                     Switch $Timesplit[0]
  233.                         Case 3
  234.                             $ConvertedHour = $Timesplit[1]
  235.                             $ConvertedMinutes = $Timesplit[2] & $Timesplit[3]
  236.                             GUICtrlSetData($Tab2_Label5, "Lullaby Switch 3b, Waiting till " & $ConvertedHour & ":" & $ConvertedMinutes)
  237.                         Case 4
  238.                             If ($Timesplit[1] & $Timesplit[2]) = 12 Then
  239.                                 $ConvertedHour = 0
  240.                             Else
  241.                                 $ConvertedHour = $Timesplit[1] & $Timesplit[2]
  242.                             EndIf
  243.                             $ConvertedMinutes = $Timesplit[3] & $Timesplit[4]
  244.                             GUICtrlSetData($Tab2_Label5, "Lullaby Switch 4b, Waiting till " & $ConvertedHour & ":" & $ConvertedMinutes)
  245.                     EndSwitch
  246.                 EndIf
  247.                 Local $DateDiffCalc = _DateDiff( 's', StringTrimRight(_NowCalc(), 8) & $ConvertedHour & ":" & $ConvertedMinutes & ":" & "00", _NowCalc())
  248.                 Local $TotalDateDiffCalc = $DateDiffCalc
  249.                 GUICtrlSetData($Progressbar, ($DateDiffCalc / $TotalDateDiffCalc) * 100)
  250.                 Do
  251.                     If $Interrupt = 1 Then Restart()
  252.                     If $Interrupt = 2 Then Quit()
  253.                     ;If $Interrupt = 3 Then Quit()
  254.                     $DateDiffCalc = _DateDiff( 's', StringTrimRight(_NowCalc(), 8) & $ConvertedHour & ":" & $ConvertedMinutes & ":" & "00", _NowCalc())
  255.                     If $DateDiffCalc <> $TotalDateDiffCalc Then GUICtrlSetData($Progressbar, ($DateDiffCalc / $TotalDateDiffCalc) * 100)
  256.                     Sleep(10)
  257.                 Until Number($ConvertedHour & $ConvertedMinutes) = @Hour & @Min
  258.                 GUICtrlSetData($Progressbar, 0)
  259.         EndSwitch
  260.         ;GUICtrlSetData($Tab2_Label5, GUICtrlRead($Input_Time) & " " & StringStripWS(GUICtrlRead($Combo_TimeFrame), 3) & " (" & StringTrimLeft($CountdownToDate, 11) & ") - " & GUICtrlRead($Combo_WinAmpStop))
  261.         GUICtrlSetData($Tab2_Label6, GUICtrlRead($Input_AlarmTime) & " " & GUICtrlRead($Combo_WinAmpStart) & " " & GUICtrlRead($Input_PlaylistorFile))
  262.         If StringStripWS(GUICtrlRead($Combo_TimeFrame), 3) <> "Specific Time" Then
  263.             Local $DateDiffCalc = _DateDiff( 's', _NowCalc(), $CountdownToDate)
  264.             Local $TotalDateDiffCalc = $DateDiffCalc
  265.             GUICtrlSetData($Progressbar, ($DateDiffCalc / $TotalDateDiffCalc) * 100)
  266.             Do
  267.                 If $Interrupt = 1 Then Restart()
  268.                 If $Interrupt = 2 Then Quit()
  269.                 $DateDiffCalc = _DateDiff( 's', _NowCalc(), $CountdownToDate)
  270.                 If $DateDiffCalc <> $TotalDateDiffCalc Then GUICtrlSetData($Progressbar, ($DateDiffCalc / $TotalDateDiffCalc) * 100)
  271.                 Sleep(10)
  272.             ;Until StringTrimRight(StringTrimLeft($CountdownToDate, 11), 3) & ":00" = StringTrimRight(StringTrimLeft(_NowCalc(), 11), 3) & ":00"
  273.             Until StringTrimLeft($CountdownToDate, 11) = StringTrimLeft(_NowCalc(), 11)
  274.             GUICtrlSetData($Progressbar, 0)
  275.         EndIf
  276.     EndIf
  277.     RunAfterLullaby()
  278. EndFunc   ;==>Lullaby
  279.  
  280. Func RunAfterLullaby()
  281.     GUICtrlSetData($Tab2_Label5, "Lullaby Done..")
  282.     If StringStripWS(GUICtrlRead($Combo_WinAmpStop), 3) <> "WinAmp" Then
  283.         Switch StringStripWS(GUICtrlRead($Combo_WinAmpStop), 3)
  284.             Case "Just Stop"
  285.                 _Winamp_Stop()
  286.             Case "Fadeout"
  287.                 ;ControlSend("Winamp", "", "", "+!v")
  288.                 Send("+!v")
  289.             Case "Stop-n-Play"
  290.                 WakeupNow()
  291.             Case "Stop When Done"
  292.                 ControlSend("Winamp", "", "", "^v")
  293.             Case "End Program"
  294.                 _Winamp_Close()
  295.         EndSwitch
  296.     EndIf
  297.     If GUICtrlRead($Input_Title) <> "Close Title" Or GUICtrlRead($Input_Title) <> "" Then WinClose(GUICtrlRead($Input_Title)) ;WinKill(GUICtrlRead($Input_Title))
  298.     If StringStripWS(GUICtrlRead($Combo_Shutdown), 3) <> "Winamp" Then
  299.         Switch StringStripWS(GUICtrlRead($Combo_Shutdown), 3)
  300.             Case "Lock"
  301.                 Run("rundll32.exe user32.dll, LockWorkStation")
  302.             Case "Standby"
  303.                 Shutdown(32)
  304.             Case "Hibernate"
  305.                 Shutdown(64)
  306.             Case "Reboot"
  307.                 Shutdown(18)
  308.             Case "Shutdown"
  309.                 Shutdown(13)
  310.         EndSwitch
  311.     EndIf
  312.     If StringStripWS(GUICtrlRead($Combo_WinAmpStart), 3) <> "WinAmp" Then WaitforWakeup()
  313. EndFunc   ;==>RunAfterLullaby
  314.  
  315. Func WaitforWakeup()
  316.     Local $ConvertedHour, $ConvertedMinutes, $Timesplit
  317.     ;ControlClick("X-Lorem Ipsum", "", "SysTabControl321", "left", 1, 75, 10)
  318.     $Timesplit = StringSplit(Number(StringFormat("%04d",StringRegExpReplace(GUICtrlRead($Input_AlarmTime), "\D", ""))), "")
  319.     If StringInStr(GUICtrlRead($Input_AlarmTime), "p") Then
  320.         Switch $Timesplit[0]
  321.             Case 3
  322.                 $ConvertedHour = $Timesplit[1] + 12
  323.                 $ConvertedMinutes = $Timesplit[2] & $Timesplit[3]
  324.                 If $ConvertedHour = 24 Then $ConvertedHour = 0
  325.                 GUICtrlSetData($Tab2_Label5, "Wakeup Case 3a, waiting till " & $ConvertedHour & $ConvertedMinutes)
  326.             Case 4
  327.                 If ($Timesplit[1] & $Timesplit[2]) = 12 Then
  328.                     $ConvertedHour = $Timesplit[1] & $Timesplit[2]
  329.                 Else
  330.                     $ConvertedHour = ($Timesplit[1] & $Timesplit[2]) + 12
  331.                 EndIf
  332.                 $ConvertedMinutes = $Timesplit[3] & $Timesplit[4]
  333.                 If $ConvertedHour = 24 Then $ConvertedHour = 0
  334.                 GUICtrlSetData($Tab2_Label5, "Wakeup Case 4a, waiting till " & $ConvertedHour & $ConvertedMinutes)
  335.         EndSwitch
  336.     Else
  337.         Switch $Timesplit[0]
  338.             Case 3
  339.                 $ConvertedHour = $Timesplit[1]
  340.                 $ConvertedMinutes = $Timesplit[2] & $Timesplit[3]
  341.                 GUICtrlSetData($Tab2_Label5, "Wakeup Case 3b, waiting till " & $ConvertedHour & $ConvertedMinutes & " (" & @HOUR & ":" & @MIN & ")")
  342.             Case 4
  343.                 If ($Timesplit[1] & $Timesplit[2]) = 12 Then
  344.                     $ConvertedHour = 0
  345.                 Else
  346.                     $ConvertedHour = $Timesplit[1] & $Timesplit[2]
  347.                 EndIf
  348.                 $ConvertedMinutes = $Timesplit[3] & $Timesplit[4]
  349.                 GUICtrlSetData($Tab2_Label5, "Wakeup Case 4b, waiting till " & $ConvertedHour & $ConvertedMinutes & " (" & @HOUR & ":" & @MIN & ")")
  350.         EndSwitch
  351.     EndIf
  352.     Local $DateDiffCalc = _DateDiff( 's', StringTrimRight(_NowCalc(), 8) & $ConvertedHour & ":" & $ConvertedMinutes & ":" & "00", _NowCalc())
  353.     Local $TotalDateDiffCalc = $DateDiffCalc
  354.     GUICtrlSetData($Progressbar, ($DateDiffCalc / $TotalDateDiffCalc) * 100)
  355.     Do
  356.         If $Interrupt = 1 Then Restart()
  357.         If $Interrupt = 2 Then Quit()
  358.         $DateDiffCalc = _DateDiff( 's', StringTrimRight(_NowCalc(), 8) & $ConvertedHour & ":" & $ConvertedMinutes & ":" & "00", _NowCalc())
  359.         If $DateDiffCalc <> $TotalDateDiffCalc Then GUICtrlSetData($Progressbar, ($DateDiffCalc / $TotalDateDiffCalc) * 100)
  360.         Sleep(10)
  361.     Until Number($ConvertedHour & $ConvertedMinutes) = @Hour & @Min
  362.     GUICtrlSetData($Progressbar, 0)
  363.     WakeupNow()
  364. EndFunc   ;==>WaitforWakeup
  365.  
  366. Func WakeupNow()
  367.     If _Winamp_GetCurrentTrackPlayStatus() Then _Winamp_Stop()
  368.     HotKeySet("{SPACE}", "Snooze")
  369.     GUICtrlSetData($Tab2_Label8, " - {SPACE} to Snooze") ;Spacebar (snooze)
  370.     GUICtrlSetData($Tab2_Label5, "Time to start..")
  371.     _Winamp_SetVolume(0)
  372.     If StringStripWS(GUICtrlRead($Combo_WinAmpStart), 3) <> "WinAmp" Then
  373.         Switch StringStripWS(GUICtrlRead($Combo_WinAmpStart), 3)
  374.             Case "Start Playing"
  375.                 _Winamp_Play()
  376.             Case "Select"
  377.                 _Winamp_ClearPlayList()
  378.                 _Winamp_AddFile($SelectedSong)
  379.                 _Winamp_Play()
  380.             Case "Random"
  381.                 _Winamp_ClearPlayList()
  382.                 _Winamp_AddFile(StringReplace($MusicPath[0], ";", ":"))
  383.                 _Winamp_Play()
  384.         EndSwitch
  385.     EndIf
  386.     ;ControlClick("X-Lorem Ipsum", "", "SysTabControl321", "left", 1, 115, 10)
  387.     GUICtrlSetData($Tab2_Label5, "Fade In..")
  388.     Fadein(GUICtrlRead($Slider_Fadein_Time), GUICtrlRead($Slider_MaxVol))
  389.     GUICtrlSetData($Tab2_Label5, "Done for now..")
  390.     ;GUICtrlSetData($Tab2_Label8, " - Disabled") ; Spacebar (snooze)
  391.     ;HotKeySet("{SPACE}")
  392. EndFunc   ;==>WakeupNow
  393.  
  394. Func Fadein($FadeTime, $MaxVolume)
  395.     ; If Main is muted, un-mute it
  396.      PixelSearch(1260, 780, 1275, 790, 0xFF0000)
  397.      If Not @error Then Send("{VOLUME_MUTE}")
  398.     ;
  399.     Switch @OSVersion
  400.         Case "WIN_VISTA", "WIN_7"
  401.             Run("sndvol.exe", "", @SW_HIDE)
  402.         Case "WIN_XP"
  403.             Run("sndvol32.exe", "", @SW_HIDE)
  404.     EndSwitch
  405.     WinWaitActive("Volume Mixer")
  406.     ControlSend("Volume Mixer", "", "msctls_trackbar321", "{HOME}") ; Max system volume
  407.     WinClose("Volume Mixer")
  408.     If _Winamp_GetVolume() = 0 Then
  409.         Do
  410.             If $Interrupt = 1 Then Restart()
  411.             If $Interrupt = 2 Then Quit()
  412.             _Winamp_SetVolume(-1, 1)
  413.             Sleep($FadeTime * 35)
  414.             GUICtrlSetData($Progressbar, _Winamp_GetVolume())
  415.         Until _Winamp_GetVolume() / 255 * 100 >= $MaxVolume
  416.     Else
  417.         MsgBox(0, "", ";==>Fadein: Winamp has volume, Quitting Fadein.", 2)
  418.     EndIf
  419. EndFunc   ;==>Fadein
  420.  
  421. Func Update_FadeInTime()
  422.     If GUICtrlRead($Slider_Fadein_Time) <> $Old_Slider1_Value Then
  423.         GUICtrlSetData($Slider_Fadein_Time_Value, GUICtrlRead($Slider_Fadein_Time))
  424.         $Old_Slider1_Value = GUICtrlRead($Slider_Fadein_Time)
  425.         IniWrite($IniFile, "Levels", "FadeInTime", GUICtrlRead($Slider_Fadein_Time))
  426.     EndIf
  427. EndFunc   ;==>Update_FadeInTime
  428.  
  429. Func Update_MaxVolume()
  430.     If GUICtrlRead($Slider_MaxVol) <> $Old_Slider2_Value Then
  431.         GUICtrlSetData($Slider_MaxVol_Value, GUICtrlRead($Slider_MaxVol))
  432.         $Old_Slider2_Value = GUICtrlRead($Slider_MaxVol)
  433.         IniWrite($IniFile, "Levels", "MaxVolume", GUICtrlRead($Slider_MaxVol))
  434.     EndIf
  435. EndFunc   ;==>Update_MaxVolume
  436.  
  437. Func VolUpDownMute()
  438.     Switch @HotKeyPressed
  439.         Case "{F2}"
  440.             Send("{VOLUME_MUTE}")
  441.         Case "{F3}"
  442.             Send("{VOLUME_DOWN}")
  443.         Case "{F4}"
  444.             Send("{VOLUME_UP}")
  445.     EndSwitch
  446. EndFunc
  447.  
  448. Func Snooze()
  449.     HotKeySet("{SPACE}", "Quit")
  450.     ;HotKeySet("{SPACE}", "Restart")
  451.     GUICtrlSetData($Tab2_Label8, " - {SPACE} to quit")
  452.     If _Winamp_GetCurrentTrackPlayStatus() Then
  453.         Local $SnoozeTime = Number(GUICtrlRead($Input_Snooze))
  454.         Local $SnoozeTill = _DateAdd('n', $SnoozeTime, _NowCalc())
  455.         GUICtrlSetData($Tab2_Label5, "Snoozing for " & $SnoozeTime & " minutes, since " & @HOUR & ":" & @MIN & ", to " & StringTrimLeft(StringTrimRight($SnoozeTill, 3), 11))
  456.         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)
  457.         _Winamp_Stop()
  458.         Do
  459.             If $Interrupt = 1 Then Restart()
  460.             If $Interrupt = 2 Then Quit()
  461.             Sleep(10)
  462.         Until @HOUR & ":" & @MIN & ":" & @SEC = StringTrimLeft($SnoozeTill, 11)
  463.         GUICtrlSetData($Tab2_Label5, "Fade In..")
  464.         SplashOff()
  465.         _Winamp_SetVolume(0)
  466.         _Winamp_Play()
  467.         HotKeySet("{SPACE}", "Snooze")
  468.         GUICtrlSetData($Tab2_Label8, " - {SPACE} to Snooze") ;Spacebar (snooze)
  469.         Fadein(GUICtrlRead($Slider_Fadein_Time), GUICtrlRead($Slider_MaxVol))
  470.     EndIf
  471. EndFunc   ;==>Snooze
  472.  
  473. Func PickMusic()
  474.     $RndORSel = 0
  475.     GUICtrlSetState($Input_PlaylistorFile, $GUI_ENABLE)
  476.     Local $Drive, $Dir, $FName, $Ext
  477.     $SelectedSong = FileOpenDialog("Select Song", "C:\Users\Public\Music\Music", "Media files (*.mp3;*.m4a;*.m3u) | All (*.*)")
  478.     If @error Then
  479.         $SelectedSong = IniRead($IniFile, "Wakeup File", "SoundFile", "NotFound")
  480.     Else
  481.         IniWriteSection($IniFile, "Wakeup File", "SoundFile=" & $SelectedSong)
  482.     EndIf
  483.     $MusicPath = StringSplit($SelectedSong, "\")
  484.     GUICtrlSetData($Input_PlaylistorFile, StringTrimRight($MusicPath[$MusicPath[0]], 4))
  485. EndFunc   ;==>PickMusic
  486.  
  487. Func RndMusic()
  488.     $RndORSel = 1
  489.     GUICtrlSetState($Input_PlaylistorFile, $GUI_ENABLE)
  490.     Local $Folder, $Drive, $Dir, $FName, $Ext
  491.     $Folder = FileSelectFolder("Select A Music Folder", "C:\Users\Public\Music\Music", 6)
  492.     $FileList = _FileListToArray($Folder, "*", 1)
  493.     If @error = 1 Then
  494.         MsgBox(0, "", "No Files\Folders Found.")
  495.         Exit
  496.     EndIf
  497.     Do
  498.         $RandomFile = Random(1, $FileList[0], 1)
  499.         $MusicPath = _PathSplit($Folder & "\" & $FileList[$RandomFile], $Drive, $Dir, $FName, $Ext)
  500.     Until $MusicPath[4] = ".mp3" Or $MusicPath[4] = ".m4a" Or $MusicPath[4] = ".m3u"
  501.     GUICtrlSetData($Input_PlaylistorFile, $FileList[$RandomFile])
  502. EndFunc   ;==>RndMusic
  503.  
  504. Func ToggleHide()
  505.     If BitAND(WinGetState("X-Lorem Ipsum", ""), 2) Then
  506.         WinSetState("X-Lorem Ipsum", "", @SW_HIDE)
  507.     Else
  508.         WinSetState("X-Lorem Ipsum", "", @SW_SHOW)
  509.     EndIf
  510. EndFunc   ;==>ToggleHide
  511.  
  512. Func CheckStartCombo()
  513.     Switch StringStripWS(GUICtrlRead($Combo_WinAmpStart), 3)
  514.         Case "Winamp"
  515.             GUICtrlSetState($Input_AlarmTime, $GUI_DISABLE)
  516.             GUICtrlSetState($Input_Snooze, $GUI_DISABLE)
  517.             GUICtrlSetData($Input_PlaylistorFile, "Playlist or File")
  518.             GUICtrlSetState($Input_PlaylistorFile, $GUI_DISABLE)
  519.         Case "Start Playing"
  520.             If StringStripWS(GUICtrlRead($Combo_WinAmpStop), 3) <> "Stop-n-Play" Then GUICtrlSetState($Input_AlarmTime, $GUI_ENABLE)
  521.             GUICtrlSetState($Input_Snooze, $GUI_ENABLE)
  522.         Case "Select"
  523.             If StringStripWS(GUICtrlRead($Combo_WinAmpStop), 3) <> "Stop-n-Play" Then GUICtrlSetState($Input_AlarmTime, $GUI_ENABLE)
  524.             GUICtrlSetState($Input_Snooze, $GUI_ENABLE)
  525.             PickMusic()
  526.         Case "Random"
  527.             If StringStripWS(GUICtrlRead($Combo_WinAmpStop), 3) <> "Stop-n-Play" Then GUICtrlSetState($Input_AlarmTime, $GUI_ENABLE)
  528.             GUICtrlSetState($Input_Snooze, $GUI_ENABLE)
  529.             RndMusic()
  530.     EndSwitch
  531. EndFunc
  532.  
  533. Func GetTitle()
  534.     Local $dll = DllOpen("user32.dll")
  535.     GUICtrlSetState($Input_Title, $GUI_ENABLE)
  536.     While 1
  537.         ToolTip("Click on the App now")
  538.         Sleep(50)
  539.         If _IsPressed("01", $dll) Then ExitLoop
  540.     WEnd
  541.     DllClose($dll)
  542.     ToolTip("")
  543.     GUICtrlSetData($Input_Title, WinGetTitle("[active]"))
  544. EndFunc   ;==>GetTitle
  545.  
  546. Func CheckTimeCombo()
  547.     Switch StringStripWS(GUICtrlRead($Combo_TimeFrame), 3)
  548.         Case "Specific Time"
  549.             GUICtrlSetState($Input_Time, $GUI_ENABLE)
  550.             GUICtrlSetData($Input_Time, "4:20")
  551.         Case "Hour.Hour"
  552.             GUICtrlSetState($Input_Time, $GUI_ENABLE)
  553.             GUICtrlSetData($Input_Time, "2.5")
  554.         Case "Hour,Minute"
  555.             GUICtrlSetState($Input_Time, $GUI_ENABLE)
  556.             GUICtrlSetData($Input_Time, "2,30")
  557.         Case "Minute"
  558.             GUICtrlSetState($Input_Time, $GUI_ENABLE)
  559.             GUICtrlSetData($Input_Time, "150")
  560.         Case "Lullaby Time"
  561.             GUICtrlSetState($Input_Time, $GUI_DISABLE)
  562.             GUICtrlSetData($Input_Time, "")
  563.     EndSwitch
  564. EndFunc   ;==>CheckTimeCombo
  565.  
  566. Func SlidersSave()
  567.     IniWrite($IniFile, "Levels", "FadeInTime", GUICtrlRead($Slider_Fadein_Time))
  568.     IniWrite($IniFile, "Levels", "MaxVolume", GUICtrlRead($Slider_MaxVol))
  569. EndFunc
  570.  
  571. Func WriteSnoozeTime()
  572.     IniWrite($IniFile, "Snooze Time", "SnoozeTime", GUICtrlRead($Input_Snooze))
  573.     ;MsgBox(0, "Snooze Time", "$Input_Snooze = " & $Input_Snooze & "  GUI_CtrlId = " & @GUI_CtrlId & @LF)
  574. EndFunc
  575.  
  576. Func WriteAlarmTime()
  577.     IniWrite($IniFile, "Alarm Time", "AlarmTime", GUICtrlRead($Input_AlarmTime))
  578.     ;MsgBox(0, "Alarm Time", "GUI_CtrlId = " & @GUI_CtrlId & @LF)
  579. EndFunc
  580.  
  581. Func MouseOverTray()
  582.     If BitAND(WinGetState("X-Lorem Ipsum", ""), 2) Then
  583.         TrayItemSetText($TrayToggleHide, "Hide Window")
  584.     Else
  585.         TrayItemSetText($TrayToggleHide, "Show Window")
  586.     EndIf
  587. EndFunc
  588.  
  589. Func ToggleHotKey()
  590.     Switch $HotKeyAble
  591.         Case 0
  592.             TrayItemSetText($TrayToggleHotKey, "Disable Hotkeys")
  593.             GUICtrlSetData($Tab2_Label7, " >-  Enabled")
  594.             GUICtrlSetData($Tab2_Label8, $Label8) ;Spacebar (snooze)
  595.             HotKeySet("{F2}", "VolUpDownMute")
  596.             HotKeySet("{F3}", "VolUpDownMute")
  597.             HotKeySet("{F4}", "VolUpDownMute")
  598.             HotKeySet("{F10}", "ToggleHide")
  599.             HotKeySet("{SPACE}", "Snooze")
  600.             $HotKeyAble = 1
  601.         Case 1
  602.             Switch GUICtrlRead($Tab2_Label8)
  603.                 Case "  -  Not Enabled"
  604.                     $Label8 = "  -  Not Enabled"
  605.                 Case " - {SPACE} to Snooze"
  606.                     $Label8 = " - {SPACE} to Snooze"
  607.             EndSwitch
  608.             TrayItemSetText($TrayToggleHotKey, "Enable Hotkeys")
  609.             GUICtrlSetData($Tab2_Label7, " |-  Disabled")
  610.             GUICtrlSetData($Tab2_Label8, " - Disabled") ;Spacebar (snooze)
  611.             HotKeySet("{F2}")
  612.             HotKeySet("{F3}")
  613.             HotKeySet("{F4}")
  614.             HotKeySet("{F10}")
  615.             HotKeySet("{SPACE}")
  616.             $HotKeyAble = 0
  617.     EndSwitch
  618. EndFunc   ;==>ToggleHotKey
  619.  
  620. Func CheckWinampStop()
  621.     If StringStripWS(GUICtrlRead($Combo_WinAmpStop), 3) <> "Stop-n-Play" Then GUICtrlSetState($Input_AlarmTime, $GUI_DISABLE)
  622. EndFunc
  623.  
  624. Func _WM_COMMAND($hWnd, $Msg, $wParam, $lParam)
  625.     If BitAND($wParam, 0x0000FFFF) = $Button_Restart Then $Interrupt = 1
  626.     If BitAND($wParam, 0x0000FFFF) = $Button_Quit Or BitAND($wParam, 0x0000FFFF) = $GUI_EVENT_CLOSE Then $Interrupt = 2
  627.     ;If BitAND($wParam, 0x0000FFFF) = $GUI_EVENT_CLOSE Then $Interrupt = 3
  628. EndFunc   ;==>_WM_COMMAND
  629.  
  630. Func Restart()
  631.     If @HotKeyPressed = "{SPACE}" Then _Winamp_Play()
  632.     $Position = WinGetPos("X-Lorem Ipsum")
  633.     If $Position[0] <> 10 And $Position[1] <> 420 Then IniWrite($IniFile, "Position", "Position", $Position[0] & "," & $Position[1])
  634. ; Restart your program - http://www.autoitscript.com/forum/index.php?s=&showtopic=19370&view=findpost&p=199608
  635. ; Author UP_NORTH
  636.     If @Compiled = 1 Then
  637.         Run(FileGetShortName(@ScriptFullPath))
  638.     Else
  639.         Run(FileGetShortName(@AutoItExe) & " " & FileGetShortName(@ScriptFullPath))
  640.     EndIf
  641.     Exit
  642. EndFunc     ;==>Restart
  643.  
  644. Func Quit()
  645.     If @HotKeyPressed = "{SPACE}" Then _Winamp_Play()
  646.     $Position = WinGetPos("X-Lorem Ipsum")
  647.     If $Position[0] <> 10 And $Position[1] <> 420 Then IniWrite($IniFile, "Position", "Position", $Position[0] & "," & $Position[1])
  648.     Exit
  649. EndFunc   ;==>Quit
  650.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement