Jump to content
Sign in to follow this  
monoceres

Asynchronous beep

Recommended Posts

monoceres

I have for a long time been irritated by the fact that Beep() doesn't return before finishing, so I wrote my own multi-threaded dll that plays the beep in another thread.

Maybe it doesn't fit in "example scripts" but it may come in handy for someone!

Here's the dll:

http://monoceres.se/Uploads/Beep.dll

The exports looks like this:

__declspec(dllexport) int BeepEx(DWORD dwFreq,DWORD dwDuration)
__declspec(dllexport) BOOL IsBeeping()

A small sample:

$dll=DllOpen("Beep.dll")
DllCall($dll,"int:cdecl","BeepEx","dword",200,"dword",1000)
MsgBox(0,"","Beeeep!"); The beep will play while the msgbox is showing!
DllClose($dll)

Important!

To not close the dll while a beep is playing, it will cause a crash!

You can play a new beep however..

PM me for the source, it's far too ugly display here :D

;)

Edited by monoceres

Broken link? PM me and I'll send you the file!

Share this post


Link to post
Share on other sites
Szhlopp

I have for a long time been irritated by the fact that Beep() doesn't return before finishing, so I wrote my own multi-threaded dll that plays the beep in another thread.

Maybe it doesn't fit in "example scripts" but it may come in handy for someone!

Here's the dll:

http://monoceres.se/Uploads/Beep.dll

The exports looks like this:

__declspec(dllexport) int BeepEx(DWORD dwFreq,DWORD dwDuration)
__declspec(dllexport) BOOL IsBeeping()

A small sample:

$dll=DllOpen("Beep.dll")
DllCall($dll,"int:cdecl","BeepEx","dword",200,"dword",1000)
MsgBox(0,"","Beeeep!"); The beep will play while the msgbox is showing!
DllClose($dll)

Important!

To not close the dll while a beep is playing, it will cause a crash!

You can play a new beep however..

PM me for the source, it's far too ugly display here :D

;)

Very cool. This will be awesome for the games or anything else that you don't want to wait for beep to finish=)

Share this post


Link to post
Share on other sites
Markos

what about this one?

Run(@AutoItExe & ' /AutoIt3ExecuteLine Beep()')
MsgBox(0, Default, 'msgboox while beeping')

Share this post


Link to post
Share on other sites
Andreik

I have for a long time been irritated by the fact that Beep() doesn't return before finishing, so I wrote my own multi-threaded dll that plays the beep in another thread.

Maybe it doesn't fit in "example scripts" but it may come in handy for someone!

Here's the dll:

http://monoceres.se/Uploads/Beep.dll

The exports looks like this:

__declspec(dllexport) int BeepEx(DWORD dwFreq,DWORD dwDuration)
__declspec(dllexport) BOOL IsBeeping()

A small sample:

$dll=DllOpen("Beep.dll")
DllCall($dll,"int:cdecl","BeepEx","dword",200,"dword",1000)
MsgBox(0,"","Beeeep!"); The beep will play while the msgbox is showing!
DllClose($dll)

Important!

To not close the dll while a beep is playing, it will cause a crash!

You can play a new beep however..

PM me for the source, it's far too ugly display here ;)

;)

Not working for me. :D

When the words fail... music speaks

Share this post


Link to post
Share on other sites
monoceres

Not working for me. ;)

Does the normal Beep() work for you? It uses the same api.


Broken link? PM me and I'll send you the file!

Share this post


Link to post
Share on other sites
NELyon

Uh oh. Autoit Hard Crashes for me.

Posted Image

With your example code.

Edited by KentonBomb

Share this post


Link to post
Share on other sites
monoceres

Uh oh. Autoit Hard Crashes for me.

Posted Image

With your example code.

Did you close the messagebox before the beep finished? If that's so then check the thing I wrote about closing the dll before beep is finished.

;)


Broken link? PM me and I'll send you the file!

Share this post


Link to post
Share on other sites
NELyon

Did you close the messagebox before the beep finished? If that's so then check the thing I wrote about closing the dll before beep is finished.

;)

The Message Box doesn't even show up. Autoit crashes as soon as the scripts starts.

Share this post


Link to post
Share on other sites
monoceres

The Message Box doesn't even show up. Autoit crashes as soon as the scripts starts.

Weird, can you test add a msgbox() before the DllCall but after the DllOpen() and see if it crashes before or after?


Broken link? PM me and I'll send you the file!

Share this post


Link to post
Share on other sites
trancexx

Weird, can you test add a msgbox() before the DllCall but after the DllOpen() and see if it crashes before or after?

DllOpen is not working. It crashes before actual call

Compile again


♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites
NELyon

Mah code:

$dll=DllOpen("Beep.dll")
ConsoleWrite("!>Dll Opened with handle " & $dll & @CRLF)
DllCall($dll,"int:cdecl","BeepEx","dword",200,"dword",1000)
ConsoleWrite("+>DLL Call... Happened" & @CRLF)
MsgBox(0,"","Beeeep!"); The beep will play while the msgbox is showing!
DllClose($dll)

With the console output:

>Running:(3.2.12.1):C:\Program Files\AutoIt3\autoit3.exe "C:\Documents and Settings\KentonBomb\My Documents\beep.au3"   
!>Dll Opened with handle -1
!>17:12:49 AutoIT3.exe ended.rc:-1073741819

So it seems to be breaking at the DLLCall because it did not open the DLL. I'll investigate.

Share this post


Link to post
Share on other sites
monoceres

DllOpen is not working. It crashes before actual call

Compile again

Mah code:

With the console output:

>Running:(3.2.12.1):C:\Program Files\AutoIt3\autoit3.exe "C:\Documents and Settings\KentonBomb\My Documents\beep.au3"   
 !>Dll Opened with handle -1
 !>17:12:49 AutoIT3.exe ended.rc:-1073741819

So it seems to be breaking at the DLLCall because it did not open the DLL. I'll investigate.

I uploaded a fresh compile which worked great atm.

Please try again ;)


Broken link? PM me and I'll send you the file!

Share this post


Link to post
Share on other sites
trancexx

not working for me

works for you? that is strange

Edited by trancexx

♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites
monoceres

not working for me

works for you? that is strange

I just got it!

I compiled it in debug mode, that means that you will need the latest VC++ Redist.

I compiled it again as "Release" now it should work!

If not then the redist is probably needed:

http://www.microsoft.com/downloads/details...;displaylang=en


Broken link? PM me and I'll send you the file!

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.