Здоровья всем.
strDay := strHour := strMin := ""
while (A_Index <= 31) {
if (A_Index - 1 > 0)
strDay := % strDay A_Index-1 "|"
else
strDay := % strDay A_Index-1 "||"
}
while (A_Index <= 24) {
if (A_Index - 1 > 0)
strHour := % strHour A_Index-1 "|"
else
strHour := % strHour A_Index-1 "||"
}
while (A_Index <= 60) {
if (A_Index - 1 == 7)
strMin := % strMin A_Index-1 "||"
else
strMin := % strMin A_Index-1 "|"
}
OnMessage(0x202, "bttnClick")
Gui, 11: +ToolWindow +AlwaysOnTop
Gui, 11: Add, Text, x5 y5,Дней:
Gui, 11: Add, ComboBox, x55 y5 w50 vwaitDay, %strDay%
Gui, 11: Add, Text, x5 y30,Часов:
Gui, 11: Add, ComboBox, x55 y30 w50 vwaitHour, %strHour%
Gui, 11: Add, Text, x5 y55,Минут:
Gui, 11: Add, ComboBox, x55 y55 w50 vwaitMin, %strMin%
Gui, 11: Add, Button, x5 y80 h18,Ждать
Gui, 11: Add, Button, x55 y80 h18,Не ждать
Gui, 11: Show,, Ожидать
waitTimer := -1
while (waitTimer == -1)
sleep, 100
waitTimer += UnixTime()
while (UnixTime() < waitTimer) {
;ControlSetText, Static2, % TimeFormat(waitTimer - UnixTime()), ahk_id %LogHwnd%
;отправляет в контрол окна оставшееся время
sleep 999
}
return
11ButtonНеждать:
waitTimer := 0
Gui, 11: Destroy
return
11ButtonЖдать:
Gui, 11: Submit, NoHide
waitTimer := (waitDay*1440+waitHour*60+waitMin)*60
Gui, 11: Destroy
return
bttnClick() {
if (A_Gui == 11)
return
Global clickReturn, guiReturn, bttnNmbr
Static newCntrl, oldClick, oldGUI, oldBttn
if (newCntrl != A_GuiControl) {
newCntrl := A_GuiControl
ctrlNameArr := StrSplit(A_GuiControl, A_Space)
oldBttn := bttnNmbr := ctrlNameArr[1]
oldClick := clickReturn := ctrlNameArr[2]
oldGUI := guiReturn := A_Gui
ToolTip
Gui, %guiReturn%: Show, Hide
} else {
clickReturn := oldClick
guiReturn := oldGUI
bttnNmbr := oldBttn
ToolTip
Gui, %guiReturn%: Show, Hide
}
}
TimeFormat(time_param) {
time_sec := time_param
time_min := 0
time_hour := 0
while (time_sec > 3599) {
time_sec -= 3600
time_hour++
}
while (time_sec > 59) {
time_sec -= 60
time_min++
}
if (StrLen(time_hour) == 1)
time_hour := % "0" time_hour
if (StrLen(time_min) == 1)
time_min := % "0" time_min
if (StrLen(time_sec) == 1)
time_sec := % "0" time_sec
return % time_hour ":" time_min ":" time_sec
}
; https://autohotkey.com/board/topic/2486-code-to-convert-fromto-unix-timestamp/
;###############Convert YYYYMMDDHHMISS into Unix timestamp#############
UnixTime() {
time_orig=%A_NOW%
StringLeft, now_year, time_orig, 4
StringMid, now_month, time_orig, 5, 2
StringMid, now_day, time_orig, 7, 2
StringMid, now_hour, time_orig, 9, 2
StringMid, now_min, time_orig, 11, 2
StringRight, now_sec, time_orig, 2
;Get year seconds
year_sec := 31536000*(now_year - 1970)
;Determine how many leap days
leap_days := (now_year - 1972)/4 + 1
Transform, leap_days, Floor, %leap_days%
;Determine if date is in a leap year, and if the leap day has been yet
this_leap := now_year/4
Transform, this_leap_round, Floor, %this_leap%
If (this_leap = this_leap_round)
{
If now_month <= 2
leap_days-- ;subtracts 1 because this year's leap day hasn't been yet
}
leap_sec := leap_days*86400
;Determine fully completed months
If now_month = 01
month_sec = 0
If now_month = 02
month_sec = 2678400
If now_month = 03
month_sec = 5097600
If now_month = 04
month_sec = 7776000
If now_month = 05
month_sec = 10368000
If now_month = 06
month_sec = 13046400
If now_month = 07
month_sec = 15638400
If now_month = 08
month_sec = 18316800
If now_month = 09
month_sec = 20995200
If now_month = 10
month_sec = 23587200
If now_month = 11
month_sec = 26265600
If now_month = 12
month_sec = 28857600
;Determine fully completed days
day_sec := (now_day - 1)*86400
;Determine fully completed hours
hour_sec := now_hour*3600 ;don't subtract 1 because it starts at 0
;Determine fully completed minutes
min_sec := now_min*60
;Calculate total seconds
date_sec := year_sec + month_sec + day_sec + leap_sec + hour_sec + min_sec + now_sec
return date_sec
}
Функция bttnClick() участвует в работе других GUI, поэтому она изолируется обозначенным ранее в этой теме способом от GUI, получающего значения времени о задержке перед следующим событием:
Но клики по полям выпадающих списков комбобокса приводят к - "Error: Invalid Gui name". В принципе, не особо и проблема, потому как можно и кнопками нужное число набрать, или вообще заменить ComboBox на Edit, но всё же, может быть есть решение? Подскажите пожалуйста.