Sign in to follow this  
Followers 0
LxP

Silent MsgBox()?

6 posts in this topic

Hi all,

How might I go about firing off a MsgBox() that doesn't play a sound or beep the PC speaker?

I tried doing this:

msgBox(80, "", "Does not ding")
msgBox(0, "", "Does ding")

but it seems more of a hack than anything else as I only discovered this through testing. Also it doesn't appear that I can add 80 to other values and get my desired icon. (I also found 128 to make space for an icon but not actually display one, if anyone's interested.)

Share this post


Link to post
Share on other sites



codeWizard is awesome...

#Region --- CodeWizard generated code Start ---
;MsgBox features: Title=Yes, Text=Yes, Buttons=OK and Cancel, Icon=Question
If Not IsDeclared("iMsgBoxAnswer") Then Dim $iMsgBoxAnswer
$iMsgBoxAnswer = MsgBox(33,"Test","this msg-box has no sound")
Select
   Case $iMsgBoxAnswer = 1;OK

   Case $iMsgBoxAnswer = 2;Cancel

EndSelect
#EndRegion --- CodeWizard generated code End ---

hope it helps

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

Thanks for your feedback but on my system that message box dings! :whistle:

I use a script at uni that displays a set of MsgBox()es and as they contain no sound card, they beep rather loudly via PC speaker. After about three beeps I get sneering looks from fellow students. :dance:

Share this post


Link to post
Share on other sites

Example:

#include <GuiConstants.au3>

$main = GUICreate("MyGUI", 392, 322)

$Button_1 = GUICtrlCreateButton("MessageBox", 140, 190, 70, 30)

GUISetState()
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $Button_1
            GUISetState(@SW_DISABLE, $main)
            $iMsgBoxAnswer = _MessageBox("Test", "My MessageBox",1)
            GUISetState(@SW_ENABLE, $main)
            GUISetState(@SW_SHOW)
            Select
                Case $iMsgBoxAnswer = 1;OK
                    ConsoleWrite("User selected OK" & @LF)
                Case $iMsgBoxAnswer = 2;Cancel
                    ConsoleWrite("User selected Cancel" & @LF)
                    
            EndSelect
            
        Case Else
        ;;;
    EndSelect
WEnd
Exit

Func _MessageBox($Title, $Text, $Icon)
    Local $returnValue = 1
    If $Icon < 1 Or $Icon > 4 Then $Icon = 1
    $popup = GUICreate($Title, 191, 130, -1, -1, $WS_DLGFRAME, $WS_EX_TOPMOST)
    GUICtrlCreateIcon(@SystemDir & "\user32.dll",$Icon,10,10,40,40)
    GUICtrlCreateLabel($Text, 60, 10, 180, 60)
    $Btn_OK = GUICtrlCreateButton("OK", 40, 80, 60, 20)
    $Btn_Cancel = GUICtrlCreateButton("Cancel", 110, 80, 60, 20)
    
    GUISetState()
    While 1
        $msg2 = GUIGetMsg()
        Select
            Case $msg2 = $Btn_OK
                ExitLoop
            Case $msg2 == $Btn_Cancel
                $returnValue = 2
                ExitLoop
        EndSelect
    WEnd
    GUIDelete($popup)
    Return $returnValue
EndFunc  ;==>_MessageBox

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

Wow, thanks for that code Gary. I'm surprised that Windows does not natively offer a silent Windows message box but then again, I guess message boxes are conventionally meant to be heard... :whistle:

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