Code : Tout sélectionner
#NoTrayIcon
#include <array.au3>
#include <file.au3>
#include<Constants.au3>
#include<GUIConstantsEx.au3>
#include<WindowsConstants.au3>
#include <MMBLib.au3>
#include <WinAPI.au3>
; Déclaration des variables
Global $send, $StopBatch, $Stopsend
; Change into the WinTitleMatchMode that supports classnames and handles
AutoItSetOption("WinTitleMatchMode", 4)
AutoItSetOption("WinSearchChildren", 1)
; get the string from commandline
#$cmd = 'MMBTitle||50||10||"C:\Program Files (x86)\RipBot264\tools\avs2yuv\pipebuf.exe" "C:\Program Files (x86)\RipBot264\tools\avs2yuv\avs2yuv.exe" "D:\temp\RipBot264temp\job1\job1.avs" - : "C:\Program Files (x86)\RipBot264\tools\x264\x264_x64.exe" --pass 1 --bitrate 852 --stats "D:\temp\RipBot264temp\job1\job1.stats" --fps 50 --force-cfr --min-keyint 50 --keyint 500 --frames 2000 --sar 1:1 --level 4.0 --aud --nal-hrd vbr --vbv-bufsize 25000 --vbv-maxrate 25000 --filter 0,0 --ref 3 --bframes 3 --b-adapt 2 --b-pyramid none --subme 7 --aq-mode 1 --trellis 2 --partitions all --me umh --stdin y4m --output "D:\temp\RipBot264temp\video.264" - : 2 '
$cmd = $CmdLine[1]
#MsgBox(0, "cmd is:", $cmd)
; Atribute variables from MMB
$CmdVar = StringSplit($cmd, "||", 1)
$MMBTitle = StringSplit($CmdVar[1], "||")
$MMBTitle = $MMBTitle[1]
$AutoItTimer = StringSplit($CmdVar[2], "||")
$AutoItTimer = $AutoItTimer[1]
$StopBatch = StringSplit($CmdVar[3], "||")
$StopBatch = $StopBatch[1]
$cmd = StringSplit($CmdVar[4], "||")
$cmd = $cmd[1]
#MsgBox(0, "MMBTitle is:", $MMBTitle)
#MsgBox(0, "AutoIt Timer is:", $AutoItTimer)
#MsgBox(0, "Stop Batch is:", $StopBatch)
#MsgBox(0, "cmd is:", $cmd)
SendScriptMMB($MMBTitle, "Status$='Starting...'")
Local $Stream = Run(@ComSpec & ' /c "' & $cmd & '"', @SystemDir, @SW_SHOW, $STDERR_CHILD + $STDOUT_CHILD)
Sleep(1000)
Local $line
SendScriptMMB($MMBTitle, "Status$='Running...'")
While 1
$line = StdoutRead($Stream)
If @error Then ExitLoop
; Get the handle of a cmd.exe window (from its classname)
$ConsoleWindowClass = WinGetTitle("classname=ConsoleWindowClass", "")
$ConsoleWindowClass = stringreplace($ConsoleWindowClass,@LF,"")
SendScriptMMB($MMBTitle, "Title$='" & $ConsoleWindowClass & "'")
; End of Get the handle of a cmd.exe window (from its classname)
If $line <>'' Then
$line = stringreplace($line,"'","'+l$+'")
#$line = stringreplace($line,@CR,"'+CR$+'")
#$line = stringreplace($line,@LF,"'+LF$+'")
$line = stringreplace($line,@CRLF,"'+CRLF$+'")
If $StopBatch = 1 then
If $Stopsend < 1 then
$Stopsend = 1
$line = stringreplace($line,@CR,"") ; Supression des Retours Chariot pour avoir une seule ligne à supprimer
#$line = stringreplace($line,@CR,"à éffacer" & @CR)
$send = $send & $line
$Lensend=StringLen($send)
##########################################
$text='CRLF'
$len_text=StringLen($text)
$contenu=$line
;méthode regexp
$resul=StringRegExp($contenu,"(?i)"&$text,3)
If IsArray($resul) Then
$occurence=UBound($resul)
Else
$occurence=0
EndIf
$location = StringInStr( $send, $text, 0, $occurence)
MsgBox(0,"résultat",$text&" a été trouvé "&$occurence&" fois, la partie à supprimer est de: "&$location&" à "&$Lensend)
##########################################
$Lensend=StringLen($send)
MsgBox(0, "send is:", $send)
SendScriptMMB($MMBTitle, "Batch$='" & $send & "'")
EndIf
SendScriptMMB($MMBTitle, "LastLine$='" & $line & "'")
Else
$send = $send & $line
SendScriptMMB($MMBTitle, "Batch$='" & $send & "'")
SendScriptMMB($MMBTitle, "LastLine$='" & $line & "'")
EndIf
EndIf
Sleep($AutoItTimer)
Wend
SendScriptMMB($MMBTitle, "Status$='Done...'")