Sign in to follow this  
Followers 0
autoit180

Playing sound every 16th minute of every hour

5 posts in this topic

Hi,

Please help me to improve a script

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 this post


Link to post
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 this post


Link to post
Share on other sites

#3 ·  Posted (edited)

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... :P

Edited by BinaryBrother

Share this post


Link to post
Share on other sites

My grossly over complicated addition...

Global $minute = 16
Global $hour = -1;Any hour
Global $played = 0
AdlibEnable("_Chimer", 1000)

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 this post


Link to post
Share on other sites

:unsure:

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

:P

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0