Ace08 Posted May 18, 2011 Share Posted May 18, 2011 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 Work smarter not harder.My First Posted Script: DataBase Link to comment Share on other sites More sharing options...
Tankbuster Posted May 18, 2011 Share Posted May 18, 2011 (edited) 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 May 18, 2011 by Tankbuster Link to comment Share on other sites More sharing options...
hannes08 Posted May 18, 2011 Share Posted May 18, 2011 (edited) 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. Edited May 18, 2011 by Hannes123 Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler] Link to comment Share on other sites More sharing options...
UEZ Posted May 18, 2011 Share Posted May 18, 2011 Try this:expandcollapse popup;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) EndFuncBeep Sound Heavy Asia by AZJIOBr,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 More sharing options...
monoscout999 Posted May 18, 2011 Share Posted May 18, 2011 I never used but i think adlibregister() do the job for doing some function while the script still running in another thing... like UEZ example Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 18, 2011 Moderators Share Posted May 18, 2011 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) EndFuncI hope it helps. M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Ace08 Posted May 19, 2011 Author Share Posted May 19, 2011 (edited) 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. i was unfamiliar with adlib thanks Melba23 for the example Edited May 19, 2011 by Ace08 Work smarter not harder.My First Posted Script: DataBase Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now