Jump to content

beeping sound while gui is active


Recommended Posts

Hi there i have another problem, i wanted the script to beep while a certain gui is pressent then stop after the gui is closed. i was able to do that with the script below however it does not close at once. i know that its with the beep duration which causes the delay, question is where can i put the beep function so that after clicking the close button it will close without delay?

#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
$Message = GUICreate("", 100 ,90,-1,-1,$WS_POPUPWINDOW, Default, WinGetHandle(AutoItWinGetTitle()));Creates The GUI
$OK = GUICtrlCreateButton("OK", 10, 55, 80)
GUISetState()
while 1
Beep(4000, 200)
Beep(3200, 200)
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            GUIDelete($Message)
            Exit
        Case $OK
            Exit            
    EndSwitch
WEnd

Would appreciate your comments on this thanks :unsure:

Work smarter not harder.My First Posted Script: DataBase

Link to comment
Share on other sites

I guess this is of the beep, it looks like it does not got a option like the Soundplay or _SOUNDPLAY command.

#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#include <Sound.au3>
$Message = GUICreate("", 100 ,90,-1,-1,$WS_POPUPWINDOW, Default, WinGetHandle(AutoItWinGetTitle()));Creates The GUI
$OK = GUICtrlCreateButton("OK", 10, 55, 80)
GUISetState()
$sound = _SoundOpen("dong.wav")
while 1
    $IDSound=_SoundPlay($sound, 0)

    consolewrite("IDSound:"&$IDSound&@CRLF)

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            GUIDelete($Message)
            Exit
        Case $OK
            Exit
    EndSwitch
WEnd
_SoundClose($sound)

I do not know if this helps you, but a tested your code with a very long Beep(4000, 200000) and so the app is not reacting anymore.

So I thought maybe the wav will work. Not really solving your issue but a workaround? BTW the used DONG.WAV is copy of the "\windows\media\Windows Print complete.wav" just to use the biggest wave I got...

Edited by Tankbuster
Link to comment
Share on other sites

Well, how 'bout creating a second exe next to your program:

; Beep.exe [<duration in msec>] [<frequency>]
If $CmdLine[0] = 0 Then Beep()
If $CmdLine[0] = 1 Then Beep(500, $CmdLine[1])
If $CmdLine[0] = 2 Then Beep($CmdLine[2], $CmdLine[1])

Then you can call that Exe with Run() from your script, which will not be paused.

Maybe it's a stupid solution, but I think it works. :unsure:

Edited by Hannes123
Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler]
Link to comment
Share on other sites

Try this:

;fast hack by UEZ'11
#include <GUIConstantsEx.au3>
Global $t=1 ; tempo
Global $f=0.7 ; frequency
Global $aScores[95][4] = [ _
                                            [5,5,130], _
                                            [7,5,130], _
                                            [11,5,130], _
                                            [7,5,130], _
                                            [11,5,130], _
                                            [12,5,130], _
                                            [11,5,450,70], _
                                            [7,5,130,130], _
                                            [7,5,130], _
                                            [5,5,250,130], _
                                            [7,5,260], _
                                            [5,5,65,65], _
                                            [7,5,260], _
                                            [5,5,65,65], _
                                            [7,5,86,130], _
                                            [7,5,65,65], _
                                            [8,5,65,65], _
                                            [8,5,130,130], _
                                            [8,5,170,350], _
                                            [5,5,130], _
                                            [7,5,130], _
                                            [11,5,130], _
                                            [7,5,130], _
                                            [11,5,130], _
                                            [12,5,130], _
                                            [11,5,390], _
                                            [12,5,86], _
                                            [11,5,43], _
                                            [7,5,130,130], _
                                            [7,5,130], _
                                            [5,5,250,130], _
                                            [7,5,260], _
                                            [5,5,65,65], _
                                            [7,5,260], _
                                            [5,5,65,65], _
                                            [5,5,170,86], _
                                            [7,5,65,65], _
                                            [8,5,65,65], _
                                            [8,5,130,130], _
                                            [8,5,170,350], _
                                            [7,3,130,130], _
                                            [7,3,170,86], _
                                            [5,3,86,43], _
                                            [7,3,217,43], _
                                            [5,3,86,43], _
                                            [7,3,170,86], _
                                            [7,3,216,434], _
                                            [5,3,86,43], _
                                            [7,3,130,130], _
                                            [7,3,170,86], _
                                            [5,3,86,43], _
                                            [7,3,217,43], _
                                            [5,3,86,43], _
                                            [7,3,170,86], _
                                            [7,3,217,43], _
                                            [8,3,43,86], _
                                            [8,3,43,86], _
                                            [8,3,43,86], _
                                            [8,3,43,86], _
                                            [7,3,130,130], _
                                            [7,3,170,86], _
                                            [5,3,86,43], _
                                            [7,3,217,43], _
                                            [5,3,86,43], _
                                            [7,3,170,86], _
                                            [7,3,216,434], _
                                            [5,3,86,43], _
                                            [7,3,130,130], _
                                            [7,3,170,86], _
                                            [5,3,86,43], _
                                            [7,3,217,43], _
                                            [5,3,86,43], _
                                            [7,3,170,86], _
                                            [7,3,217,43], _
                                            [8,3,520], _
                                            [12,3,390], _
                                            [7,4,390], _
                                            [6,4,520], _
                                            [5,4,450], _
                                            [3,4,330], _
                                            [12,3,390], _
                                            [7,4,390], _
                                            [6,4,520], _
                                            [5,4,450], _
                                            [3,4,330], _
                                            [5,3,390], _
                                            [12,3,390], _
                                            [11,3,520], _
                                            [10,3,450], _
                                            [8,3,330], _
                                            [5,3,390], _
                                            [12,3,390], _
                                            [11,3,520], _
                                            [10,3,450], _
                                            [8,3,330]]

$hGUI = GUICreate("Play Beep Score", 300, 100)
$idButtonStart = GUICtrlCreateButton("Start Beep", 30, 30, 100, 40)
$idButtonStop = GUICtrlCreateButton("Stop Beep", 170, 30, 100, 40)
GUICtrlSetState(-1, $GUI_DISABLE)
GUISetState()

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            AdlibUnRegister("Play")
            GUIDelete()
            ExitLoop
        Case $idButtonStart
            AdlibRegister("Play", 200)
            GUICtrlSetState($idButtonStart, $GUI_DISABLE)
            GUICtrlSetState($idButtonStop, $GUI_ENABLE)
        Case $idButtonStop
            AdlibUnRegister("Play")
            GUICtrlSetState($idButtonStart, $GUI_ENABLE)
            GUICtrlSetState($idButtonStop, $GUI_DISABLE)
    EndSwitch
WEnd

Func Play()
    Local Static $i = 0
    _Beep($aScores[$i][0], $aScores[$i][1], $aScores[$i][2], $aScores[$i][3])
    $i += 1
    If $i = UBound($aScores) Then $i = 0
EndFunc

Func _Beep($nota, $Octave=4, $Duration=200, $pause=0)
    $Frequency=440*2^($nota/12+$Octave+1/6-4)
    Beep($Frequency*$f, $Duration/$t)
    If $pause<>0 Then Sleep($pause/$t)
EndFunc

Beep Sound Heavy Asia by AZJIO

Br,

UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

  • Moderators

Ace08,

An example using Adlib: :>

#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>

Global $fBeep = False

$Message = GUICreate("", 100 ,90,-1,-1,$WS_POPUPWINDOW, Default, WinGetHandle(AutoItWinGetTitle()));Creates The GUI
$OK = GUICtrlCreateButton("OK", 10, 55, 80)
GUISetState()

while 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            GUIDelete($Message)
            Exit
        Case $OK
            Exit
    EndSwitch

    If WinExists($Message) Then
        If Not $fBeep Then
            AdlibRegister("_Beep", 500) ; Must be longer than the total Beep time!!!!!!
            $fBeep = True
        EndIf
    Else
        AdlibUnRegister("_Beep")
        $fBeep = False
    EndIf

WEnd

Func _Beep()
    Beep(4000, 200)
    Beep(3200, 200)
EndFunc

I hope it helps. :unsure:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Wow Thanks guys for the help its now working, i was also thinking of using soundplay however ill be using this for a server PC with no speaker devices installed so i choose beep instead. :unsure:

i was unfamiliar with adlib thanks Melba23 for the example :>

Edited by Ace08

Work smarter not harder.My First Posted Script: DataBase

Link to comment
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
 Share

  • Recently Browsing   0 members

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