Attribute VB_Name = "Aplicacion"
Option Explicit

Private Type AppConfig
Rutaffmpeg As String
Rutaffplay As String
Rutaffprobe As String
Rutacdda2wav As String
RutaYouTubedl As String
NombreLenguaje As String
FEIniciarListas As Byte
FE_FFAEncodersList() As String
FE_FFVEncodersList() As String
FE_FFSEncodersList() As String
FE_FFADecodersList() As String
FE_FFVDecodersList() As String
FE_FFSDecodersList() As String
FE_FFMuxersList() As String
FE_FFDemuxersList() As String
FE_FFInputPxFmt() As String
FE_FFOutputPxFmt() As String
Conv_2Pases As Byte
Conv_Eliminar As Byte
Conv_Reemplazar As Byte
GrabBufer As String
Conv_QuitarConv As Byte
ArchivosAConvertirCount As Integer
ArchivosAConvertir() As String
ArchivosMap() As String
OutDir As String
OutFile As String
SaveAsOpt As Byte
OutputFormat As String
OutputEdit As String
OutputExtension As String
LastDirExplored As String
EnableThreading As Byte
ytdl_BSize As Integer
ytdl_VCert As Byte
ytdl_outDir As String
ytdl_inURL As String
ytdl_cmd As String
ytdl_QIndex As Byte
ytdl_FmtSp As String
ytdl_plItems As String
ytdl_plItemsEnable As Byte
ytdl_OutFileName As String
ytdl_OutFileNameEnable As Byte
ytdl_cmdEnable As Byte
ytdl_IgnErr As Byte
End Type

Public OutDir As String
Public OutFile As String
Public InFiles() As String
Public InFilesMap() As String
Public InFilesCount As Integer
Public OutputFormat As String
Public OutputEdit As String

Public FormPosX As Single
Public FormPosY As Single

Public Sub AddInFiles()
Dim Files() As String, i As Integer
Files = APIS.OpenFileDialog("", Form1.hWnd, vbNullString, "", True, 4096)
If Files(1) = "" Then Exit Sub
InFilesCount = InFilesCount + UBound(Files)
ReDim Preserve InFiles(1 To InFilesCount)
ReDim Preserve InFilesMap(1 To InFilesCount)
For i = 1 To UBound(Files)
InFiles(InFilesCount - UBound(Files) + i) = Files(i)
Next
RefreshInListBox
End Sub

Public Sub QuitInFiles()
Dim SelIndex As Integer, i As Integer
SelIndex = Form1.List1.ListIndex + 1
If SelIndex = 0 Then Exit Sub
If SelIndex < InFilesCount Then
For i = SelIndex To InFilesCount - 1
InFiles(i) = InFiles(i + 1)
InFilesMap(i) = InFilesMap(i + 1)
Next
End If
InFilesCount = InFilesCount - 1
If InFilesCount > 0 Then
ReDim Preserve InFiles(1 To InFilesCount)
ReDim Preserve InFilesMap(1 To InFilesCount)
RefreshInListBox
Else
Erase InFiles
Erase InFilesMap
RefreshInListBox
End If
End Sub

Public Sub RefreshInListBox()
Dim IndexSel As Integer, i As Integer
IndexSel = Form1.List1.ListIndex
Form1.List1.Clear
If InFilesCount = 0 Then Exit Sub
For i = 1 To InFilesCount
Form1.List1.AddItem InFiles(i)
Next
If IndexSel > -1 And Form1.List1.ListCount > 0 Then
If IndexSel < Form1.List1.ListCount Then Form1.List1.ListIndex = IndexSel Else Form1.List1.ListIndex = Form1.List1.ListCount - 1
End If
End Sub

Public Function CrearDirectorioTemporal(Optional InformarError As Byte = 0) As String
Dim TempPath As String
TempPath = App.Path & "\appfiles\temp\temp"
TempPath = ScriptObj.ResolverConflictoDeNombres(TempPath)
If ScriptObj.CrearArbol(TempPath) = True Then
CrearDirectorioTemporal = TempPath
Else
If InformarError = 1 Then Lang.MsgCanotCreateDir (TempPath)
End If
End Function

Public Sub CargarAppConfig()
Dim Configuracion As AppConfig, NumArchivo As Integer
If ScriptObj.ExisteArchivo(App.Path & "\appfiles\config.lcf") = False Then Exit Sub
NumArchivo = FreeFile
On Error GoTo ErrH
Open App.Path & "\appfiles\config.lcf" For Binary As NumArchivo
Get NumArchivo, , Configuracion
Close NumArchivo
With Configuracion
Form1.Conv_Opt_2pass.Checked = (.Conv_2Pases = 1)
Form1.Conv_Opt_DelFiles.Checked = (.Conv_Eliminar = 1)
Form1.Conv_Opt_Reemplazar.Checked = (.Conv_Reemplazar = 1)
Form1.Conv_Opt_EnableThreading.Checked = (.EnableThreading = 1)
FormatEdit.FFAEncodersList = .FE_FFAEncodersList
FormatEdit.FFVEncodersList = .FE_FFVEncodersList
FormatEdit.FFSEncodersList = .FE_FFSEncodersList
FormatEdit.FFADecodersList = .FE_FFADecodersList
FormatEdit.FFVDecodersList = .FE_FFVDecodersList
FormatEdit.FFSDecodersList = .FE_FFSDecodersList
FormatEdit.FFMuxersList = .FE_FFMuxersList
FormatEdit.FFDemuxersList = .FE_FFDemuxersList
FormatEdit.FFInputPxFmt = .FE_FFInputPxFmt
FormatEdit.FFOutputPxFmt = .FE_FFOutputPxFmt
FormatEdit.IniciarListasValS = .FEIniciarListas
Grabador.realTBuffSize = .GrabBufer
Lang.LangName = .NombreLenguaje
cdrtools.cdda2wavPath = CompletarRuta(.Rutacdda2wav)
ffmpeg.ffmpegPath = CompletarRuta(.Rutaffmpeg)
ffmpeg.ffplayPath = CompletarRuta(.Rutaffplay)
ffmpeg.ffprobePath = CompletarRuta(.Rutaffprobe)
VideoDownloader.YouTubeDLPath = CompletarRuta(.RutaYouTubedl)
Form1.CnvOpt_QuitarConv.Checked = (.Conv_QuitarConv = 1)
InFilesCount = .ArchivosAConvertirCount
InFiles = .ArchivosAConvertir
InFilesMap = .ArchivosMap
Call RefreshInListBox
OutDir = .OutDir
OutFile = .OutFile
OutputFormat = .OutputFormat
OutputEdit = .OutputEdit
Form1.Combo2.Tag = .OutputExtension
Form1.Combo1.ListIndex = .SaveAsOpt
APIS.LastDirExplore = .LastDirExplored

VideoDownloader.BufferSizeValue = .ytdl_BSize
VideoDownloader.DownloadDir = .ytdl_outDir
VideoDownloader.CalidadIndex = .ytdl_QIndex
VideoDownloader.DownloadURL = .ytdl_inURL
VideoDownloader.FormatoEspecificado = .ytdl_FmtSp
VideoDownloader.VlCertificado = .ytdl_VCert
VideoDownloader.ComandosAdicionales = .ytdl_cmd
VideoDownloader.ItemsPlayList = .ytdl_plItems
VideoDownloader.HabilitarItemsPlayList = .ytdl_plItemsEnable
VideoDownloader.NombreArchivoSalida = .ytdl_OutFileName
VideoDownloader.EspecificarNombreArchivoSalida = .ytdl_OutFileNameEnable
VideoDownloader.HabilitarComandosAdicionales = .ytdl_cmdEnable
VideoDownloader.IgnorarErrores = .ytdl_IgnErr

End With
Exit Sub
ErrH:
Lang.MsgCantFileRead ("config.lcf")
End Sub

Public Sub GuardarAppConfig()
Dim Configuracion As AppConfig, NumArchivo As Integer
With Configuracion
If Form1.Conv_Opt_2pass.Checked = True Then .Conv_2Pases = 1 Else .Conv_2Pases = 0
If Form1.Conv_Opt_DelFiles.Checked = True Then .Conv_Eliminar = 1 Else .Conv_Eliminar = 0
If Form1.Conv_Opt_Reemplazar.Checked = True Then .Conv_Reemplazar = 1 Else .Conv_Reemplazar = 0
If Form1.Conv_Opt_EnableThreading.Checked = True Then .EnableThreading = 1 Else .EnableThreading = 0
.FE_FFAEncodersList = FormatEdit.FFAEncodersList
.FE_FFVEncodersList = FormatEdit.FFVEncodersList
.FE_FFSEncodersList = FormatEdit.FFSEncodersList
.FE_FFADecodersList = FormatEdit.FFADecodersList
.FE_FFVDecodersList = FormatEdit.FFVDecodersList
.FE_FFSDecodersList = FormatEdit.FFSDecodersList
.FE_FFMuxersList = FormatEdit.FFMuxersList
.FE_FFDemuxersList = FormatEdit.FFDemuxersList
.FE_FFInputPxFmt = FormatEdit.FFInputPxFmt
.FE_FFOutputPxFmt = FormatEdit.FFOutputPxFmt
.FEIniciarListas = FormatEdit.IniciarListasValS
.GrabBufer = Grabador.realTBuffSize
.NombreLenguaje = Lang.LangName
.Rutacdda2wav = Replace(cdrtools.cdda2wavPath, App.Path, "", , , vbTextCompare)
.Rutaffmpeg = Replace(ffmpeg.ffmpegPath, App.Path, "", , , vbTextCompare)
.Rutaffplay = Replace(ffmpeg.ffplayPath, App.Path, "", , , vbTextCompare)
.Rutaffprobe = Replace(ffmpeg.ffprobePath, App.Path, "", , , vbTextCompare)
.RutaYouTubedl = Replace(VideoDownloader.YouTubeDLPath, App.Path, "", , , vbTextCompare)
If Form1.CnvOpt_QuitarConv.Checked Then .Conv_QuitarConv = 1 Else .Conv_QuitarConv = 0
.ArchivosAConvertir = InFiles
.ArchivosMap = InFilesMap
.ArchivosAConvertirCount = InFilesCount
.OutDir = OutDir
.OutFile = OutFile
.SaveAsOpt = Form1.Combo1.ListIndex
Call ValidarOutFmt
Call ValidarOutEdit
.OutputFormat = OutputFormat
.OutputEdit = OutputEdit
If LCase(Form1.Combo2.Text) = LCase("<" & Lang.PerfilName_Automatic & ">") Then .OutputExtension = vbCrLf Else .OutputExtension = Form1.Combo2.Text
.LastDirExplored = APIS.LastDirExplore

.ytdl_BSize = VideoDownloader.BufferSizeValue
.ytdl_outDir = VideoDownloader.DownloadDir
.ytdl_QIndex = VideoDownloader.CalidadIndex
.ytdl_inURL = VideoDownloader.DownloadURL
.ytdl_FmtSp = VideoDownloader.FormatoEspecificado
.ytdl_VCert = VideoDownloader.VlCertificado
.ytdl_cmd = VideoDownloader.ComandosAdicionales

.ytdl_plItems = VideoDownloader.ItemsPlayList
.ytdl_plItemsEnable = VideoDownloader.HabilitarItemsPlayList
.ytdl_OutFileName = VideoDownloader.NombreArchivoSalida
.ytdl_OutFileNameEnable = VideoDownloader.EspecificarNombreArchivoSalida
.ytdl_cmdEnable = VideoDownloader.HabilitarComandosAdicionales
.ytdl_IgnErr = VideoDownloader.IgnorarErrores

End With
If ScriptObj.CrearArbol(App.Path & "\appfiles") = False Then
Lang.MsgCanotCreateDir ("appfiles")
Exit Sub
End If
Call ScriptObj.BorrarArchivo(App.Path & "\appfiles\config.lcf", True)
NumArchivo = FreeFile
On Error GoTo ErrH
Open App.Path & "\appfiles\config.lcf" For Binary As NumArchivo
Put NumArchivo, , Configuracion
Close NumArchivo
Exit Sub
ErrH:
Lang.MsgCantWriteFile ("config.lcf")
End Sub

Public Function CompletarRuta(Ruta As String) As String
If Ruta = "" Then Exit Function
If Mid(Ruta, 2, 1) <> ":" Then CompletarRuta = Replace(App.Path & "\" & Ruta, "\\", "\") Else CompletarRuta = Ruta
End Function

Public Sub InicializarAplicacion()
Dim RutaAnteriorFFmpeg As String
Call ffmpeg.FFCmdLParInicializar
Call ffmpeg.FFCmdLParEtiqInicializar
Call CargarAppConfig
Call CargarLenguaje(Lang.LangName)
If Lang.LangName = "" Then
Form1.Show
Load Form13
Form13.Show vbModal, Form1
End If
If ScriptObj.ExisteArchivo(App.Path & "\appfiles\config.lcf") = False Then
    Form1.Show
    Load Form16
    Form16.Show vbModal, Form1
    FormatEdit.IniciarListasValS = 1
End If
RutaAnteriorFFmpeg = LCase(ffmpeg.ffmpegPath)
Call Aplicacion.BuscarEjecutablesEnAppDir(ffmpeg.ffmpegPath, ffmpeg.ffprobePath, ffmpeg.ffplayPath, cdrtools.cdda2wavPath, VideoDownloader.YouTubeDLPath)
If RutaAnteriorFFmpeg <> LCase(ffmpeg.ffmpegPath) Then FormatEdit.IniciarListasValS = 1
If ffmpeg.ComprobarExistenciaFFmpeg = False Then
    Load Form9
    Form9.Show vbModal, Form1
End If
End Sub

Public Sub VerAyudaDelPrograma()
Dim NumArchivo As Integer
On Error GoTo ErrH
If ScriptObj.ExisteArchivo(App.Path & "\appfiles\doc.pdf") = False Then
If ScriptObj.CrearArbol(App.Path & "\appfiles") = False Then GoTo ErrH
NumArchivo = FreeFile
Open App.Path & "\appfiles\doc.pdf" For Binary As NumArchivo
Put NumArchivo, , LoadResData(103, "CUSTOM")
Close NumArchivo
End If
Call APIS.APIAbrirArchivo(App.Path & "\appfiles\doc.pdf")
Exit Sub
ErrH:
Lang.MsgFileNotFound ("doc.pdf")
Call ScriptObj.BorrarArchivo(App.Path & "\appfiles\doc.pdf", True)
End Sub

Public Sub ArrastrarArchivosAConvertirNew()
Call APIDragDropPaths.DragDropMatarTimer
On Error GoTo ErrH
Dim List As ListBox, i As Integer, Rutas() As String, j As Integer
Dim IsForm20Load As Byte
For i = 0 To Forms.Count - 1
    If Forms(i) Is Form20 Then
        IsForm20Load = 1
        Exit For
    End If
Next
If IsForm20Load = 1 Then Set List = Form20.List1 Else Set List = Form1.List1
For i = 1 To APIDragDropPaths.nDragDropRutas
    If ScriptObj.ExisteArchivo(APIDragDropPaths.DragDropRutas(i)) = True Then
        Aplicacion.InFilesCount = Aplicacion.InFilesCount + 1
        ReDim Preserve Aplicacion.InFiles(1 To Aplicacion.InFilesCount)
        ReDim Preserve Aplicacion.InFilesMap(1 To Aplicacion.InFilesCount)
        Aplicacion.InFiles(Aplicacion.InFilesCount) = APIDragDropPaths.DragDropRutas(i)
        List.AddItem APIDragDropPaths.DragDropRutas(i)
    Else
        Rutas = ScriptObj.ListarArchivosDeDir(APIDragDropPaths.DragDropRutas(i))
        If Rutas(1) <> "" Then
            For j = 1 To UBound(Rutas)
                Aplicacion.InFilesCount = Aplicacion.InFilesCount + 1
                ReDim Preserve Aplicacion.InFiles(1 To Aplicacion.InFilesCount)
                ReDim Preserve Aplicacion.InFilesMap(1 To Aplicacion.InFilesCount)
                Aplicacion.InFiles(Aplicacion.InFilesCount) = Rutas(j)
                List.AddItem Rutas(j)
            Next
        End If
    End If
Next
Erase APIDragDropPaths.DragDropRutas
APIDragDropPaths.nDragDropRutas = 0
Exit Sub
ErrH:
MsgBox "Error " & Err.Number & vbCrLf & Err.Description, vbCritical, Form1.Caption
End Sub

Public Sub ValidarOutFmt()
Select Case LCase(Form1.Combo3.Text)
    Case Is = vbNullString
        Form1.Combo3.Text = "<" & Lang.PerfilName_Automatic & ">"
        Aplicacion.OutputFormat = ""
    Case Is = LCase("<" & Lang.PerfilName_Automatic & ">"): Aplicacion.OutputFormat = ""
    Case Is = LCase("<" & Lang.PerfilName_Manual & ">"): Aplicacion.OutputFormat = App.Path & "\appfiles\formats\.lfm"
    Case Else: Aplicacion.OutputFormat = App.Path & "\appfiles\formats\" & Form1.Combo3.Text & ".lfm"
End Select
End Sub

Public Sub ValidarOutEdit()
Select Case LCase(Form1.Combo4.Text)
    Case Is = vbNullString
        Form1.Combo4.Text = "<" & Lang.PerfilName_Nothing & ">"
        Aplicacion.OutputEdit = ""
    Case Is = LCase("<" & Lang.PerfilName_Nothing & ">"): Aplicacion.OutputEdit = ""
    Case Is = LCase("<" & Lang.PerfilName_Manual & ">"): Aplicacion.OutputEdit = App.Path & "\appfiles\editp\.lep"
    Case Else: Aplicacion.OutputEdit = App.Path & "\appfiles\editp\" & Form1.Combo4.Text & ".lep"
End Select
End Sub

Public Sub InicializarManifest()
Dim NumArchivo As Integer, Buffer() As Variant
Dim Bytes() As Byte, i As Integer
If ScriptObj.ExisteArchivo(App.Path & "\" & App.EXEName & ".exe.manifest") = True Then Exit Sub
Buffer = Array(60, 63, 120, 109, 108, 32, 118, 101, 114, 115, 105, 111, 110, 61, 34, 49, 46, 48, 34, 32, 101, 110, 99, 111, 100, 105, 110, 103, 61, 34, 85, 84, 70, 45, 56, 34, 32, 115, 116, 97, 110, 100, 97, 108, 111, 110, 101, 61, 34, 121 _
, 101, 115, 34, 63, 62, 13, 10, 60, 97, 115, 115, 101, 109, 98, 108, 121, 32, 120, 109, 108, 110, 115, 61, 34, 117, 114, 110, 58, 115, 99, 104, 101, 109, 97, 115, 45, 109, 105, 99, 114, 111, 115, 111, 102, 116, 45, 99, 111, 109, 58 _
, 97, 115, 109, 46, 118, 49, 34, 13, 10, 109, 97, 110, 105, 102, 101, 115, 116, 86, 101, 114, 115, 105, 111, 110, 61, 34, 49, 46, 48, 34, 62, 13, 10, 60, 97, 115, 115, 101, 109, 98, 108, 121, 73, 100, 101, 110, 116, 105, 116, 121 _
, 13, 10, 32, 32, 32, 32, 110, 97, 109, 101, 61, 34, 87, 111, 111, 122, 108, 101, 46, 80, 69, 82, 101, 115, 111, 117, 114, 99, 101, 69, 120, 112, 108, 111, 114, 101, 114, 46, 88, 80, 77, 97, 110, 105, 102, 101, 115, 116, 34, 13 _
, 10, 32, 32, 32, 32, 112, 114, 111, 99, 101, 115, 115, 111, 114, 65, 114, 99, 104, 105, 116, 101, 99, 116, 117, 114, 101, 61, 34, 120, 56, 54, 34, 13, 10, 32, 32, 32, 32, 118, 101, 114, 115, 105, 111, 110, 61, 34, 49, 46, 48 _
, 46, 48, 46, 48, 34, 13, 10, 32, 32, 32, 32, 116, 121, 112, 101, 61, 34, 119, 105, 110, 51, 50, 34, 47, 62, 13, 10, 60, 100, 101, 115, 99, 114, 105, 112, 116, 105, 111, 110, 62, 87, 105, 110, 100, 111, 119, 115, 32, 83, 104 _
, 101, 108, 108, 60, 47, 100, 101, 115, 99, 114, 105, 112, 116, 105, 111, 110, 62, 13, 10, 60, 100, 101, 112, 101, 110, 100, 101, 110, 99, 121, 62, 13, 10, 32, 32, 32, 32, 60, 100, 101, 112, 101, 110, 100, 101, 110, 116, 65, 115, 115 _
, 101, 109, 98, 108, 121, 62, 13, 10, 32, 32, 32, 32, 32, 32, 32, 32, 60, 97, 115, 115, 101, 109, 98, 108, 121, 73, 100, 101, 110, 116, 105, 116, 121, 13, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 116, 121 _
, 112, 101, 61, 34, 119, 105, 110, 51, 50, 34, 13, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 110, 97, 109, 101, 61, 34, 77, 105, 99, 114, 111, 115, 111, 102, 116, 46, 87, 105, 110, 100, 111, 119, 115, 46, 67 _
, 111, 109, 109, 111, 110, 45, 67, 111, 110, 116, 114, 111, 108, 115, 34, 13, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 118, 101, 114, 115, 105, 111, 110, 61, 34, 54, 46, 48, 46, 48, 46, 48, 34, 13, 10, 32 _
, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 112, 114, 111, 99, 101, 115, 115, 111, 114, 65, 114, 99, 104, 105, 116, 101, 99, 116, 117, 114, 101, 61, 34, 120, 56, 54, 34, 13, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32 _
, 32, 32, 32, 32, 112, 117, 98, 108, 105, 99, 75, 101, 121, 84, 111, 107, 101, 110, 61, 34, 54, 53, 57, 53, 98, 54, 52, 49, 52, 52, 99, 99, 102, 49, 100, 102, 34, 13, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32 _
, 32, 32, 108, 97, 110, 103, 117, 97, 103, 101, 61, 34, 42, 34, 13, 10, 32, 32, 32, 32, 32, 32, 32, 32, 47, 62, 13, 10, 32, 32, 32, 32, 60, 47, 100, 101, 112, 101, 110, 100, 101, 110, 116, 65, 115, 115, 101, 109, 98, 108 _
, 121, 62, 13, 10, 60, 47, 100, 101, 112, 101, 110, 100, 101, 110, 99, 121, 62, 13, 10, 60, 47, 97, 115, 115, 101, 109, 98, 108, 121, 62)
ReDim Bytes(LBound(Buffer) To UBound(Buffer))
For i = LBound(Buffer) To UBound(Buffer)
Bytes(i) = Buffer(i)
Next
On Error GoTo ErrH
NumArchivo = FreeFile
Open App.Path & "\" & App.EXEName & ".exe.manifest" For Binary As NumArchivo
Put NumArchivo, , Bytes
Close NumArchivo
Exit Sub
ErrH:
Call ScriptObj.BorrarArchivo(App.Path & "\" & App.EXEName & ".exe.manifest", True)
Call Lang.MsgFileNotFound(App.EXEName & ".exe.manifest")
End Sub

Public Sub BuscarEjecutablesEnAppDir(ByRef Rutaffmpeg As String, ByRef Rutaffprobe As String, ByRef Rutaffplay As String, ByRef Rutacdda2wav As String, ByRef RutaYouTubedl As String)
Dim Rutas() As String, i As Long, Rffmpeg As String, Rffplay As String, Ryoutubedl As String
Dim Rffprobe As String, Rcdda2wav As String
If ScriptObj.ExisteArchivo(Rutaffmpeg) Then Rffmpeg = Rutaffmpeg
If ScriptObj.ExisteArchivo(Rutaffprobe) Then Rffprobe = Rutaffprobe
If ScriptObj.ExisteArchivo(Rutaffplay) Then Rffplay = Rutaffplay
If ScriptObj.ExisteArchivo(Rutacdda2wav) Then Rcdda2wav = Rutacdda2wav
If ScriptObj.ExisteArchivo(RutaYouTubedl) Then Ryoutubedl = RutaYouTubedl
If Rffmpeg <> "" And Rffplay <> "" And Rffprobe <> "" And Rcdda2wav <> "" And Ryoutubedl <> "" Then Exit Sub
Rutas = ScriptObj.ListarArchivosEnArbol(App.Path, "exe:")
If Rutas(1) = "" Then Exit Sub
For i = 1 To UBound(Rutas)
    If Rffmpeg = "" Then
        If LCase(ScriptObj.NombreBase(Rutas(i))) = "ffmpeg" Then
            Rffmpeg = Rutas(i)
            GoTo Siguiente
        End If
    End If
    If Rffplay = "" Then
        If LCase(ScriptObj.NombreBase(Rutas(i))) = "ffplay" Then
            Rffplay = Rutas(i)
            GoTo Siguiente
        End If
    End If
    If Rffprobe = "" Then
        If LCase(ScriptObj.NombreBase(Rutas(i))) = "ffprobe" Then
            Rffprobe = Rutas(i)
            GoTo Siguiente
        End If
    End If
    If Rcdda2wav = "" Then
        If LCase(ScriptObj.NombreBase(Rutas(i))) = "cdda2wav" Then
            Rcdda2wav = Rutas(i)
            GoTo Siguiente
        End If
    End If
    If Ryoutubedl = "" Then
        If LCase(ScriptObj.NombreBase(Rutas(i))) = "youtube-dl" Then Ryoutubedl = Rutas(i)
    End If
    If Rffmpeg <> "" And Rffplay <> "" And Rffprobe <> "" And Rcdda2wav <> "" And Ryoutubedl <> "" Then Exit For
Siguiente:
Next
If Rffmpeg <> "" Then Rutaffmpeg = Rffmpeg
If Rffplay <> "" Then Rutaffplay = Rffplay
If Rffprobe <> "" Then Rutaffprobe = Rffprobe
If Rcdda2wav <> "" Then Rutacdda2wav = Rcdda2wav
If Ryoutubedl <> "" Then RutaYouTubedl = Ryoutubedl
End Sub

Public Function CortarRuta(Ruta As String) As String
Dim Longitud As Long
Longitud = Len(App.Path)
If Len(Ruta) > Longitud Then
    If LCase(Left(Ruta, Longitud)) = LCase(App.Path) Then
        CortarRuta = Right(Ruta, Len(Ruta) - Longitud)
    Else
        CortarRuta = Ruta
    End If
Else
    CortarRuta = Ruta
End If
End Function
