Es gibt keine native Windows Scripting Host-Schnittstelle für den "Speichern unter" -Dialog from what I've read. Der einfachste Weg, den ich gefunden habe, um den Dialog zu erstellen, ist das Ausleihen von .NET. PowerShell funktioniert ziemlich einfach mit .NET-Objekten. Hier ist ein Batch/Powershell Hybrid Skript, das den Dialog Speichern unter öffnet, eine Erweiterung .mp4 zwingen:
<# : batch portion
@powershell -noprofile "iex (${%~f0} | out-string)"
@exit /b
: end batch/begin PowerShell #>
add-type -as System.windows.forms
$save = New-Object Windows.Forms.SaveFileDialog
$save.initialDirectory = $pwd.path
$save.filter = "MP4 files (*.mp4)|*.mp4"
$save.ShowHelp = $true
[void]$save.ShowDialog()
$save.filename
Vor diesem Hintergrund können Sie das Skript% temp% schreiben und ausführen mit Shell.Exec(), um Erfassen Sie den STDOUT innerhalb Ihrer HTA-Skriptfunktionen. Sobald das Skript abgeschlossen ist, kann die temporäre Batchdatei gelöscht werden. Sehen Sie sich die Funktion saveDlg()
im folgenden Beispiel an.
<html>
<head>
<title>HTA Test</title>
<HTA:APPLICATION
ID="objTest"
APPLICATIONNAME="HTATest"
SCROLL="yes"
SINGLEINSTANCE="yes"
>
</head>
<textarea style="display: none" id="save_bat">
<# : batch portion
@powershell -noprofile -window hidden "iex (${%~f0} | out-string)"
@exit
: end batch/begin PowerShell #>
add-type -as System.windows.forms
$save = New-Object Windows.Forms.SaveFileDialog
$save.initialDirectory = $pwd.path
$save.filter = "MP4 files (*.mp4)|*.mp4"
$save.ShowHelp = $true
[void]$save.ShowDialog()
$save.filename
</textarea>
<script language="JavaScript">
function saveDlg() {
var fso = new ActiveXObject("Scripting.FileSystemObject"),
shell = new ActiveXObject("WScript.Shell"),
temp = shell.Environment("Process")("temp"),
batfile = fso.createTextFile(temp + "\\save.bat", true),
saveLoc;
batfile.write(document.getElementById("save_bat").value);
batfile.close();
var proc = shell.Exec(temp + "\\save.bat");
while (!proc.Status && !saveLoc) {
saveLoc = proc.StdOut.ReadLine();
proc.Terminate();
}
fso.DeleteFile(temp + "\\save.bat", 1);
return saveLoc;
}
function goBabyGo() {
var shell = new ActiveXObject("Wscript.Shell");
shell.run("h:\\tools\\ffmpeg\\bin\\ffmpeg.exe -i "
+ document.getElementById("InputTextbox").value
+ ' '
+ document.getElementById('OutputTextbox').value
);
}
</script>
<body bgcolor="buttonface">
<p><font face="verdana" color="red">VOB to MP4 Converter</font></p>
<p>
Input : <input type="file" id="InputTextbox" size="30" />
</p>
<p>
Output: <input type="text" id="OutputTextbox" size="30" readonly />
<button onclick="document.getElementById('OutputTextbox').value = saveDlg()">Save As...</button>
</p>
<p>
<input id=runbutton type="button" value="Convert!" name="run_button" onClick="goBabyGo()" />
</p>
</body>
</html>
Bitte überprüfen Sie, ob [meine Antwort] (http://stackoverflow.com/a/28672540/3439404) auf [VBScript-Datei oder einen Ordner Auswahl] (http://stackoverflow.com/q/28632270/3439404) könnte helfen? – JosefZ
Was hat das mit Batch-Dateien zu tun? – Squashman