Sign in to follow this  
Followers 0
Garp99HasSpoken

Play sound after process ends

5 posts in this topic

I use the program mkvmergeGUI which I would like to have a sound played

after I run the program and it is done processing.

This program already exists so I can't just modify the code (yes the source is available but I don't want that).

When I click on 'Encode' button, a new window pops up to show the progress,

leaving the "OK" button unavailable until the process is done.

How can I capture that and then play a sound to let me know it's done (so I can do other things).

Is there a better way than checking for a Window title to see if it exists, and then check status of

one of its' buttons, and then play the sound?

Should this be run standalone, or have it open mkvmergeGUI and then monitor from there?

Share this post


Link to post
Share on other sites



... When I click on 'Encode' button, a new window pops up to show the progress,

leaving the "OK" button unavailable until the process is done. ...

;waits for the OK button NOT TO BE available
Do
    Sleep(99)
Until Not ControlCommand("title", "text", controlID, "IsEnabled", "")

;waits for the OK button TO BE available
Do
    Sleep(99)
Until ControlCommand("title", "text", controlID, "IsEnabled", "")

SoundPlay("filename.wav", 1)
Without seeing the application - I cannot tell you if the first Do/Sleep/Until loop is needed. You tell me :-)

[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites

Thanks for the help... it got me started and I do have it partly working but it'd not consistent

as to when the sound plays, or how it activates the window.

I am still playing around with it, but I'll let you know more later when I need more help.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

... not consistent as to when the sound plays, or how it activates the window. ...

Keep an "eye" on it:
;waits for the OK button NOT TO BE available
Do
    ToolTip("waiting for the control to be disabled", 0, 0)
    Sleep(99)
Until Not ControlCommand("title", "text", controlID, "IsEnabled", "")

;waits for the OK button TO BE available
Do
    ToolTip("waiting for the control to be enabled", 0, 0)
    Sleep(99)
Until ControlCommand("title", "text", controlID, "IsEnabled", "")

ToolTip("starting wav file", 0, 0)
SoundPlay("filename.wav", 1)
You might want to post your code. Edited by herewasplato

[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites

After quite a few fumbling around attempts, it look like I got this working now to my liking.

I ran into a problem with a

Do ... Until ControlCommand($runningTitle, "Ok", "Button3", "IsChecked")

because I thought that would exit after the user (me) clicks the Ok button, and I got "Button3" using Au3Info utility.

It would not work so I could never run another job to monitor. I had to restart my monitor script again.

Now it will loop for every new process until the mkvmergeGUI is closed.

Here's the code in full...

#cs ----------------------------------------------------------------------------


    AutoIt Version: 3.2.12.0
    Author: copyright 2008 by Garp
 
    License: GPL

    Script Function:
        Monitors progress of mmg.exe (mkvmergeGUI) when splitting files, and
        plays sound files when the monitored state has ocurred.

#ce ----------------------------------------------------------------------------


Dim $progTitle = "mkvmerge GUI"
Dim $runningTitle = "mkvmerge"
Dim $runningText = "Muxing in progress"
Dim $finished = "mkvmerge finished with a return code of 0"

; Path location for 
; Sounds used to indicate background activity
Local $sndClap = "C:\Bin\CLAP.WAV"
Local $sndLaser = "C:\Bin\LASER.WAV"
Local $sndExplode = "C:\Bin\EXPLODE.WAV"
Local $sndDrumroll = "C:\Bin\DRUMROLL.WAV"
Local $sndRicochet = "C:\Bin\RICOCHET.WAV"

$sndClap = "CLAP.WAV"
$sndLaser = "LASER.WAV"
$sndExplode = "EXPLODE.WAV"
SoundPlay($sndLaser, 1)
SoundPlay($sndClap, 1)
SoundPlay($sndExplode, 1)
Exit

; Run program, or if already running, bring to the front.
If Not WinExists($progTitle) Then
; Get Application dir 
    $dirApp = RegRead("HKEY_CURRENT_USER\SOFTWARE\mkvmergeGUI\GUI", "installation_path")
; Script starts application
    run ($dirApp & "\" & "mmg.exe")   
Else
; Activate the already running program
    WinActivate($progTitle)
EndIf
WinWaitActive($progTitle)   

While WinExists($progTitle)

;   Wait for 1 second for running process to become active
    If (WinWaitActive($runningTitle, $runningText, 1000)) Then
;       SoundPlay($sndLaser, 0)
        Do
            Sleep(99)
;       Waits for the OK button TO BE available
        Until ControlCommand($runningTitle, "", "Button3", "IsEnabled")
    EndIf

    WinActivate($runningTitle)
    If (WinWaitActive($runningTitle, $finished, 1000)) Then
        SoundPlay($sndClap, 1)
    Else
        SoundPlay($sndExplode, 1)
    Endif

    Do
        If (Not WinActivate($runningTitle))  Then ExitLoop
        Sleep(99)
;   Until ControlCommand($runningTitle, "Ok", "Button3", "IsChecked")
    Until Not WinExists($runningTitle, $finished)

;   SoundPlay($sndDrumroll, 1)
WEnd

;   SoundPlay($sndRicochet, 1)
Exit

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