Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; mpeg2auto.au3
- ; takes one argument - the name of the input file.
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; If you compile this to an EXE, make sure this is compiled with the Console
- ; option enabled otherwise it will not work in a batch file!
- Run("mpeg2repair.exe")
- WinWaitActive("MPEG2Repair")
- ; Track the process ID and windows handle of the mpeg2repair instance we launched - save them
- ; for later. We want to track them so that we know that any dialog boxes it pulls up belong To
- ; us.
- $hMPEG2RepairHandle = WinGetHandle("MPEG2Repair")
- $pidMPEG2Repair = WinGetProcess($hMPEG2RepairHandle)
- ; Fill in the input filename
- if $CmdLine[0] < 1 Then
- ;$ABC = "D:\Current\c-bubble\Baburu.e.go!!.Taimu.mashin.wa.doramu-shiki.2007.AAC5.1.JPN.ts"
- ;ControlSetText($hMPEG2RepairHandle, "", "[CLASS:Edit; INSTANCE:1]", $ABC)
- Exit 1
- Else
- ControlSetText($hMPEG2RepairHandle, "", "[CLASS:Edit; INSTANCE:1]", $CmdLine[1])
- EndIf
- ; Press the PID scan button - then wait for it to complete
- ControlClick($hMPEG2RepairHandle, "", "[CLASS:Button; INSTANCE:7]");
- Do
- Sleep(100)
- $StatusString = ControlGetText($hMPEG2RepairHandle, "", "[CLASS:Static; INSTANCE:9]")
- $result = StringInStr($StatusString, "100 % Completed", 0)
- Until $result > 0
- ; Check the logging option
- ControlClick($hMPEG2RepairHandle, "", "[CLASS:Button; INSTANCE:5]");
- ; Click on the Start button
- ControlClick($hMPEG2RepairHandle, "", "[CLASS:Button; INSTANCE:7]");
- ; There is a chance the user aborted us - check for this!
- if WinExists($hMPEG2RepairHandle) == 0 Then
- exit 1
- EndIf
- ; First we wait until the start button text is changed to say "Cancel".
- ; There may also be an overwrite dialog box or an error box popping up too.
- While StringInStr(ControlGetText($hMPEG2RepairHandle, "", "[CLASS:Button; INSTANCE:7]"), "CANCEL", 0) == 0
- ; We might get asked to overwrite a previously existing log - always say yes!
- $var = WinList()
- For $i = 1 to $var[0][0]
- ; we might get asked to overwrite --- search for the warning if it exists!
- ; Only answer visible windows that belong to our mpeg2repair
- If StringInStr($var[$i][0], "Warning:") AND (WinGetProcess($var[$i][1]) == $pidMPEG2Repair) Then
- ;MsgBox(0, "Details", "Title=" & $var[$i][0] & @LF & "Handle=" & $var[$i][1])
- ControlClick($var[$i][1], "", "[CLASS:Button; INSTANCE:1]")
- WinWaitClose($var[$i][1])
- EndIf
- ; check for error!
- If StringInStr($var[$i][0], "Error:") AND (WinGetProcess($var[$i][1]) == $pidMPEG2Repair) Then
- ;MsgBox(0, "Details", "Title=" & $var[$i][0] & @LF & "Handle=" & $var[$i][1])
- ControlClick($var[$i][1], "", "[CLASS:Button; INSTANCE:1]")
- WinWaitClose($var[$i][1])
- WinClose($hMPEG2RepairHandle)
- Exit 1
- EndIf
- Next
- Sleep(100)
- WEnd
- ; Wait until logging is complete
- Do
- ; There is also a chance that mpeg2repair has an error - if so, we exit and return an error code!
- $var = WinList()
- For $i = 1 to $var[0][0]
- If StringInStr($var[$i][0], "Error:") AND (WinGetProcess($var[$i][1]) == $pidMPEG2Repair) Then
- ;MsgBox(0, "Details", "Title=" & $var[$i][0] & @LF & "Handle=" & $var[$i][1])
- ControlClick($var[$i][1], "", "[CLASS:Button; INSTANCE:1]")
- WinWaitClose($var[$i][1])
- WinClose($hMPEG2RepairHandle)
- Exit 1
- EndIf
- Next
- Sleep(1000)
- $StatusString = ControlGetText($hMPEG2RepairHandle, "", "[CLASS:Static; INSTANCE:9]")
- $result = StringInStr($StatusString, "100 % Completed", 0)
- ; There is a chance the user aborted us - check for this!
- if WinExists($hMPEG2RepairHandle) == 0 Then
- Exit 1
- EndIf
- Until $result > 0
- WinClose($hMPEG2RepairHandle)
- Exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement