magician13134 Posted October 31, 2007 Share Posted October 31, 2007 Hi, I'm writing a script where I need a system bell ringing function similar to Beep(), but it needs to be slightly different. I need to to work like this: (Don't try to run this code, this function doesn't exist) While 1 $msg = GUIGetMsg() If $msg = $coolButton Then StartBeep($frequency) If $msg = $anotherButton Then EndBeep If $msg = $GUI_EVENT_CLOSE Then Exit ; Other cool stuff WEnd So you see, I need it to not have a defined time, I just want it to beep until I say stop while still being able to run other stuff and end it at any point. I could do this by just setting duration to 10 or something similar, but then I get a nasty clicking sound every 10mS... Any ideas? Visit Magic Soft Inc. for some of my software Link to comment Share on other sites More sharing options...
Achilles Posted October 31, 2007 Share Posted October 31, 2007 Try making it beep for a super long time when you press start and then when you want to stop make it beep for 10 ms or maybe 0.. The new beep should cancel out the old one and end quickly.. I don't have time to try but it might work. My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list] Link to comment Share on other sites More sharing options...
Uten Posted October 31, 2007 Share Posted October 31, 2007 If you insist on this. ( I dont think it is a good idea to force the computer to make such noice ) Make a small script called beep.au3 beep(5000, 30000)oÝ÷ Ø*&¦)^Ö¬mç©k|H*.®f¢ªijëh×6Fileinstall("beep.a3x", @TempDir) While 1 $msg = GUIGetMsg() If $msg = $coolButton Then $beep = Run(@AutoItExe & "/AutoIt3ExecuteScript " & @tempdir & "\beep.a3x") If $msg = $anotherButton Then ProcessKill($beep) If $msg = $GUI_EVENT_CLOSE Then Exit ; Other cool stuff WEnd Something like that. Please keep your sig. small! Use the help file. Search the forum. Then ask unresolved questions :) Script plugin demo, Simple Trace udf, TrayMenuEx udf, IOChatter demo, freebasic multithreaded dll sample, PostMessage, Aspell, Code profiling Link to comment Share on other sites More sharing options...
rasim Posted October 31, 2007 Share Posted October 31, 2007 (edited) One of the variant #include <GUIConstants.au3> GUICreate("BeepTest", 200, 100) $start_button = GUICtrlCreateButton("Start", 10, 10, 50, 25) GUISetState() While 1 Switch GUIGetMsg() Case -3 ExitLoop Case $start_button GUICtrlSetData($start_button, "Stop") StartBeep() EndSwitch WEnd Func StartBeep() While GUIGetMsg() <> $start_button Beep(500, 30) Sleep(30) WEnd GUICtrlSetData($start_button, "Start") EndFunc Edited October 31, 2007 by rasim Link to comment Share on other sites More sharing options...
Nevin Posted October 31, 2007 Share Posted October 31, 2007 Don't forget you could just play real sounds. Link to comment Share on other sites More sharing options...
magician13134 Posted October 31, 2007 Author Share Posted October 31, 2007 (edited) @Uten, I guess I could do something like that, but I'd like to avoid dependencies on other computers @rasim, the only problem with that is it makes terrible clicking sounds every time it restarts (every 30mS) @nevin, I need specific hertz, can I do this with real sounds? Without any dlls or external files? Edited October 31, 2007 by magician13134 Visit Magic Soft Inc. for some of my software Link to comment Share on other sites More sharing options...
Achilles Posted October 31, 2007 Share Posted October 31, 2007 GuiCreate('Testing Beep', 400, 40) $btnStart = GuiCtrlCreateButton('Start', 5, 5, 185, 30) $btnStop = GuiCtrlCreateButton('Stop', 205, 5, 185, 30) $processID = -1 GuiSetState() While 1 Switch GuiGetMsg() Case -3 Exit Case $btnStart $processID = Run(@AutoItExe & ' /AutoIt3ExecuteLine' & ' "Beep(500, 600000)"') Case $btnStop ProcessClose($processID) EndSwitch WEnd My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list] Link to comment Share on other sites More sharing options...
magician13134 Posted October 31, 2007 Author Share Posted October 31, 2007 Ooh, cool, thanks. But just to verify, this can run WITHOUT autoit installed, right? Thanks. And one more thing, while this command is being executed, the cursor changes to and hourglass, any way to eliminate that issue? Visit Magic Soft Inc. for some of my software Link to comment Share on other sites More sharing options...
BrettF Posted October 31, 2007 Share Posted October 31, 2007 Ooh, cool, thanks. But just to verify, this can run WITHOUT autoit installed, right? Thanks. And one more thing, while this command is being executed, the cursor changes to and hourglass, any way to eliminate that issue?Alt using DllCall... GuiCreate('Testing Beep', 400, 40) $btnStart = GuiCtrlCreateButton('Start', 5, 5, 185, 30) $btnStop = GuiCtrlCreateButton('Stop', 205, 5, 185, 30) $processID = -1 GuiSetState() While 1 Switch GuiGetMsg() Case -3 Exit Case $btnStart $freq = 500 $duration = 60000 $processID = Run(@AutoItExe & ' /AutoIt3ExecuteLine' & ' "DllCall(""kernel32.dll"", ""int"", ""Beep"", ""int"", '&$freq&', ""int"", '&$duration&')"') Case $btnStop ProcessClose($processID) EndSwitch WEnd Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
Achilles Posted October 31, 2007 Share Posted October 31, 2007 Ooh, cool, thanks. But just to verify, this can run WITHOUT autoit installed, right? Thanks. And one more thing, while this command is being executed, the cursor changes to and hourglass, any way to eliminate that issue?This does require AutoIt installed. As to the hourglass, I'm not even sure why it comes up. I'll look into it for a bit though... My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list] Link to comment Share on other sites More sharing options...
magician13134 Posted October 31, 2007 Author Share Posted October 31, 2007 It may just be my computer. Visit Magic Soft Inc. for some of my software Link to comment Share on other sites More sharing options...
Achilles Posted October 31, 2007 Share Posted October 31, 2007 It may just be my computer.No... It does that on mine too... I tried GuiSetCursor but that wasn't working right. I'll be there's a .dll you can call but I'm no expert on those.. My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list] Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now