WesleyThomas Posted July 2, 2012 Posted July 2, 2012 Hopefully just a quicky guys. I have been writing a graphical program and have embedded a child GUI into my main gui and I am using the standard wasd key setup to do some animation in my child window. All is going fine but now I have decided to add some buttons to the main GUI for other controls and all of a sudden I am getting a beep when I press my keys to animate my graphics. If I press and hold w to move forward I get a succession of beeps. The graphical side is still working fine, just can't get rid of these annoying beeps. Probably something simple, I just have to ask as I have spent over 3 hours trying different things. It even does it if I add a label to the main GUI. If I have a clear GUI, with no controls added then I do not get any beeps and all works fine. Just happens when I have a control. Any ideas? Can add a sample code if required, just think someone will know what i'm talking about straight away as it seems so simple. Regards, Wez
WesleyThomas Posted July 2, 2012 Author Posted July 2, 2012 Here is an example, run it and press w key to change colour of the square. You get a beep. If you run it after removing the Global $hButton = GUICtrlCreateButton("GO!", 610, 10, 50, 20) line, then there is no beep. #include <WindowsConstants.au3> #include <Misc.au3> Opt("GUIOnEventMode", 1) Global Const $hUSER32 = DllOpen("user32.dll") Global $hGUI = GUICreate("GL GUI", 800, 600, 0, 0, BitOr($Gui_SS_DEFAULT_GUI,$WS_CLIPCHILDREN)) Global $hButton = GUICtrlCreateButton("GO!", 610, 10, 50, 20) GUISetOnEvent(-3, "Terminate", $hGUI) ; on exit GUISetState(@SW_SHOW, $hGUI) Global $hGUIGraphics = GUICreate("", 600, 600, 0, 0, $WS_CHILD, 0, $hGUI) Global $Label = GUICtrlCreateLabel(" Press W Key", 10, 10, 100, 100) GUICtrlSetBkColor($Label, 0x808080) GUISetState() GUISetState(@SW_SHOW, $hGUIGraphics) While 1 Sleep(100) If _IsPressed(57, $hUSER32) Then;if w is pressed Local $String = "0x"&Hex(Random(0,255, 1),2)&Hex(Random(0,255, 1),2)&Hex(Random(0,255, 1),2) GUICtrlSetBkColor($Label, $String) GUISetState() EndIf WEnd Func Terminate() DllClose($hUSER32) Exit EndFunc
John Posted July 2, 2012 Posted July 2, 2012 I'm not getting a beep. Turned them up very loud to. Is this the internal computer speaker, like what beep for bios codes, or the sound card speakers?
WesleyThomas Posted July 2, 2012 Author Posted July 2, 2012 Like the beep you get when a Messagebox appears
John Posted July 2, 2012 Posted July 2, 2012 Oh, it's an event generated beep, defined in the registry. I'll set a sound profile and trace it.
John Posted July 2, 2012 Posted July 2, 2012 It's the "Default Sound", under "Critical Stop" on my machine, in your sound settings. Turn it off. It's not even an informative sound.
WesleyThomas Posted July 2, 2012 Author Posted July 2, 2012 Thanks very much. Will try it tomorrow. I guess there is no default option I can set to turn it off so it would be eliminated on everyone's machine that run the program?
John Posted July 2, 2012 Posted July 2, 2012 The registry key associatted with these sounds is at: HKEY_CURRENT_USERAppEventsSchemesApps The offensive sound in this case is at: HKEY_CURRENT_USERAppEventsSchemesApps.Default.Default.Current You can store this value during program startup, delete it, and restore it on exit. It does run the risk of losing their sound setting in an abnormal program closure. No great loss for me, but some people might not like it.
WesleyThomas Posted July 3, 2012 Author Posted July 3, 2012 Thats great, just tested and it works. Thank you very much. You have saved me hours of trolling! It seemed the sort of problem that would have a straight forward setting option to resolve it but I guess I would have found it long ago if so. Thanks again for the help
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