Jump to content

Recommended Posts

Posted

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

Posted

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
Posted

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?

Posted

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.

Posted

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?

Posted

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.

Posted

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

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
  • Recently Browsing   0 members

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