Advertisement
CivReborn

Desktop Alarm Clock - StopWatch

Nov 26th, 2017
2,105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ;Writtn By: Hellbent aka CivReborn
  2. ;Written for: CivReborn Youtube Channel- https://www.youtube.com/user/CivReborn
  3. ;Date Written: Nov 26th, 2017
  4. #SingleInstance,Force
  5. global StopWatch_State:=0,Pauseit:=0,Sound_Setting:=1,Tx:=600,Ty:=100,myHour:=A_Hour,Alarm_Off:=0,colour_List:= ["Lime","Yellow","Red"],lnum:=1
  6. FormatTime, Time1,h , h tt
  7. StringRight,time2,time1,2
  8. myHour>=13?myHour-=12:myHour<1?myHour+=12
  9. Clock_Gui()
  10. SetTimer,Main_Clock,1000
  11. return
  12. Turn_Off_Alarm:
  13.     Alarm_Off:=1
  14.     return
  15. Watch_Alarm:
  16.     New_Second:=(A_TickCount-Alarm_Tick)//1000
  17.     if(New_Second>Last_Second){
  18.         Last_Second:=New_Second
  19.         GuiControl,1:,Alarm_Progress,% Last_Second
  20.         update_edit3_1:=(Alarm_Seconds-Last_Second)//60,update_edit3_2:=(Alarm_Seconds-Last_Second)-(update_edit3_1*60),update_Edit3_1<10?update_edit3_1:="0" update_edit3_1,update_Edit3_2<10?update_edit3_2:="0" update_edit3_2
  21.         GuiControl,3:,edit3,% update_edit3_1 " : " update_edit3_2
  22.     }
  23.     if(Last_Second>=Alarm_Seconds){
  24.         if(Sound_Setting=1){
  25.             SetTimer,Watch_Alarm,Off
  26.             Gui,1:Show
  27.             Gui,4:Destroy
  28.             while(!GetKeyState("RButton"))
  29.                 SoundBeep,850,500
  30.             GuiControl,1:,Alarm_Progress,0
  31.         }else if(Sound_Setting=2){
  32.                 SetTimer,Watch_Alarm,Off
  33.                 Gui,1:Show
  34.                 Gui,4:Destroy
  35.                 Flashing()
  36.                 while(Alarm_Off=0){
  37.                     Gui,5:Color,% colour_List[lnum]
  38.                     lnum++
  39.                     (lnum=4)?(lnum:=1)
  40.                     sleep,500
  41.                 }
  42.             GuiControl,1:,Alarm_Progress,0
  43.             Gui,5:Destroy
  44.         }else if(Sound_Setting=3){
  45.             SetTimer,Watch_Alarm,Off
  46.             Gui,1:Show
  47.             Gui,4:Destroy
  48.             Flashing()
  49.             while(Alarm_Off=0&&!GetKeyState("RButton")){
  50.                 Gui,5:Color,% colour_List[lnum]
  51.                 lnum++
  52.                 (lnum=4)?(lnum:=1)
  53.                 SoundBeep,850,500
  54.             }
  55.             GuiControl,1:,Alarm_Progress,0
  56.             Gui,5:Destroy
  57.         }
  58.     }
  59.     return
  60. Set_Alarm_Time:
  61.     if(Time_Radio=1)
  62.         Alarm_Seconds:=3600
  63.     else if(Time_Radio=2)
  64.         Alarm_Seconds:=(Min_Slide*60)+Sec_Slide
  65.     GuiControl,1:+Range0-%Alarm_Seconds%,Alarm_Progress
  66.     GuiControl,1:,Alarm_Progress,0
  67.     Last_Second:=0,Alarm_Tick:=A_TickCount,Alarm_Off:=0
  68.     SetTimer,Watch_Alarm,333
  69.     Gui,3:Destroy
  70.     return
  71. Cancel:
  72.     Gui,3:Destroy
  73.     return
  74. Submit_All:
  75.     Gui,3:Submit,NoHide
  76.     GuiControl,3:,edit1,% Min_Slide
  77.     GuiControl,3:,edit2,% Sec_Slide
  78.     if(Time_Radio=1)
  79.         GuiControl,3:,edit3,60 : 00
  80.     else
  81.         GuiControl,3:,edit3,% Min_Slide " : " Sec_Slide
  82.     return
  83. Reset:
  84.     Gui,3:Destroy
  85.     SetTimer,Watch_Alarm,Off
  86.     GuiControl,1:,Alarm_Progress,0
  87.     return
  88. set_Alarm:
  89.     Gui,3:Destroy
  90.     Gui,3:+AlwaysOnTop -Caption +Owner1 +Border
  91.     Gui,3:Color,0x72B4B1
  92.     Gui_Control_Types := ["Radio","Radio","Groupbox","Text","Slider","Edit","Groupbox","Text","Slider","Edit","Groupbox","Edit","Groupbox","Button","Button","Button"]
  93.     Control_Text:= ["1 Hour","Set Amount",Fake_Value,"Mins:",Fake_Value,Fake_Value,Fake_Value,"Secs:",Fake_Value,Fake_Value,Fake_Value,"60 : 00",Fake_Value,"Set","Reset","Back"],Fake_Value:=""
  94.     for k, v in ["x10 y10 Checked vTime_Radio gSubmit_All","x100 y10 gSubmit_All","x10 y30 w200 h60 Section","xs+10 ys+20 w30,Mins:","x+10 w100 Range0-59 AltSubmit vMin_Slide gSubmit_All","x+10 w30 Center ReadOnly -E0x200 vedit1","x10 y100 w200 h60 Section","xs+10 ys+20 w30","x+10 w100 Range0-59 AltSubmit vSec_Slide gSubmit_All","x+10 w30 Center ReadOnly -E0x200 vedit2","x10 y160 w200 h40 Section","xs+10 ys+13 w180 h20 ReadOnly Center -E0x200 vedit3","x10 y200 w200 h40 Section","xs+10 ys+13 w50 h20 gSet_Alarm_Time","x+15 ys+13 w50 h20 gReset","x+15 ys+13 w50 h20 gCancel"]
  95.         Gui,3:Add,% Gui_Control_Types[A_Index],% v ,% Control_Text[A_Index]
  96.     gosub,Submit_All
  97.     Gui,3:Show,AutoSize ,Alarm Setup
  98.     return
  99. Show_StopWatch:
  100.     GuiControl,1:Hide,Main_Clock_Time
  101.     GuiControl,1:Show,Stop_Watch
  102.     Loop 6
  103.         GuiControl,1:Show,SW%A_Index%
  104.     Loop 3
  105.         GuiControl,2:Show,% "SW" A_Index+6
  106.     return
  107. Show_Clock:
  108.     GuiControl,1:Hide,Stop_Watch
  109.     Loop 6
  110.         GuiControl,1:Hide,SW%A_Index%
  111.     Loop 3
  112.         GuiControl,2:Hide,% "SW" A_Index+6
  113.     GuiControl,1:Show,Main_Clock_Time  
  114.     return 
  115. Start_StopWatch:
  116.     if(StopWatch_State=0){
  117.         StopWatch_State:=1,Pauseit:=0,Start_Tick:=A_TickCount
  118.         SetTimer,StopWatch_Timer,10
  119.     }
  120.     return
  121. Pause_StopWatch:
  122.     if(StopWatch_State=1)
  123.         Pauseit:=!Pauseit,Start_Tick:=A_TickCount-Start_Tick
  124.     return
  125. Reset_StopWatch:
  126.     StopWatch_State:=0
  127.     Pauseit:=0
  128.     SetTimer,StopWatch_Timer,Off
  129.     GuiControl,1:,Stop_Watch, 000 : 00 : 00 : 000
  130.     return
  131. StopWatch_Timer:
  132.     Stop_Hour:=((A_TickCount-Start_Tick)//3600000)
  133.     Stop_Min:=(((A_TickCount-Start_Tick)-(Stop_Hour*3600000))//60000)
  134.     Stop_Sec:=(((A_TickCount-Start_Tick)-(Stop_Hour*3600000)-(Stop_Min*60000))//1000)
  135.     Stop_MS:=(((A_TickCount-Start_Tick)-(Stop_Hour*3600000)-(Stop_Min*60000)-(Stop_Sec*1000)))
  136.     Stop_Hour<10?Stop_Hour:="00" Stop_Hour
  137.     Stop_Min<10?Stop_Min:="0" Stop_Min
  138.     Stop_Sec<10?Stop_Sec:="0" Stop_Sec
  139.     Stop_MS<100?Stop_MS:="0" Stop_MS
  140.     if(Pauseit=0)
  141.     GuiControl,1:,Stop_Watch,% Stop_Hour " : " Stop_Min " : " Stop_Sec " : " Stop_Ms
  142.     return
  143. GuiClose:
  144.     ExitApp
  145. Sounds:
  146.     Sound_Setting++
  147.     Sound_Setting>=4?Sound_Setting:=1
  148.     (Sound_Setting=1)?(HList:=["1:Show","1:Show","1:Show","1:Show","1:Hide","1:Hide","1:Hide"])
  149.     :(Sound_Setting=2)?(HList:=["1:Hide","1:Hide","1:Hide","1:Hide","1:Show","1:Show","1:Hide"])
  150.     :(Sound_Setting=3)?(HList:=["1:Hide","1:Hide","1:Hide","1:Hide","1:Show","1:Hide","1:Show"])
  151.     for,k,v in HList
  152.         GuiControl,% v,SG%A_Index% 
  153.     return
  154. Move_Window:
  155.     PostMessage,0xA1,2
  156.     While(GetKeyState("LButton"))
  157.         sleep 10
  158.     WinGetPos,wx,wy,,,Hellbents StopWatch/Alarm TL
  159.     Gui,1:Show,x%wx% y%wy%
  160.     return
  161. Minimize_Window:
  162.     Gui,1:Minimize
  163.     return
  164. Move_Tab:
  165.     PostMessage,0xA1,2
  166.     While(GetKeyState("LButton"))
  167.         sleep,10
  168.     WinGetPos,Tx,Ty,,,StopWatch Tab
  169.     return
  170. 4Guicontextmenu:
  171.     Gui,1:Show
  172.     Gui,4:Destroy
  173.     return
  174. 2Guicontextmenu:
  175.     Gui,1:Minimize
  176.     Gui,4:Destroy
  177.     Gui,3:Destroy
  178.     Gui,4:+AlwaysOnTop -Caption +Border +Owner1
  179.     Gui,4:Color,0x72B4B1
  180.     Gui,4:Font,cBlack s8 Bold Q5,Segoe UI  
  181.     Gui,4:Add,Text,x0 y3 w40 h20 Center gMove_Tab,HBSW
  182.     Gui,4:Show,x%Tx% y%Ty% w40 h20,StopWatch Tab
  183.     return
  184. Main_Clock:
  185.     myHour:=A_Hour
  186.     myHour>=13?myHour-=12:myHour<1?myHour+=12
  187.     FormatTime, Time1,h , h tt
  188.     StringRight,time2,time1,2
  189.     GuiControl,1:,Main_Clock_Time,% MyHour " : " A_Min " : " A_Sec  "   " Time2
  190.     return
  191. Flashing(){
  192.     Gui,5:Destroy
  193.     Gui,5:+AlwaysOnTop -Caption +Border +Owner1
  194.     Gui,5:Color,Red
  195.     Gui,5:Font,s12 Bold Q5,Segoe UI
  196.     Gui,5:Add,Button,x120 y270 w60 h25 gTurn_Off_Alarm,Ok
  197.     Gui,5:Show,w300 h300
  198. }
  199. Clock_Gui(){
  200.     global
  201.     Gui,1:+AlwaysOnTop -Caption
  202.     Gui,2:+AlwaysOnTop -Caption +Owner1 +LastFound
  203.     WinSet,Transparent,1
  204.     Gui,2:Color,Blue
  205.     Gui,1:Color,Black,0x72B4B1
  206.     Gui,1:Add,Edit,x-100 y0 w10 h10
  207.     Gui,1:Add,Progress,x0 y0 w300 h65 BackgroundBlack c0x72B4B1,100
  208.     Gui,1:Font,cBlack s12 underline Bold Q5 ,Nirmala UI
  209.     Gui,1:Add,Text,x25 y0  r1 Backgroundtrans ,Hellbents StopWatch
  210.     For k,v in ["x5 y15 w2 h5 Backgroundaa8800 vSG1","x+1 y11 w2 h9 Backgroundaaff00 vSG2","x+1 y7 w2 h13 Background00ff00 vSG3","x+1 y4 w2 h16 Background00ff00 vSG4"]
  211.         Gui,1:Add,Progress,% v
  212.     Gui,1:Font
  213.     Gui,1:Font,cLime s9 Bold Q5 ,Nirmala UI
  214.     Gui,1:Add,Progress,x5 y5 w15 h15 BackgroundBlack c555555 Hidden vSG5,100
  215.     Gui,1:Add,Text,x5 y5 w15 r1 Center BackgroundTrans Hidden vSG6,M
  216.     Gui,1:Font
  217.     Gui,1:Font,cLime s12 Bold Q5 ,Nirmala UI
  218.     Gui,1:Add,Text,x5 y0 w15 r1 Center BackgroundTrans Hidden vSG7,+
  219.     Gui,1:Font
  220.     Gui,1:Font,cYellow s9 Bold Q5 ,Nirmala UI
  221.     For k,v in ["x200 y5 w15 h15 BackgroundBlack c555555","x220 y5 w15 h15 BackgroundBlack c555555","x240 y5 w15 h15 BackgroundBlack c555555","x260 y5 w15 h15 BackgroundBlack c555555","x280 y5 w15 h15 BackgroundBlack c555555"]
  222.         Gui,1:Add,Progress,% v ,100
  223.     Button_Text1 := ["C","A","S","-","X"]
  224.     For k,v in ["x200 y5 w15 r1 Center BackgroundTrans","x220 y5 w15 r1 Center BackgroundTrans","x240 y5 w15 r1 Center BackgroundTrans","x260 y5 w15 r1 Center BackgroundTrans","x280 y5 w15 r1 Center BackgroundTrans"]
  225.         Gui,1:Add,Text,% v ,% Button_Text1[A_Index]
  226.     Gui,1:Font
  227.     Gui,1:Font,cBlack s14  Bold Q5 ,Nirmala UI
  228.     Gui,1:Add,Edit, x2 y25 w296 h20 Center -E0x200 BackgroundTrans vMain_Clock_Time ,% MyHour " : " A_Min " : " A_Sec  "   " Time2
  229.     Gui,1:Add,Edit,x10 y25 w180 h20  BackgroundTrans -E0x200 Hidden vStop_Watch,000 : 00 : 00 : 000
  230.     For,k,v in ["x192 y27 w22 h22 BackgroundBlack csilver Hidden vSW1","x229 y27 w22 h22 BackgroundBlack csilver Hidden vSW3","x266 y27 w22 h22 BackgroundBlack csilver Hidden vSW5"]
  231.         Gui,1:Add,Progress,% v ,100
  232.     NL1:= ["S","P","R"]
  233.     for,k,v in ["x192 y25 w22 r1 Center Backgroundtrans Hidden vSW2","x229 y25 w22 r1 Center Backgroundtrans Hidden vSW4","x266 y25 w22 r1 Center Backgroundtrans Hidden vSW6"]
  234.         Gui,1:Add,Text,% v,% NL1[A_Index]
  235.     Gui,1:Add,Progress,x10 y53 w280 h10 BackgroundBlack cred vAlarm_Progress range0-1000,
  236.     for,k,v in ["x1 y0 w20 h23 Border gSounds","x25 y0 w170 h20 Border gMove_Window","x200 y5 w15 h15 Border gShow_Clock","x220 y5 w15 h15 Border gSet_Alarm","x240 y5 w15 h15 Border gShow_StopWatch","x260 y5 w15 h15 Border gMinimize_Window","x280 y5 w15 h15 Border gGuiClose","x192 y27 w22 h22 Border Hidden vSW7 gStart_StopWatch","x229 y27 w22 h22 Border Hidden vSW8 gPause_StopWatch","x266 y27 w22 h22 Border Hidden vSW9 gReset_StopWatch"]
  237.         Gui,2:Add,Text,% v
  238.     Gui,1:Show,x900 y50 w300 h65 ,Hellbents StopWatch/Alarm BL
  239.     Gui,2:Show,x900 y50 w300 h65 ,Hellbents StopWatch/Alarm TL
  240. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement