#NoTrayIcon
#include <SendMessage.au3>
#include <WindowsConstants.au3>
#include <Sound.au3>
$iTimeGoSleep = 19
$iTimeCanWork = 9
$fPlay = True
$fSleep = True
While 1
Switch @HOUR
Case 0 To $iTimeCanWork, $iTimeGoSleep To 23
If $fPlay Then
If @OSVersion = 'WIN_XP' Then
If FileExists(@SystemDir & '\oobe\images\title.wma') Then
$hSound = _SoundOpen(@SystemDir & '\oobe\images\title.wma')
$sTime = _SoundLength($hSound, 1)
ToolTip('Пора спать. Вам осталось провести за компьютером ' & $sTime, 0, 0, 'Go To Sleep', 2)
_SoundPlay($hSound, 1)
_SoundClose($hSound)
EndIf
Else
If FileExists(@WindowsDir & '\Media\onestop.mid') Then
$hSound = _SoundOpen(@WindowsDir & '\Media\onestop.mid')
$sTime = _SoundLength($hSound, 1)
ToolTip('Пора спать. Вам осталось провести за компьютером ' & $sTime, 0, 0, 'Go Sleep', 2)
_SoundPlay($hSound, 1)
_SoundClose($hSound)
EndIf
EndIf
$fPlay = False
$fSleep = True
BlockInput(1)
AdlibRegister('_Go_Sleep', 5000)
ToolTip('Спать!!!', 0, 0, 'Go Sleep', 2)
EndIf
Case Else
If $fSleep Then
BlockInput(0)
AdlibUnRegister('_Go_Sleep')
ToolTip('')
$fPlay = True
$fSleep = False
EndIf
EndSwitch
Sleep(100)
WEnd
Func _Go_Sleep()
Local $aList = WinList()
If $aList[0][0] Then
For $i = 1 To $aList[0][0]
If BitAND(WinGetState($aList[$i][1]), 2) Then
_SendMessage($aList[$i][1], $WM_COMMAND, 0x019F, 0)
EndIf
Next
EndIf
;WinMinimizeAll()
EndFunc ;==>_Go_Sleep