Created
November 14, 2019 13:47
-
-
Save nibb13/d871ba221c820a2e597399b661ced547 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
//"Часы с кукушкой" на GenTee (http://www.gentee.ru) | |
//Идея с http://bash.org.ru | |
//Made by nibb13 (nibble@list.ru) | |
//Распространяются по GNU GPL =) | |
// | |
//!!!Работает скрыто, закрывается ручным убийством процесса!!! | |
// | |
import "kernel32.dll"{ | |
GetLocalTime(uint) -> myGetLocalTime //Функция получения системного локального времени. | |
//Пришлось переименовать, т.к. gentee импортирует её | |
//по дефолту. И как-то криво, IMHO... | |
Sleep(uint) //Стандартный sleep | |
} | |
import "winmm.dll"{ | |
uint mciSendStringA(uint,uint,uint,uint) //Функция, для отправки управляющих строк mci-устройствам. | |
uint sndPlaySoundA(uint,uint) //Функция, воспроизводящая WAV-файлы. | |
} | |
func cuckoo(uint iterations){ | |
uint i; | |
fornum i=0, iterations{ | |
mciSendStringA("Set cdaudio door open wait".ptr(),0,0,0); //Открыли CD-ROM | |
sndPlaySoundA("cuckoo.wav".ptr(),0); //Воспроизвели "ку-ку" | |
mciSendStringA("Set cdaudio door closed wait".ptr(),0,0,0); //Закрыли CD-ROM | |
} //Повторили сколько нужно | |
} | |
func start<main>{ | |
datetime currDate; | |
uint sleepInterval=30000; | |
uint currHour; | |
while 1 { //MAINLOOP | |
myGetLocalTime(&currDate); //Текущая дата | |
if currDate.minute==59 && sleepInterval!=1000:sleepInterval=1000; //На последней минуте часа | |
//увеличиваем разрешение | |
//проверок до 1 сек. | |
if currDate.minute==0 && currDate.hour!=currHour { //Нулевая минута + ещё не "кукукали" | |
if currDate.hour<=12 && currDate.hour>0 { //Час - от 1 до 12 | |
cuckoo(currDate.hour); | |
} elif currDate.hour>0 { //Час от 13 до 23 | |
cuckoo(currDate.hour-12); | |
} else { //Час 0 (для системы - 0, для нас - 24 :)) | |
cuckoo(24); | |
} | |
currHour=currDate.hour; //Флаг завершённости действия в текущем часу. | |
sleepInterval=30000; //уменьшаем частоту проверок до 30 сек. | |
} | |
Sleep(sleepInterval) //спим заданный интервал | |
} //MAINLOOP | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment