WinBatch® Technical Support Forum

All Things WinBatch => WinBatch => Topic started by: pguild on March 17, 2022, 07:50:37 AM

Title: annoying beep
Post by: pguild on March 17, 2022, 07:50:37 AM
How do I turn off the beep that happens automatically with a pause command as in PAUSE("CONTINUE?","CLICK OK TO CONTINUE")
Title: Re: annoying beep
Post by: td on March 17, 2022, 09:31:15 AM
The "beep" is more or less something controlled by the OS. You do have several alternatives to using the "Pause" function. You could roll your own by creating a WIL Dialog, use the DllCall function to make a call to the Win32 API function "MessageBox" with parameters of your choice, or use the Box functions to create one. There are several examples of the latter in the Tech Database. Finally, you could use the WILX extender's "xMessageBox" function to configure a message box that does not "beep". The "beep" is caused by the  MB_ICONEXCLAMATION  style on many systems so don't bitwise "or" (|) the number 48 with other style parameter values.
Title: Re: annoying beep
Post by: td on March 17, 2022, 09:53:46 AM
A rough example of using DllCall to display a message box:

Code (winbatch) Select

strMsgTitle = "MessageBox test"
strMsgText = "Are you having fun?"
MB_OKCANCEL = 1
nResult = DllCall (DirWindows (1):"User32.dll", long :"MessageBoxA", long:DllHwnd (""), lpstr:strMsgText, lpstr:strMsgTitle, long:MB_OKCANCEL)
exit
Title: Re: annoying beep
Post by: pguild on March 17, 2022, 10:19:42 AM
Thanks. i rolled my own with the dialog editor and it works great.