# Playing sound every 16th minute of every hour

## Recommended Posts

Hi,

the purpose: playing sound every 16th minute of an hour

what I wrote is that:

```\$r=1
While \$r=1
if @MIN = 16 Then
SoundPlay("c:\1.wav")
EndIf
WEnd```

is there any better script?

##### Share on other sites

whats the point in

```\$r=1
While \$r=1```

when the value of \$r never changes?

```While 1
If @MIN = 16 Then
SoundPlay("C:\1.wav")
EndIf
WEnd```

##### Share on other sites

Keep in mind with a loop like that, the script is going to consume massive CPU, as well as play the sound, (weather audible or not) MANY times in that 16th minute... I suggest something like...

```While 1
If @MIN = 16 Then
SoundPlay("C:\test.wav",1)
Sleep(60000)
EndIf
sleep(1000)
WEnd```

That way the second it hits the 16th minute, you clearly hear the sound... and you don't hear it again until the next 16th minute... It doesn't consume CPU, and slower machines won't sound like a skipping record for 60 seconds...

Edited by BinaryBrother

##### Share on other sites

```Global \$minute = 16
Global \$hour = -1;Any hour
Global \$played = 0

While 1
Sleep(100)
WEnd

Func _Chimer()
Local \$lhour, \$lminute = @MIN
If \$hour = -1 Then \$lhour = @HOUR
If \$lminute = \$minute Then
If Not \$played Then
SoundPlay(@WindowsDir & "\MEDIA\notify.WAV")
\$played = 1
;I did this to test for more than one case...
;\$minute += 1
EndIf
Else
\$played = 0
EndIf
EndFunc  ;==>_Chimer```

##### Share on other sites

Never thought someone could turn basic math into quantum physics... You probably just caused 'AutoIt180' to give up AutoIt forever...

## Create an account

Register a new account

×

• Wiki

• Back

• Git