时钟1


#SingleInstance force
#NoEnv

help=
(
● on click = show full date and stop alarm
● 单击 = 显示日期和停止提醒
● on double click = set in saved position
● start alarm - click on small date or open options in the right click context menu
click or double click on ListBox items: double click = alarm with dialog even if it's turned off in Settings
● double click on tray icon = go to settings - Periodic alarm, alarm on specific date

● more options in the right click context menu:   
   GUI color, transparency
   save position for next launch
   small date on/off Full hour flash on/off 
   Regulate alarm loudness on/off , set alarm loudness
● F4 - show GUI , or click on tray icon
● shows missed date alarm, if computer was off or in sleep mode at the time set (on the same day)



)


ico:=RegExMatch(A_OSVersion,"WIN_VISTA|WIN_7") ? 21: 17 
Menu, Tray, Icon, wmploc.dll , %ico%
;Menu, Tray, Icon, wmploc.dll, 21 ; Win Vista
;Menu, Tray, Icon, wmploc.dll, 17 ; Win8

Menu, Tray, NoStandard
Menu, Tray, Add, Window Spy, WindowSpy 
Menu, Tray, Add
Menu, Tray, Add, Periodic alarm settings , alarm_settings
Menu, Tray, Add,
Menu, Tray, Add, Set in saved position , GoToSavedPos
Menu, Tray, Add, Open settings file , Open_ini
Menu, Tray, Icon, Open settings file , Shell32.dll, 70
Menu, Tray, Add,
Menu, Tray, Add, Edit in Scite, Edit_Scite
Menu, Tray, Add, Edit in Notepad, Edit_Notepad
Menu, Tray, Add,
Menu, Tray, Add, Reload , Reload
Menu, Tray, Add, Exit , Exit 
;Menu, Tray, Default, Set in saved position  ; double click tray icon 
Menu, Tray, Default, Periodic alarm settings ; double click tray icon 

Menu, ContextMenu, Add, On Top, OnTop
Menu, ContextMenu, Icon, On Top, Shell32.dll, 248
Menu, ContextMenu, Add,
Menu, ContextMenu, Add, Save current position , save_position
Menu, ContextMenu, Icon, Save current position , Shell32.dll, 124
;Menu, ContextMenu, Add, Set in saved position , GoToSavedPos


Menu, ContextMenu, Add,
;Menu, ContextMenu, Add, Start timer , start_timer
Menu, Submenu3, Add,  Input, start_timer_input
Menu, Submenu3, Add,
Menu, Submenu3, Add,  1 min , start_timer_1m
Menu, Submenu3, Add,  5 min , start_timer_5m
Menu, Submenu3, Add,  10 min , start_timer_10m
Menu, Submenu3, Add,  15 min , start_timer_15m
Menu, Submenu3, Add,  30 min , start_timer_30m
Menu, Submenu3, Add,  60 min , start_timer_60m
Menu, Submenu3, Add,
Menu, Submenu3, Add, Stop timer, stop_timer
Menu, ContextMenu, Add, Start timer, :Submenu3
Menu, ContextMenu, Add,

Menu, Submenu1, Add, Transparent , BackgroundTransparent
Menu, Submenu1, Add, Half Transparent , BackgroundHalfTransparent
Menu, Submenu1, Add,
Menu, Submenu1, Add, Blue gradient   , BackgroundGradientB 
Menu, Submenu1, Add, Red gradient   , BackgroundGradientR
Menu, Submenu1, Add, Green gradient   , BackgroundGradientG
Menu, ContextMenu, Add, Background, :Submenu1 

Menu, Submenu2, Add, Set in saved position , GoToSavedPos
Menu, Submenu2, Icon, Set in saved position , Shell32.dll, 124
Menu, Submenu2, Add
Menu, Submenu2, Add, Show small date on/off   , Show_small_date
Menu, Submenu2, Check, Show small date on/off   
Menu, Submenu2, Add, Full hour flash  on/off , full_hour_flash
Menu, Submenu2, Check, Full hour flash  on/off 
Menu, Submenu2, Add
Menu, Submenu2, Add, Periodic timer on/off   , Periodic_timer_on 
Menu, Submenu2, Check, Periodic timer on/off  ; , wmploc.dll , %ico%
Menu, Submenu2, Add
Menu, Submenu2, Add, Regulate loudness on/off  , Regulate_loudness
Menu, Submenu2, Check, Regulate loudness on/off  

Menu, Submenu2, Add, Alarm loudness  , set_alarm_loudness
Menu, Submenu2, Icon, Alarm loudness  , SndVol.exe
Menu, Submenu2, Add
Menu, Submenu2, Add, Open settings file , Open_ini
Menu, Submenu2, Icon, Open settings file, Shell32.dll, 70
Menu, Submenu2, Add
Menu, Submenu2, Add, Temp routine , temp_routine
Menu, ContextMenu, Add, more, :Submenu2 

Menu, ContextMenu, Add,
Menu, ContextMenu, Add, Periodic alarm settings , alarm_settings
Menu, ContextMenu, Icon, Periodic alarm settings  , wmploc.dll , %ico%
Menu, ContextMenu, Add,
Menu, ContextMenu, Add, Help , show_help
Menu, ContextMenu, Icon, Help , shell32.dll, 24
;Menu, ContextMenu, Add,
;Menu, ContextMenu, Add, Open settings file , Open_ini
;Menu, ContextMenu, Icon, Open settings file, Shell32.dll, 70
Menu, ContextMenu, Add,
Menu, ContextMenu, Add, Restart, Reload
Menu, ContextMenu, Add, Exit, Exit
Menu, ContextMenu, Icon, Exit, Shell32.dll, 132

SetBatchLines, -1




 If !pToken := Gdip_Startup(){
	MsgBox, No Gdiplus 
	ExitApp
}

OnExit, Exit

FileEncoding, UTF-8
SetWorkingDir %A_ScriptDir%

;-----------
	;rim:=0xff444444 ; black
	rim:="" ; default
	;bgrd:="0x99120F00" 
	bgrd:="" ; default
;-----------		
	small_date:=1, full_hour_flash:=1 
	
	alarm_timer_on:=1
	numberOfalarms:=16
	numberOfDatealarms:=10
	alarm_loudness:=20 
	regulate_loudness:=1 ; for longer music
	
	PCspeaker:=1 ; 1: double , 2: short  - timer 
	timesBlink_max:= 3  ; alarm blink ; 6 ~ 1 min
	shortDialogtime:= 15 ; sec
;-----------	
	sounds_folder:=A_WinDir "Media"  ; "F:1.Musicalarm"
	;alarm_sound0:=sounds_folder "Hendrix-Watchtower.mp3" 
	alarm_sound0:=A_WinDir "MediaAlarm03.wav" 

	;alarm_file:= A_WinDir "Medianotify.wav"
	Cuckoo:=sounds_folder "Cuckoo.wav"
	alarm_files:=["notify.wav","chimes.wav","Alarm02.wav","Alarm03.wav","Alarm06.wav","Alarm09.wav"]
;-----------
	show_date:=0, show_date2:=0, alarm_on:=0
	week_days:=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"]

	textToSpeech:="text-to-speech.ahk"
	RuntextToSpeech:=1
;===========

SysGet, MonitorWorkArea, MonitorWorkArea, 1
;~ pos_x:=A_ScreenWidth - 140
pos_x:=A_ScreenWidth/2
;pos_y:= MonitorWorkAreaBottom -830 ;870
pos_y:= A_ScreenHeight/2
settings_ini := "Drozd alarm clock.ini"

IfNotExist, %settings_ini%
{
	first_run:=1	
}

	IniRead, pos_x_saved, %settings_ini%, window position, x	
	IniRead, pos_y_saved, %settings_ini%, window position, y	

if(pos_x_saved!="ERROR" && pos_x_saved!="" && pos_y_saved!="ERROR" && pos_y_saved!=""){
		if(pos_x_saved44 && x77 && y1){
		;=== with gradient =====
		grad_color_rim:=Background_[1]
		grad_color_mid:=Background_[2]
		;size:=Background_[3]
		
		pBrushBG := Gdip_CreateLineBrushFromRect(0, 0, 1, 25, grad_color_rim, grad_color_mid ,1) 
		;Gdip_FillRectangle(G, pBrushBG, 0, 0, w, h)
		Gdip_FillRoundedRectangle(G,pBrushBG,0, 0, w, h,14)
	;========
	}else{
		pBrushBG := Gdip_BrushCreateSolid(Background)
		;Gdip_FillRectangle(G, pBrushBG, 0, 0, w, h)
		Gdip_FillRoundedRectangle(G, pBrushBG, 0, 0, w, h, 14)
	}	
	
	
	pBrush2 := Gdip_BrushCreateSolid(Foreground) ;0xaa2D2A1F
	Gdip_FillEllipse(G, pBrush2, midX-62, midY-62, 124,124)

	if(rim!=""){
		pBrush2 := Gdip_BrushCreateSolid(rim)
		Gdip_FillEllipse(G, pBrush2, midX-60, midY-60, 120, 120)	
	}else{
		pBrush2 := Gdip_CreateLineBrushFromRect(0, 0, 12, 28, 0xff1B1B1B, 0xff2A3649,3)
		Gdip_FillEllipse(G, pBrush2, midX-60, midY-60, 120, 120)
	}

	pBrush2 := Gdip_BrushCreateSolid(0xff222222)
	Gdip_FillEllipse(G, pBrush2, midX-52, midY-52, 104,104)		
	
	pBrushW:= Gdip_BrushCreateSolid(0xffF4F1E4) ; 0xffF4F1E4
	Gdip_FillEllipse(G, pBrushW, midX-50, midY-50, 100,100)

	Gdip_FillEllipse(G, pBrush1, midX-r3, midY-r3, 2*r3, 2*r3)

	;pBrushT := Gdip_BrushCreateSolid(0xff333333)

;================	

	ramkaX:= midX-23 ,ramkaY:=midY+11
	ramkaW:=48 , ramkaH:=12
		
	FormatTime , DayF,, ddd
	FormatTime , Day,,  d	
	months:=["I","II","III","IV","V","VI","VII","VIII","IX","X","XI","XII"]
	FormatTime, M,, M
	
/* 	Polish:=0x0415
	;Data:=GetDateFormat(A_Now,"d MMM',' ddd",Polish) 
	DayF:=GetDateFormat(A_Now,"ddd",Polish) 
	 */
	
	Date:= Day " " months[M]

	if(Daymax_R){
		SetTimer, flash, Off
		Gdip_draw_Win(GuiHwnd,angleM,angleH,rim,bgrd)	
	}
	
 	if(f2==0){
		Gdip_flash(GuiHwnd, pBitmap_2, color_flash,f1,,flash_grad)
		f1:=f1+stepF
	}
	
	if(f1>max_R-0){
		f2:=f2+stepF 
		Gdip_flash(GuiHwnd, pBitmap_2, color_flash,f1,f2,flash_grad)
		if(f2>max_R){
			SetTimer, flash, Off
			f1:=0 , f2:=0

			Gdip_draw_Win(GuiHwnd,angleM,angleH,rim,bgrd)	
			;SetBatchLines, 10ms	
			flash_on:=0				
		}
	}
return


;============================================

start_blink:
if(flash_on){
	SetTimer,start_blink, -2000
	flash_on:=0	
	return
}
	;SoundPlay, *48
	;Gosub, beep 
	max_R:=110 
	b1:=0, b2:=0, b3:=0, 	
	stepB:=3
	go:=1	, i:=0
	SetTimer,blink, 30
	go:=1	
return

blink:
if(flash_on)
	return
;SetBatchLines, -1
	b3a:= (b3>max_R) ? 0 : b3
	Gdip_animate(GuiHwnd,0x99D35050,b1,b2,b3a)

	b1:= go ? b1+stepB : 0	
	b2:= b2 ? b2+stepB : 0
	b3:= b3 ? b3+stepB : 0

	if(b1>max_R){ 
		b1:=0
		go:=0
		i++
	}

 	if(b1>30 && !b2){
			b2:=b2+stepB
	} 
	
	if(b1>60 && !b3){
			b3:=b3+stepB
	} 		 

	if(b2>max_R){
			b2:=0
	} 		

	if(b3>max_R+30){ ; delay between
			b3:=0
			go:=1	
			;SoundPlay, *48
	}

if(i>=3) {	
		go:=0
		if(b3>max_R-10){
			SetTimer,blink, Off
			b1:=0, b2:=0, b3:=0
			timesBlink++
			Gdip_draw_Win(GuiHwnd,angleM,angleH,rim)
			;SetBatchLines, 10ms		
			;Menu, Tray, Tip , %tray_tip%
			Menu, Tray, Tip , %tray_tip%`nblink %timesBlink% x ;times
		}
		
}

if(timesBlink>timesBlink_max){  ;  6 timesBlink ~= 1 min
		Gosub, alarm_off
		Gui,3: Destroy
		;SetBatchLines, 10ms			
		;SoundPlay, *64 
		Menu, Tray, Tip , %tray_tip%
		;Menu, Tray, Tip , %tray_tip%`nblink %timesBlink% times
} 
	
return



;==================================



time:
	;SetBatchLines, -1
	
	FormatTime, h,, HH
	FormatTime, m,, mm
	FormatTime, s,, ss
  FormatTime, weekD,, ddd
	;ToolTip, %  h ":" m ":" s "`n" 

	;if(m!=old_min || Mod(s,5)==0){	
	if(m!=old_min){		
		angleM:=m*6
		angleH:=h*30+angleM/12
		if(!alarm_on){
			Gdip_draw_Win(GuiHwnd,angleM,angleH,rim,bgrd)
		}else{
			Gdip_draw_Win(GuiHwnd,angleM,angleH,rim)
		}
		old_min:=m
	}


	;if(s=0){
	if(m=0 && s=0){		
		if(!alarm_on && full_hour_flash){
			SoundBeep, 2000, 40
			Gosub start_flash
			
		}
		
/* 		SoundGet, loudness_start
		;SoundSet, %alarm_loudness%		
		if(regulate_loudness)
			SoundSet, %alarm_loudness%	
		 */
		if(h=12){
			SoundPlay, %Cuckoo% 
		}
		
/* 		if(regulate_loudness && loudness_start)
			SoundSet, %loudness_start%
		 */
	}
	 
return

;=====================

time_date:
	FormatTime, h,, HH
	FormatTime, m,, mm
	FormatTime, s,, ss
	
if(alarm_timer_on=1){
	
Loop, %numberOfalarms% {
	if(alarms_Object[A_Index].on==1){
		if(alarms_Object[A_Index][weekD]==1){
			if(alarms_Object[A_Index].hour==h && alarms_Object[A_Index].minute==m){
				if((alarms_Object[A_Index].second==s || alarms_Object[A_Index].second==s-1) && (A_TickCount - alarms_Object[A_Index].run >3000)){
						alarms_Object[A_Index].run:=A_TickCount
						if(alarm_on)
							Gosub, alarm_off_2
						alarm_on:=1
						alarm_time:=alarms_Object[A_Index].hour ":" alarms_Object[A_Index].minute ":" alarms_Object[A_Index].second ;h ":" m ":" s
						
						if(alarms_Object[A_Index].PC_speaker==1){
							beep_long() 
						}else if(alarms_Object[A_Index].PC_speaker==2){
							beep_short()
						}

						if(alarms_Object[A_Index].Message){
							alarm_text:= alarms_Object[A_Index].name 							
								if(alarms_Object[A_Index].Message=2)
									short:=1							
							Gosub, alarm_dialog_show
						}else{							
							timesBlink:=0
							Gosub, start_blink
							SetTimer, repeat_alarm, 10000
							SetTimer, alarm_off, -30000							
						}
						
						last_sound:=alarms_Object[A_Index].sound
						SoundGet, loudness_start	
						play_music()
						;SoundSet, %alarm_loudness%
						;SoundPlay, %last_sound%
						

						if(RuntextToSpeech && alarm_text!="")
							Run, %textToSpeech% " Periodic alarm. %alarm_text%" "-3" "100"
						
						tray_tip:="Alarm on " alarm_time "`n" alarms_Object[A_Index].name 	
						Menu, Tray, Tip , %tray_tip%
					}
					
			}
		}
	}
}

;==== every hour =====

	if(alarms_Object[0].on==1){
			if(alarms_Object[0].minute==m){
				if((alarms_Object[0].second==s || alarms_Object[0].second==s-1) && (A_TickCount - alarms_Object[0].run >3000)){
						alarms_Object[0].run:=A_TickCount	
						if(alarm_on)
							Gosub, alarm_off_2
					alarm_on:=1
					
					if(alarms_Object[0].PC_speaker==1){
						beep_short() ;beep_long() 
					}else if(alarms_Object[0].PC_speaker==2){
						beep_short_1()
					}

					last_sound:=alarms_Object[0].sound
					SoundGet, loudness_start	
					;play_music()
					;SoundSet, %alarm_loudness%
					
					
					;Gosub, start_flash
					;Gosub, start_blink	
					
					
					alarm_text:= alarms_Object[A_Index].name
					;if(alarms_Object[0].Message){
					if(RegExMatch(alarm_text,"w+")){	
						;alarm_text:= alarms_Object[A_Index].name
						short:=1 						
						Gosub, alarm_dialog_show
						play_music()
					}else{
						SoundPlay, %last_sound%
						;timesBlink:=0
						;Gosub, start_blink
						;SetTimer, loudness_back,-10000
						;SetTimer, alarm_off, -10000
					}
					
	
					
						if(RuntextToSpeech && alarm_text!="")
							Run, %textToSpeech% " %alarm_text%" "-3" "100"					
					
						tray_tip:= alarms_Object[A_Index].name " " alarm_time "`n" 
						Menu, Tray, Tip , %tray_tip%
				}
			}
	}
;==== 


;==== date

	FormatTime, year,, yyyy
  FormatTime, month,, MM
  FormatTime, day,, d

Loop, %numberOfDatealarms% {	
	if(dates_alarms_Obj[A_Index].on==1){
		if(dates_alarms_Obj[A_Index].year==year && dates_alarms_Obj[A_Index].month==month && dates_alarms_Obj[A_Index].day==day){
				;MsgBox,,, % dates_alarms_Obj[A_Index].name "`nweekD: " weekD " = " dates_alarms_Obj[A_Index][weekD]
					;MsgBox,,, %  dates_alarms_Obj[A_Index].hour "`n" H
					;ToolTip, %  h ":" m ":" s "`n" dates_alarms_Obj[A_Index].name
			;if(dates_alarms_Obj[A_Index].run=0)
			if(dates_alarms_Obj[A_Index].hour==h && dates_alarms_Obj[A_Index].minute==m ){	;|| dates_alarms_Obj[A_Index].run!=1
				;if((dates_alarms_Obj[A_Index].second==s || dates_alarms_Obj[A_Index].second==s-1) && (A_TickCount - dates_alarms_Obj[A_Index].run>3000)){
				if((dates_alarms_Obj[A_Index].second==s || dates_alarms_Obj[A_Index].second==s-1) && dates_alarms_Obj[A_Index].run!=1){	
					dates_alarms_Obj[A_Index].run:=1
					IniWrite, 1, %settings_ini%, Date alarm%A_Index%, Run
					dates_alarms_Obj[A_Index].on:=0
					IniWrite, 0, %settings_ini%, Date alarm%A_Index%, alarm on
					
							dates_alarms_Obj[A_Index].run:=A_TickCount
							alarm_time:=day "/" month  "  " dates_alarms_Obj[A_Index].hour ":" dates_alarms_Obj[A_Index].minute 
									if(alarm_on)
										Gosub, alarm_off_2	
								alarm_on:=1
								
								if(dates_alarms_Obj[A_Index].PC_speaker==1){
									beep_long() 
								}else if(dates_alarms_Obj[A_Index].PC_speaker==2){
									beep_short()
								}					

								;alarm_time:=day "/" month  "  " h ":" m ;":" s
								alarm_text:= dates_alarms_Obj[A_Index].name 
								if(dates_alarms_Obj[A_Index].Message){
									;alarm_text:= dates_alarms_Obj[A_Index].name 							
											;if(alarm_text=="")									
									Gosub, alarm_dialog_show
								}else{
									alarm_on:=1
									timesBlink:=0
									Gosub, start_blink
									SetTimer, repeat_alarm, 10000
								}
								
								last_sound:=dates_alarms_Obj[A_Index].sound
								SoundGet, loudness_start	
								play_music()
								;SoundSet, %alarm_loudness%
								;SoundPlay, %last_sound%

								if(RuntextToSpeech && alarm_text!=""){
									FormatTime, date_, % dates_alarms_Obj[A_Index].Date, dddd. MMMM dd.																		
									date_speak:= " Date alarm. " alarm_text ". " date_  ;" " dates_alarms_Obj[A_Index].hour ":" dates_alarms_Obj[A_Index].minute  "."										
									Run, %textToSpeech% "%date_speak%" "-3" "100"
								}
								
								tray_tip:="Date alarm on " date_ "`n" alarm_time "`n" dates_alarms_Obj[A_Index].name 	
								Menu, Tray, Tip , %tray_tip%	
				}
			}else if(dates_alarms_Obj[A_Index].hour3600 ? Floor(mod(time_compare,3600)/60) : Floor(time_compare/60)
	compare_timeLeft_s := Floor(mod(time_compare,60))
	time_compare_show:=compare_timeLeft_h >0 ? dig(compare_timeLeft_h) ":" dig(compare_timeLeft_m) ":" dig(compare_timeLeft_s)  : dig(compare_timeLeft_m) ":" dig(compare_timeLeft_s) 

tray_tip:="timer:          " min_input " min" "`ntime left:     " time_compare_show  "`nstarted on:  " timer_started_on
	Menu, Tray, Tip , % tray_tip   
	GuiControl,3:, Show_timer, %time_compare_show%
	if(time_compare3600 ? Floor(mod(start_msg_timer,3600)/60) : Floor(start_msg_timer/60)
msg_timer_s := Floor(mod(start_msg_timer,60))
msg_timer_l:=msg_timer_h >0 ? dig(msg_timer_h) " : " dig(msg_timer_m) " : " dig(msg_timer_s)  : "`    " dig(msg_timer_m) "  :  " dig(msg_timer_s) 
GuiControl,2:, msg_timer, %msg_timer_l%
return


flash_:
    col:=!col          
  if(col){
    Gui,2: Font, S11 c%alarm_text_col_fl% W700 , Comic Sans MS
    GuiControl,2: Font, title  
  }else{
    Gui,2: Font, S11 cRed W700 , Comic Sans MS
    GuiControl,2: Font, title        
  }
return

beep:
	SoundPlay *48	
	;SoundPlay, % A_WinDir "Medianotify.wav" ; chimes.wav
return

beep_Off:
	SetTimer, beep, Off
return

loudness_back:
	alarm_on:=0
	if(regulate_loudness)
		play_music_Off()
return

play_music(sound:=""){
  global last_sound , alarm_loudness , regulate_loudness, loudness_start
	;SoundGet, loudness_start	
	sound:=sound ? sound : last_sound
  SoundPlay, %sound%
	;SoundSet, %alarm_loudness%	
	if(regulate_loudness)
		play_loudness(alarm_loudness)  
}


play_loudness(alarm_loudness){
	;Run, SndVol.exe -f 57738758 
 loop, 10 {
  SoundSet, % A_Index*alarm_loudness/10
  Sleep, 100
 }
 ;WinClose, ahk_exe SndVol.exe
}

play_music_Off(){
	global alarm_loudness, loudness_start
	global alarm_on:=0
	SoundGet, start
	start:= (start) ? start : alarm_loudness
	;Run, SndVol.exe -f 57738758
	loop, 10 {
		sndLev:=(10-A_Index)*start/10
		SoundSet, % sndLev
		Sleep, 100
 } until (sndLev5) ? loudness_start : 10
 SoundSet, %loudness_start%
}

play_again:
	;play_music()
	SoundPlay, %last_sound%
	;Gui,2: -AlwaysOnTop	
return

close_dialog:
SetTimer, close_dialog, Off
2GuiClose:
if(short_close){
	DllCall( "AnimateWindow", "Int", D_Hwnd, "Int", 400, "Int", 0x00010001 ) ; hide R-L
	short_close:=0
}else
	DllCall( "AnimateWindow", "Int", D_Hwnd, "Int", 200, "Int", 0x00010008 ) ; hide sweep
	;DllCall( "AnimateWindow", "Int", D_Hwnd, "Int", 300, "Int", 0x00010010 ) ; hide grow
	;Gui,2: Hide  ;Gui,2: Destroy
	SetTimer, blink, Off
	SetTimer, repeat_alarm, Off
	SetTimer, flash_, Off
	SetTimer, time_, Off 
	Gdip_draw_Win(GuiHwnd,angleM,angleH,rim,bgrd)
	;if(regulate_loudness && loudness_start)
	;	SoundSet, %loudness_start%
	if(regulate_loudness){
		play_music_Off()
	}else
		SoundPlay, nic
	SetTimer, beep, Off
return


4GuiClose:
Gui,4: Destroy
return


;======================



beep_long(){
	SoundBeep,700
	SoundBeep,520,400 
}

beep_short(){
  SoundBeep,520,50 ; m-high
}
  
beep_short_1(){
  SoundBeep,720,20 ; high
}
  	
beep_short_2(){
  SoundBeep,400,150  ;low
}	



;======================

dig(num){ ;to_two_digits
   num:= (StrLen(num)=1) ? "0" . num : num
   return num
}


;=================================


alarm_settings:
if WinExist("Drozd alarm settings"){
	Gui,4: Show
	return
}

GuiW_4:=834 , GuiH_4:=570
SaveX:= GuiW_4/2 - 80, SaveY:= GuiH_4-40
CancelX:=GuiW_4/2 + 10, CancelY:=GuiH_4-40
;Gui,4:+Owner1 
Gui,4:+ToolWindow  

Gui,4:Color, 0B4761 ;blu 
;Gui,4:Color, 10524E  ;06615A ;0A615A

Gui,4:Margin, 0 
Gui,4:Font,  Q5, Segoe UI bold ;Tahoma
Gui,4:Add, Tab3, x2 y4 w826 h500  cF1F1F1  0x400 , ` Periodic alarm` |` On specific date` |` Every hour` | Settings

Gui,4: Tab, 
Gui,4:Add, Button , x%SaveX% y%SaveY% w60 h22  gSaveSet , Save
Gui,4:Add, Button , x%CancelX% y%CancelY% w60 h22  gCancel_but , Cancel


Gui,4: Font, S12 cF1F1F1 Q5, Segoe UI Bold ;
;Gui,4:Add, Text, x340  y10   , Periodic alarm

Gui,4: Tab, 1

	Gui,4: Font, S7 cF1F1F1 Q5
	Gui,4:Add, Text,  x42 y50 , Name:
	Gui,4: Font, S7 Q5
	Gui,4:Add, Text,  x7 y50 , Enable
	Gui,4:Add, Text,  x156 y50 , Hour
	Gui,4:Add, Text,  x188 y50 , Min.
	Gui,4:Add, Text,  x218 y50 , Sec.

	Gui,4:Add, Text,  x272 y50 , Mon
	Gui,4:Add, Text,  x+9 y50 , Tue 
	Gui,4:Add, Text,  x+10 y50 , Wed
	Gui,4:Add, Text,  x+9 y50 , Thu
	Gui,4:Add, Text,  x+13 y50 , Fri
	Gui,4:Add, Text,  x+15 y50 , Sat
	Gui,4:Add, Text,  x+12 y50 , Sun

	Gui,4:Add, Text,  x490 y50 , Sound file:

	;Gui,4:Add, Text,  x705 y50 , Msg.
	Gui,4:Add, Text,  x706 y37 , Msg. dialog
	
	Gui,4:Add, Text,  x772 y37 , PC speaker
	Gui,4: Font, S6 Q5 , Segoe UI 
	Gui,4:Add, Text,  x774 y51  , long
	Gui,4:Add, Text,  x+10 y51 , short
	
	Gui,4:Add, Text,  x711 y51  , long
	Gui,4:Add, Text,  x+6 y51 , short
 
Gui,4: Font, S8 cDefault W400 , Tahoma 


Loop, %numberOfalarms% {
	if(A_Index==1){
		Gui,4:Add, Checkbox, x12 y70 vNum%A_Index%  , 
	}else{
		Gui,4:Add, Checkbox, x12 y+14  vNum%A_Index%  , 
	}
		Gui,4:Add, Edit, x+0 y+-17 w110  vName%A_Index%, Name %A_Index%
		Gui,4:Add, Edit, x+5  w30 vhora%A_Index%, %A_Hour% 
		Gui,4:Add, Edit, x+0  w30 vmin%A_Index%, %A_Min%
		Gui,4:Add, Edit, x+0  w30 vsec%A_Index%, 00 ;%A_Sec%
		
 		Name=A%A_Index%
	Loop, 7 {	
		 var=%Name%Day%A_Index%      
	if(A_Index==1){
			Gui,4:Add, Checkbox, x+30 y+-18 w27 v%var% Checked 
		}else
			Gui,4:Add, Checkbox, x+0 w27 v%var% Checked  
	}			
}

len:=alarm_files.Length(), j:=1

Loop, %numberOfalarms% {
	if(A_Index==1){
			Gui,4:Add, Edit, x490 y66 w180 vSound%A_Index%  , % A_WinDir "Media" alarm_files[j] ; %alarm_file%   ;file path
			;Gui,4:Add, Checkbox, x+10 y70
			Gui,4:Add, Button, x+6 h20 w25 vFile%A_Index% gSelectFile, ..
	}else{
			Gui,4:Add, Edit, x490 y+6 w180 vSound%A_Index%  , % A_WinDir "Media" alarm_files[j] ;  %alarm_file%    ;file path
			Gui,4:Add, Button, x+6  h20 w25 vFile%A_Index% gSelectFile, ..
			;Gui,4:Add, Checkbox, x+10
	}
	j:=(j >= len) ? 1 : j+1
}	


 
	Loop, %numberOfalarms% {
		if(A_Index==1){
			Gui,4:Add, Checkbox, x714 y69 w24 vMsg%A_Index% Checked ,  
			Gui,4:Add, Checkbox, x+0 w24 vMsgSh%A_Index%  ,		
		}else{	
			Gui,4:Add, Checkbox, x714 y+13 w24 vMsg%A_Index% Checked ,
			Gui,4:Add, Checkbox,  x+0 w24 vMsgSh%A_Index%  ,
			
		}
	}

 Loop, %numberOfalarms% {
	if(A_Index==1){
		Gui,4:Add, Checkbox, x776 y69 vPC_l%A_Index% ,  ;PCspeaker
		Gui,4:Add, Checkbox, x+0 y69 vPC_s%A_Index% , 
	}else{	
		Gui,4:Add, Checkbox, x776 y+13 vPC_l%A_Index% 
		Gui,4:Add, Checkbox, x+0 vPC_s%A_Index% 
	}
}   


  Gui,4: Add, Text, x260 y66 w3 h410 0x5 ; Vertical Line
	Gui,4: Add, Text, x470 y66 w3 h410 0x5 ; Vertical Line
	Gui,4: Add, Text, x764 y66 w1 h410 0x5 ; Vertical Line
	
;==== every hour =====	
Gui,4: Tab, 3	

	Gui,4: Font, S12 cF1F1F1 Q5, Segoe UI Bold ;
	;Gui,4:Add, Text, x340  y10   , Periodic alarm
	Gui,4: Font, S7 cF1F1F1 Q5
	Gui,4:Add, Text,  x40 y50 , Name:
	Gui,4: Font, S7 Q5
	Gui,4:Add, Text,  x7 y50 , Enable
	;Gui,4:Add, Text,  x190 y50 , Hour
	Gui,4:Add, Text,  x225 y50 , Min.
	Gui,4:Add, Text,  x256 y50 , Sec.

	Gui,4:Add, Text,  x520 y50 , Sound file:

	Gui,4:Add, Text,  x735 y50 , Msg.

	Gui,4:Add, Text,  x772 y37 , PC speaker
	Gui,4: Font, S6 Q5 , Segoe UI 
	Gui,4:Add, Text,  x774 y51  , long
	Gui,4:Add, Text,  x+10 y51 , short
	
	
Gui,4: Font, S8 cDefault W400 , Tahoma 

	
	Gui,4:Add, Checkbox, x12 y70 w23 vNum0  , 
	Gui,4:Add, Edit, x+6 y+-17 w140  vName0, ;Every hour

	Gui,4:Add, Edit, x+10  w30 vhora0, %A_Hour% 
			GuiControl,4: Hide,hora0 
	Gui,4:Add, Edit, x+0  w30 vmin0,00 ;%A_Min%
	Gui,4:Add, Edit, x+0  w30 vsec0, 00 ; %A_Sec%
		
/*  		Name=A%0%
	Loop, 7 {
		 var=%Name%Day%A_Index%      
	if(A_Index==1){
			Gui,4:Add, Checkbox, x+33 y+-18 w27 v%var% Checked ;vDay%A_Index%
		}else
			Gui,4:Add, Checkbox, x+0 w27 v%var% Checked  ;vDay%A_Index%		
	}			
 */
	Gui,4:Add, Edit, x520 y66 w180 vSound0  , %alarm_file%
	Gui,4:Add, Button, x+6 h20 w25 vFile0 gSelectFile, ..
	
	Gui,4:Add, Checkbox, x740 y69 w24 vMsg0 Checked ,	
	Gui,4:Add, Checkbox, x776 y69 vPC_l0 ,  ;gPCspeaker
	Gui,4:Add, Checkbox, x+0 y69 vPC_s0
;==== 


;==== 
Gui,4:Tab,2

	Gui,4: Font, S7 w700 cF1F1F1 Q5, Segoe UI Bold
	Gui,4:Add, Text,  x40 y50 , Name:
	Gui,4:Add, Text,  x7 y50 , Enable
	Gui,4:Add, Text,  x193 y50 , Hour
	Gui,4:Add, Text,  x225 y50 , Min.
	Gui,4:Add, Text,  x255 y50 , Sec.

	Gui,4:Add, Text,  x520 y50 , Sound file:
	Gui,4:Add, Text,  x735 y50 , Msg.
	Gui,4:Add, Text,  x772 y37 , PC speaker
	Gui,4: Font, S6 Q5 , Segoe UI 
	Gui,4:Add, Text,  x774 y51  , long
	Gui,4:Add, Text,  x+10 y51 , short



Gui,4: Font, S8 cDefault W400 , Tahoma 

Loop, %numberOfDatealarms% {
	if(A_Index==1){
		Gui,4:Add, Checkbox, x12 y70 w23 vDateNum%A_Index%  , 
	}else{
		Gui,4:Add, Checkbox, x12 y+9 w23 vDateNum%A_Index%  , 
	}
		Gui,4:Add, Edit, x+6 y+-17 w140  vDateName%A_Index%, Date %A_Index%
		Gui,4:Add, Edit, x+10  w30 vDatehora%A_Index%, %A_Hour% 
		Gui,4:Add, Edit, x+0  w30 vDatemin%A_Index%, %A_Min%
		Gui,4:Add, Edit, x+0  w30 vDatesec%A_Index%, 00 ;%A_Sec%
}	
	
	Gui,4: Font, S8 W700

Loop, %numberOfDatealarms% {	
	if(A_Index==1){
		Gui,4:Add, DateTime, x+20 y65  w160 vDateTime%A_Index%  Choose%var% ;Range20170301, ;LongDate
	}else{
		Gui,4:Add, DateTime, y+5  w160 vDateTime%A_Index% , 
	}
}

;=== notify_texts
Gui,4: Font, S9 cD0CFCF W700 , Tahoma 

Loop, %numberOfDatealarms% {	
	if(A_Index==1){
		Gui,4:Add, Text, x+15 y68 w14 cD0CFCF Center vDateText%A_Index%, 
	}else{
		Gui,4:Add, Text, y+12 w14 cD0CFCF Center vDateText%A_Index%, 
	}
}


	Gui,4: Font, S8 cDefault W400 , Tahoma 
 len:=alarm_files.Length(), j:=1
Loop, %numberOfDatealarms% {
	
	if(A_Index==1){
			Gui,4:Add, Edit, x520 y66 w180 vDateSound%A_Index%  , % A_WinDir "Media" alarm_files[j] ;%alarm_file%   ;file path
			;Gui,4:Add, Checkbox, x+10 y70
			Gui,4:Add, Button, x+6 h20 w25 vDateFile%A_Index% gSelectFileDate, ..
	}else{
			Gui,4:Add, Edit, x520 y+6 w180 vDateSound%A_Index%  , % A_WinDir "Media" alarm_files[j]  ;%alarm_file%    ;file path
			Gui,4:Add, Button, x+6  h20 w25 vDateFile%A_Index% gSelectFileDate, ..
			;Gui,4:Add, Checkbox, x+10
	}
	;Gui,4:Add, Button, x+10 y13 h24 w30 gSelectFile, ...
	j:=(j >= len) ? 1 : j+1
}	
	
 
 Loop, %numberOfDatealarms% {
	if(A_Index==1){
		Gui,4:Add, Checkbox, x740 y69 w24 vDateMsg%A_Index% Checked ,   
	}else{	
		Gui,4:Add, Checkbox, x740 y+13 w24 vDateMsg%A_Index% Checked ,
		
	}
} 

 Loop, %numberOfDatealarms% {
	if(A_Index==1){
		Gui,4:Add, Checkbox, x776 y69 vDatePC_l%A_Index% ,  ;PCspeaker
		Gui,4:Add, Checkbox, x+0 y69 vDatePC_s%A_Index% , 
	}else{	
		Gui,4:Add, Checkbox, x776 y+13 vDatePC_l%A_Index% 
		Gui,4:Add, Checkbox, x+0 vDatePC_s%A_Index% 
	}
}   



;===== other settings

Gui,4:Tab,4
	
	Gui,4: Font, S8 cDefault W400 , Tahoma 
	Gui,4:Add, Edit, x180 y66 w180 vSoundTimer  , % A_WinDir "MediaAlarm03.wav" ;%alarm_file%
	Gui,4:Add, Button, x+6 h20 w25  gSelectFileTimer, ..
	Gui,4:Add, Edit, x180 y+10 w180  vSoundsFolder , % A_WinDir "Media" 
	Gui,4:Add, Button, x+6 h20 w25  gSelectSoundsFolder, ..
	
	Gui,4: Font, S9 cF1F1F1 Q5, Segoe UI SemiBold  
	Gui,4:Add, Text,  x20 y69 , Timer alarm sound: 
	Gui,4:Add, Text,  x20 y+15 , Sounds folder: 
	
	


	Gui,4:Add, Checkbox, x440 y180 vRegulate_loudness Checked
	Gui,4:Add, Text,  x+10 vRegulate_loudnessCtrl gtextCtrl, Loudness control (gradual increase/decrease)
	Gui,4:Add, Button, x530 y230 gset_alarm_loudness, Set alarm loudness

	;Gui,4:Add, Text,  x+10, Alarm loudness:  ;set_alarm_loudness
	
	Gui,4:Add, Checkbox, x40  y180 vPeriodic_timer_on Checked
	Gui,4:Add, Text,  x+10  vPeriodic_timer_onCtrl gtextCtrl, Periodic timer on

	
	Gui,4:Add, Checkbox, x40 y+20 vShow_small_date Checked
	Gui,4:Add, Text,  x+10  vShow_small_dateCtrl gtextCtrl, Show small date
	Gui,4:Add, Checkbox, x40 y+20  vfull_hour_flash Checked   
	Gui,4:Add, Text,  x+10  vfull_hour_flashCtrl gtextCtrl, Full hour flash 
 	Gui,4:Add, Checkbox, x40 y+20  vTimerMsg Checked
	Gui,4:Add, Text,  x+10  vTimerMsgCtrl gtextCtrl, Timer alarm dialog 
	Gui,4:Add, Checkbox, x40 y+20  vTxtSpch Checked
	Gui,4:Add, Text,  x+10  vTxtSpchCtrl gtextCtrl, Text To Speech
	
	Gui,4:Tab		

	Gui, 4:Show, w%GuiW_4% h%GuiH_4%  , Drozd alarm settings
	
IfExist, %settings_ini% 
{
	IniRead, x, %settings_ini%, alarm1
	if(x!="ERROR" && x!=""){
		Gosub, Load_Settings
	}
}

return 




SelectFile:
	RegExMatch(A_GuiControl,"i)File(d+)",out)	
	FileSelectFile, file_path, 1 , %sounds_folder% , Open, Files (*.wav; *.3gp; *.mp3; *.avi; *.wmv; *.aac; *.m4a)
	if(file_path)
		GuiControl,4:, Sound%out1%, %file_path%
return

SelectFileDate:
	RegExMatch(A_GuiControl,"i)DateFile(d+)",out)	
	FileSelectFile, file_path, 1 , %sounds_folder% , Open, Files (*.wav; *.3gp; *.mp3; *.avi; *.wmv; *.aac; *.m4a)
	if(file_path)
		GuiControl,4:, DateSound%out1%, %file_path%
return

SelectFileTimer:
	FileSelectFile, file_path, 1 , %sounds_folder% , Open, Files (*.wav; *.3gp; *.mp3; *.avi; *.wmv; *.aac; *.m4a)
	if(file_path)
		GuiControl,4:, SoundTimer, %file_path%
return

SelectSoundsFolder:
	FileSelectFile, file_path , ,  %sounds_folder%RootDir, Open ; "RootDir" - to open folder instead of file
	file_path:=RegExReplace(file_path,"RootDir$","")
	if(file_path)
		GuiControl,4:, SoundsFolder, %file_path%
return

textCtrl:
	RegExMatch(A_GuiControl,"i)File(d+)",out)
	Ctrl:=RegExReplace(A_GuiControl,"i)Ctrl","")
	GuiControlGet, var,4: , %Ctrl%
	;MsgBox,,, % Ctrl "`n " test_	
	if(var=1){
		GuiControl,4: ,%Ctrl% , 0
	}else if(var=0){
		GuiControl,4: ,%Ctrl% , 1		
	}
return


Load_Settings:
 if !WinExist("Drozd alarm settings")
	Gosub, alarm_settings	
	
		Loop, %numberOfalarms% {
		IniRead, x, %settings_ini%, alarm%A_Index%, alarm on , %A_Space%
		GuiControl,4:, Num%A_Index% , %x%	 

		IniRead, x , %settings_ini%, alarm%A_Index%, Name , %A_Space%
		GuiControl,4:, Name%A_Index% , %x%	 
		IniRead, x , %settings_ini%, alarm%A_Index%, Hour , %A_Space%
		GuiControl,4:, hora%A_Index% , %x%
		IniRead, x, %settings_ini%, alarm%A_Index%, Minute , %A_Space%
		GuiControl,4:, min%A_Index% , %x%
		IniRead, x , %settings_ini%, alarm%A_Index%, Second	 , %A_Space%
		GuiControl,4:, sec%A_Index% , %x%
		 
		GuiControl,4:, Msg%A_Index% , 0
		IniRead, x , %settings_ini%, alarm%A_Index%, Message , %A_Space%  ; 1= long , 2= short, 0= none
		if(x=1)
			GuiControl,4:, Msg%A_Index% , 1
		if(x=2)	
			GuiControl,4:, MsgSh%A_Index% , 1	
		
		IniRead, x , %settings_ini%, alarm%A_Index%, Sound file , %A_Space%
		GuiControl,4:, Sound%A_Index% , %x%
		
	
		IniRead,x , %settings_ini%, alarm%A_Index%, PC speaker  , %A_Space% ; 1= long , 2= short, 0= none
		if(x==1)
			GuiControl,4:, PC_l%A_Index% , 1
		if(x==2)	
			GuiControl,4:, PC_s%A_Index% , 1

		
		Name=A%A_Index%
		num=%A_Index%
		Loop, 7 {
			var=%Name%Day%A_Index%    
			day:=week_days[A_Index]
			IniRead, x , %settings_ini%, alarm%num%, %day%  , %A_Space%
			GuiControl,4:, %var% , %x%			
		}
	}
		

;==== every hour =====
		IniRead, x, %settings_ini%, alarm0, alarm on , %A_Space%
		GuiControl,4:, Num0 , %x%	 

		IniRead, x , %settings_ini%, alarm0, Name
		GuiControl,4:, Name0 , %x%	 
		;IniRead, x , %settings_ini%, alarm0, Hour
		;GuiControl,4:, hora0 , %x%
		IniRead, x, %settings_ini%, alarm0, Minute , %A_Space%
		GuiControl,4:, min0 , %x%
		IniRead, x , %settings_ini%, alarm0, Second	 , %A_Space%
		GuiControl,4:, sec0 , %x%

		IniRead, x , %settings_ini%, alarm0, Message , %A_Space%
		GuiControl,4:, Msg0 , %x%
		
		IniRead, x , %settings_ini%, alarm0, Sound file , %A_Space%
		GuiControl,4:, Sound0 , %x%
		
	
		IniRead,x , %settings_ini%, alarm0, PC speaker  , %A_Space% ; 1= long , 2= short, 0= none
		if(x==1)
			GuiControl,4:, PC_l0 , 1
		if(x==2)	
			GuiControl,4:, PC_s0 , 1
	
;==== 

;==== 

		Loop, %numberOfDatealarms% {
		IniRead, x, %settings_ini%, Date alarm%A_Index%, alarm on , %A_Space%
		GuiControl,4:, DateNum%A_Index% , %x%	 

		IniRead, x , %settings_ini%, Date alarm%A_Index%, Name , %A_Space%
		GuiControl,4:, DateName%A_Index% , %x%	 
		IniRead, x , %settings_ini%, Date alarm%A_Index%, Hour , %A_Space%
		GuiControl,4:, Datehora%A_Index% , %x%
		IniRead, x, %settings_ini%, Date alarm%A_Index%, Minute , %A_Space%
		GuiControl,4:, Datemin%A_Index% , %x%
		IniRead, x , %settings_ini%, Date alarm%A_Index%, Second	 , %A_Space%
		GuiControl,4:, Datesec%A_Index% , %x%
		
		IniRead, x , %settings_ini%, Date alarm%A_Index%, Date , %A_Space%
		GuiControl,4:, DateTime%A_Index% , %x%	
	
		
		IniRead, x , %settings_ini%, Date alarm%A_Index%, Message , %A_Space%
		GuiControl,4:, DateMsg%A_Index% , %x%
		
		IniRead, x , %settings_ini%, Date alarm%A_Index%, Sound file , %A_Space%
		GuiControl,4:, DateSound%A_Index% , %x%
		
	
		IniRead,x , %settings_ini%, Date alarm%A_Index%, PC speaker  , %A_Space% ; 1= long , 2= short, 0= none
		if(x==1)
			GuiControl,4:, DatePC_l%A_Index% , 1
		if(x==2)	
			GuiControl,4:, DatePC_s%A_Index% , 1
 
	}
	
;=== notify_texts
		FormatTime, year,, yyyy
		FormatTime, month,, MM
		FormatTime, day,, d
					
	Loop, %numberOfDatealarms% {
		IniRead, dat , %settings_ini%, Date alarm%A_Index%, Date , %A_Space%
			FormatTime, datY,%dat%, yyyy
			FormatTime, datM,%dat%, MM
			FormatTime, datD,%dat%, d		
			
		if(datY

给TA捐赠
共{{data.count}}人
人已捐赠
其他

时钟

2020-3-9 3:14:44

其他

时钟2

2020-3-9 3:16:44

个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索