How to avoid or disable windows beep/sound when GUI's edit/input field characters limit is reached
Posted: 06 Mar 2022, 05:45
Hi! Based on the code by @da_boogey_man, I modified the code to set a characters limit for the Edit field by using the limit keyword:
, but each time I'd reach the 4 characters set by the limit the windows beep would trigger, which is really annoying to me. To not have to play the windows beep anymore, I came up with this solution:
I'm sorry if this was posted before! I just thought this might be helpful to someone.
Code: Select all
#SingleInstance Ignore
Gui, Add, Edit, x10 y10 w150 limit4 gGetCount vedtType
Gui, Add, Text, x10 y+10 w150 vtxtCount
Gui, Show, Center
Return
GetCount:
GuiControlGet, myString,, edtType
nowCount := StrLen(myString)
GuiControl,, txtCount, %nowCount%/4
Return
ESC::
GuiClose:
ExitApp
Return
Code: Select all
#SingleInstance Ignore
SetKeyDelay, -1, -1
Gui, Add, Edit, x10 y10 w150 gGetCount vedtType
Gui, Add, Text, x10 y+10 w150 vtxtCount
Gui, Show, Center
Return
GetCount:
GuiControlGet, myString,, edtType
nowCount := StrLen(myString)
GuiControl,, txtCount, %nowCount%/4
If nowCount > 4
ControlSend, Edit1, {BackSpace}
Return
ESC::
GuiClose:
ExitApp
Return