Sign in to follow this  
Followers 0
chiners_68

How to Exit script if 3rd party app closes???

4 posts in this topic

Hi All,

ive wrote the following script which uses SoundRecorder in Windows 7. How & what would I add to the script to close, if Sound recorder is closed?

Script Function:

Sound Recorder v1.2

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

#include <GUIConstants.au3>

Run(@WindowsDir & "\system32\SoundRecorder.exe", "", @SW_SHOWNORMAL)

WinWaitActive("Save As", "")

WinSetState("Save As", "", @SW_HIDE)

ControlSend("Save As", "", 1001, "\\wi102-st01\e$\test\" & @UserName & " " & @YEAR & "-" & @MON & "-" & @MDAY & " " & @HOUR & "." & @MIN & "." & @SEC)

ControlClick("Save As", "", 1)

WinActivate("Sound Recorder", "")

WinClose("Sound Recorder", "")

;*******************************************************************************

;Completion Notice

;*******************************************************************************

Opt("GUIOnEventMode", 1) ; Change to OnEvent mode

$started = 1

$mainwindow = GUICreate("Sound Recorder", 210, 110)

GUICtrlCreateLabel("Recording saved to tutor", 42, 28)

$btnExit = GUICtrlCreateButton("OK", 70, 70, 65)

GUISetOnEvent($GUI_EVENT_CLOSE, "_Terminate")

GUICtrlSetOnEvent($btnExit, "_Terminate")

GUISetState(@SW_SHOW)

While 1

for $i = 5 to 1 Step -1

GUICtrlSetData($btnExit,"OK (" & $i & ")")

Sleep(1000)

Next

If $started Then

GUIDelete($mainwindow)

EndIf

Exit

WEnd

Func _Terminate()

$started = 0

Exit

EndFunc

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

in your while loop do a if not processexists("3rdparty.exe") then exit

Edited by gcue

Share this post


Link to post
Share on other sites

Like this

While 1

for $i = 5 to 1 Step -1

GUICtrlSetData($btnExit,"OK (" & $i & ")")

Sleep(1000)

Next

if not processexists("SoundRecorder.exe") then Exit

Next

If $started Then

GUIDelete($mainwindow)

EndIf

Exit

WEnd

Func _Terminate()

$started = 0

Exit

EndFunc

Share this post


Link to post
Share on other sites

Like this

While 1

for $i = 5 to 1 Step -1

GUICtrlSetData($btnExit,"OK (" & $i & ")")

Sleep(1000)

Next

if not processexists("SoundRecorder.exe") then Exit

Next

If $started Then

GUIDelete($mainwindow)

EndIf

Exit

WEnd

Func _Terminate()

$started = 0

Exit

EndFunc

Maybe...

While 1
    for $i = 5 to 1 Step -1
        GUICtrlSetData($btnExit,"OK (" & $i & ")")
        Sleep(1000)
    Next

    If $started AND Not ProcessExists("SoundRecorder.exe")  Then
        GUIDelete($mainwindow)
        Exit
    EndIf

WEnd
Func _Terminate()
    $started = 0
    Exit
EndFunc

EndFuncAutoIt is the shiznit. I love it.

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