Sign in to follow this  
Followers 0
WesleyThomas

Keys are getting annoying now!

9 posts in this topic

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

Share this post


Link to post
Share on other sites



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

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

Like the beep you get when a Messagebox appears

Share this post


Link to post
Share on other sites

Oh, it's an event generated beep, defined in the registry. I'll set a sound profile and trace it.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
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
Sign in to follow this  
Followers 0