Jump to content

Asynchronous beep


monoceres
 Share

Recommended Posts

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!

Link to comment
Share on other sites

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=)

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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!

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...