Jump to content

Recommended Posts

Posted (edited)

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!

Posted

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

Posted

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
Posted

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!

Posted

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.

Posted

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!

Posted

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

Posted

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.

Posted

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!

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
×
×
  • Create New...