Sign in to follow this  
Followers 0
miki

Play a sound without stopping the script

9 posts in this topic

I am thinking about the best way to realize this idea.

I have my .au3 script called SCRIPT1 with his continue loop.

Inside this loop I wait for a condition that happens.

I would like after the condition happens to play a sound with continuity.

In the same time I want that the main SCRIPT1 continue without waiting the stop of the sound.

Maybe the main SCRIPT1 can call another .au3 script like this one (script2.au3)?

script2.au3

While(1)

SoundPlay("C:\Windows\media\notify.wav",1)

sleep(1000)

Wend

Or maybe there is a best way?

Thanks for all suggestion :P

Share this post


Link to post
Share on other sites



SoundPlay("C:\Windows\media\notify.wav")

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

SoundPlay("C:\Windows\media\notify.wav")

8)

Thanks, now I read in the help for SoundPlay

SoundPlay ( "filename" [, wait] )

[optional] This flag determines if the script should wait for the sound to finish before continuing:

1 = wait until sound has finished

0 = continue script while sound is playing (default)

But I want to have a continuos sound like in the script

While(1)

SoundPlay("C:\Windows\media\notify.wav",1)

sleep(1000)

Wend

P.S. the duration of notify.wav is about 1 sec.

Thanks again

Edited by miki

Share this post


Link to post
Share on other sites

Write the sound play code to a temp au3 file and run it while your main sript does it's thing.

$File = FileOpen ("myTempFile.au3",2)

FileWriteline ($File, 'While(1)')
FileWriteline ($File, 'SoundPlay("C:\Windows\media\notify.wav",1)')
FileWriteline ($File, 'sleep(1000)')
FileWriteline ($File, 'Wend')

FileClose ($File)

$Process = Run (@AutoItExe & ' /AutoIt3ExecuteScript myTempFile.au3')

;The rest of your script goes here and when your done you close the process of the temp file



ProcessClose($Process)
FileDelete("myTempFile.au3")

Share this post


Link to post
Share on other sites

Write the sound play code to a temp au3 file and run it while your main sript does it's thing.

$File = FileOpen ("myTempFile.au3",2)

FileWriteline ($File, 'While(1)')
FileWriteline ($File, 'SoundPlay("C:\Windows\media\notify.wav",1)')
FileWriteline ($File, 'sleep(1000)')
FileWriteline ($File, 'Wend')

FileClose ($File)

$Process = Run (@AutoItExe & ' /AutoIt3ExecuteScript myTempFile.au3')

;The rest of your script goes here and when your done you close the process of the temp file
ProcessClose($Process)
FileDelete("myTempFile.au3")
This is real interesting for me.

Thanks

Share this post


Link to post
Share on other sites

Or:

AdlibEnable("Play", 1000)

While 1
    Sleep(100000)
WEnd

Func Play()
    SoundPlay("C:\Windows\media\notify.wav")
EndFunc

Don't take my pic to serious...~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~You Looked, but you did not see!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Share this post


Link to post
Share on other sites

Hi,

you can also Fileinstall the soundplaying exe. This way it will run also on pcs without having installed Autoit.

So long,

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

Hi,

you can also Fileinstall the soundplaying exe. This way it will run also on pcs without having installed Autoit.

So long,

Mega

You don't need autoit installed for my method, because it uses the autoit exe which is compiled in your main script

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

You don't need autoit installed for my method, because it uses the autoit exe which is compiled in your main script

I think @ScriptFullPath (other than @AutoIt.exe) works there too... If I'm not mistaken. Edited by SmOke_N

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

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