HTML应用程序(HTA)是Microsoft Windows程序,其源代码由HTML,动态HTML和Internet Explorer支持的一种或多种脚本语言(如VBScript或JScript)组成。如果您的问题是关于HTA中的脚本,请始终提及或添加使用的脚本语言的标记。
我遇到了一个问题,试图摆脱cmd弹出窗口并使命令中的所有数据出现在span标签中。我知道足以让命令正常工作,但不知道如何实现
我希望用户通过创建的输入标签提供文件夹或目录的路径,如下所示: var newinput = document.createElement('input'); newinput.type = "文件"; 新输入。
我希望用户通过创建的输入标签提供文件夹或目录的路径,如下所示: var newinput = document.createElement('input'); newinput.type = "文件"; 新输入。
也许这里有人可以帮我修改这个脚本吗?我希望文件名位于 gif 下方,并且文本大小稍小一些,以便更多的 gif 可以出现在一行中。 <p>也许这里有人可以帮我修改这个脚本吗?我希望文件名位于 gif 下方,并且文本大小稍小一些,以便更多的 gif 可以出现在一行中。</p> <pre><code><script type="text/vbs"> set fso=CreateObject("Scripting.FileSystemObject") set fldr=fso.GetFolder(".") for each file in fldr.files if lcase(right(file.name,4))=".gif" then document.write "<img src=""" & file.name & """>" document.write file.name & "&#160;&#160;&#160;&#160;&#160;&#160;" end if next </script> </code></pre> </question> <answer tick="false" vote="0"> <p>如评论中所述,您可以使用一些应用于 Div 的 CSS 并创建一个类来设置图像大小。大小可以指定为任何所需的单位。这里使用 Ems 是因为在设置不同缩放值的显示器上尺寸保持相当恒定。这是 HTA 代码:</p> <p><strong>GIFshow.hta</strong></p> <pre><code><!DOCTYPE html> <html> <head> <meta http-equiv="x-ua-compatible" content="IE=10"> <script language="VBScript"> Set oFSO = CreateObject("Scripting.FileSystemObject") Set oFolder = oFSO.GetFolder(".") For Each oFile In oFolder.Files If LCase(oFSO.GetExtensionName(oFile.Name)) = "gif" Then document.write "<div class=""image-container"">" document.write "<img class=""image"" src=""" & oFile.Name & """ alt=""" & oFile.Name & """>" document.write "<br>" & oFile.Name document.write "</div>" End If Next </script> <style> .image-container { display: inline-block; text-align: center; } .image { width: 10em; height: 10em; } </style> </head> <body> </body> </html> </code></pre> </answer> </body></html>
我需要通过命令行应用程序快速编写一个简单的 GUI。需要两个步骤: 指定输入文件路径, 指定输出文件路径(不存在) 我发现了以前的帖子,h...
BAT/HTA 混合 - 如何转义 HTML 部分中的百分号?
我正在处理批处理/HTA 混合文件,并希望向应用程序添加一些背景音乐。当我尝试将 url(包含百分号)添加到 标签时,它不会播放任何内容...
HTA VBScript:在运行时从字符串或包含字符串的变量动态创建函数,如 Javascript 中使用 new Function() 构造函数
我正在尝试学习更多的 hta 和 VBScript,我想知道 VBS 是否允许像 Javascript 中那样创建动态函数: var f = new Function('函数名', 函数体); 或者 赢...
如何将 HTA 窗口居中,使其位于屏幕中央,无论 HTA 大小的屏幕分辨率如何我有这个: Sub DoResize '不要使用 </desc> <question vote="8"> <p>如何将 HTA 窗口居中,使其位于屏幕中央,无论 HTA 大小的屏幕分辨率如何我有这个:</p> <pre><code></head> <script> Sub DoResize 'Do not use Window_Onload window.resizeTo 800,600 strComputer = "." Set objWMIService = GetObject("Winmgmts:\\" & strComputer & "\root\cimv2") Set colItems = objWMIService.ExecQuery("Select * From Win32_DesktopMonitor") For Each objItem in colItems intHorizontal = objItem.ScreenWidth intVertical = objItem.ScreenHeight Next intLeft = (intHorizontal - 800) / 2 intTop = (intVertical - 600) / 2 window.moveTo intLeft, intTop End Sub DoResize() 'Run the subroutine to position the containing window (your HTA dialog) before the body is rendered. </script> <body> </code></pre> <p>但是如果我更改屏幕分辨率,它就不起作用,并且会调整 HTA 窗口的大小。</p> <p>问题:无论屏幕分辨率的 HTA 大小如何,如何将 HTA 移动到屏幕中央。</p> </question> <answer tick="true" vote="6"> <p>为此使用 WMI 有点过分了。您可以使用 <pre><code>screen</code></pre> 对象代替:</p> <pre><code>window.resizeTo (800, 600); window.moveTo((screen.width - 800) / 2, (screen.height - 600) / 2); </code></pre> <p>如果您想在开始时调整窗口大小,请将上面的行放在 <pre><code>script</code></pre> 部分中的 (JS) <pre><code>head</code></pre> 标记中,甚至在 <pre><code><hta: application></code></pre> 标记之前,或者在事件处理程序中或任何位置使用代码需要它。</p> <p>如果您想将任务栏的高度排除在居中区域之外,可以使用 <pre><code>screen.availHeight</code></pre> 代替 <pre><code>screen.height</code></pre>。</p> </answer> <answer tick="false" vote="2"> <pre><code>var winWidth = 800, winHeight = 600; window.resizeTo(winWidth, winHeight); window.moveTo((screen.width - winWidth) / 2, (screen.height - winHeight) / 2); </code></pre> </answer> <answer tick="false" vote="0"> <p>HTA窗口</p> <blockquote> <p>`</p> </blockquote> <p></p><div data-babel="false" data-lang="js" data-hide="false" data-console="true"> <div> <pre><code><!DOCTYPE html> <html> <head> <title>File Operations</title> <hta:application id="FileOperationsHTA" applicationname="FileOperationsHTA" singleinstance="yes" maximizebutton="no" minimizebutton="no" windowstate="normal" scroll="no" navigable="yes" showintaskbar="no" contextmenu="no" selection="no" /> </head> <body onload="showFields()"> <h1>File Operations</h1> <label for="operationCombo">Select operation:</label> <select id="operationCombo" onchange="showFields()"> <option value="">Select an operation</option> <option value="move">Move</option> <option value="copy">Copy</option> <option value="delete">Delete</option> <option value="newfolder">New Folder</option> <option value="rename">Rename</option> </select> <div id="sourceField" style="display: none;"> <label for="sourcePath">Source path:</label> <input type="text" id="sourcePath" /> </div> <div id="destinationField" style="display: none;"> <label for="destinationPath">Destination path:</label> <input type="text" id="destinationPath" /> </div> <div id="deleteField" style="display: none;"> <label for="deletePath">File/Folder to delete:</label> <input type="text" id="deletePath" /> </div> <div id="newFolderField" style="display: none;"> <label for="parentPath">Parent path for new folder:</label> <input type="text" id="parentPath" /> <label for="newFolderName">New folder name:</label> <input type="text" id="newFolderName" /> </div> <div id="renameField" style="display: none;"> <label for="sourcePathRename">Source path:</label> <input type="text" id="sourcePathRename" /> <label for="destinationPathRename">Destination path:</label> <input type="text" id="destinationPathRename" /> <label for="newFileName">New filename:</label> <input type="text" id="newFileName" /> </div> <button id="executeButton" onclick="executeOperation()">Execute</button> <script type="text/javascript"> function showFields() { var operation = document.getElementById('operationCombo').value; var sourceField = document.getElementById('sourceField'); var destinationField = document.getElementById('destinationField'); var deleteField = document.getElementById('deleteField'); var newFolderField = document.getElementById('newFolderField'); var renameField = document.getElementById('renameField'); var executeButton = document.getElementById('executeButton'); sourceField.style.display = 'none'; destinationField.style.display = 'none'; deleteField.style.display = 'none'; newFolderField.style.display = 'none'; renameField.style.display = 'none'; switch (operation) { case 'move': sourceField.style.display = 'block'; destinationField.style.display = 'block'; break; case 'copy': sourceField.style.display = 'block'; destinationField.style.display = 'block'; break; case 'delete': deleteField.style.display = 'block'; break; case 'newfolder': newFolderField.style.display = 'block'; break; case 'rename': renameField.style.display = 'block'; document.getElementById('sourcePathRename').disabled = false; document.getElementById('destinationPathRename').disabled = false; document.getElementById('newFileName').disabled = false; break; } } function executeOperation() { var operation = document.getElementById('operationCombo').value; switch (operation) { case 'move': var sourcePath = document.getElementById('sourcePath').value; var destinationPath = document.getElementById('destinationPath').value; moveFilesWithWildcard(sourcePath, destinationPath); break; case 'copy': var sourcePath = document.getElementById('sourcePath').value; var destinationPath = document.getElementById('destinationPath').value; copyFilesWithWildcard(sourcePath, destinationPath); break; case 'delete': var deletePath = document.getElementById('deletePath').value; deleteFilesWithWildcard(deletePath); break; case 'newfolder': var parentPath = document.getElementById('parentPath').value; var newFolderName = document.getElementById('newFolderName').value; createNewFolder(parentPath, newFolderName); break; case 'rename': var sourcePathRename = document.getElementById('sourcePathRename').value; var destinationPathRename = document.getElementById('destinationPathRename').value; var newFileName = document.getElementById('newFileName').value; renameFile(sourcePathRename, destinationPathRename, newFileName); break; } } function renameFile(sourcePath, destinationPath, newFileName) { var fso = new ActiveXObject("Scripting.FileSystemObject"); if (fso.FileExists(sourcePath)) { try { fso.MoveFile(sourcePath, fso.BuildPath(destinationPath, newFileName)); alert('Rename operation executed.\nSource: ' + sourcePath + '\nDestination: ' + destinationPath); } catch (e) { alert('Error renaming file: ' + e.message); } } else { alert('Source file not found.'); } } function moveFilesWithWildcard(sourcePath, destinationPath) { var fso = new ActiveXObject("Scripting.FileSystemObject"); var parentFolder = fso.GetParentFolderName(sourcePath); var wildcard = fso.GetFileName(sourcePath); var parentFolderObj = fso.GetFolder(parentFolder); if (fso.FolderExists(parentFolder)) { try { var files = new Enumerator(parentFolderObj.Files); var subFolders = new Enumerator(parentFolderObj.SubFolders); var regex = new RegExp(wildcard.replace(/\./g, "\\.").replace(/\*/g, ".*"), "i"); for (; !files.atEnd(); files.moveNext()) { var file = files.item(); if (regex.test(file.Name)) { var sourceFile = fso.BuildPath(parentFolder, file.Name); var destinationFile = fso.BuildPath(destinationPath, file.Name); fso.MoveFile(sourceFile, destinationFile); } } for (; !subFolders.atEnd(); subFolders.moveNext()) { var subFolder = subFolders.item(); if (regex.test(subFolder.Name)) { var newDestPath = fso.BuildPath(destinationPath, subFolder.Name); fso.CreateFolder(newDestPath); moveFilesRecursive(subFolder, newDestPath); } } } catch (e) { alert('Error moving files/folders with wildcard.'); } } else { alert('Parent path not found.'); } } function moveFilesRecursive(folder, destinationPath) { var fso = new ActiveXObject("Scripting.FileSystemObject"); var files = new Enumerator(folder.Files); var subFolders = new Enumerator(folder.SubFolders); for (; !files.atEnd(); files.moveNext()) { var file = files.item(); var destinationFile = fso.BuildPath(destinationPath, file.Name); fso.MoveFile(file.Path, destinationFile); } for (; !subFolders.atEnd(); subFolders.moveNext()) { var subFolder = subFolders.item(); var newDestPath = fso.BuildPath(destinationPath, subFolder.Name); fso.CreateFolder(newDestPath); moveFilesRecursive(subFolder, newDestPath); } } function copyFiles(sourcePath, destinationPath) { var fso = new ActiveXObject("Scripting.FileSystemObject"); var folder = fso.GetFolder(sourcePath); if (fso.FolderExists(destinationPath)) { try { copyFilesRecursive(folder, destinationPath); alert('Copy operation executed.\nSource Path: ' + sourcePath + '\nDestination Path: ' + destinationPath); } catch (e) { alert('Error copying files/folders.'); } } else { alert('Destination path not found.'); } } function copyFilesRecursive(folder, destinationPath) { var fso = new ActiveXObject("Scripting.FileSystemObject"); var files = new Enumerator(folder.Files); var subFolders = new Enumerator(folder.SubFolders); for (; !files.atEnd(); files.moveNext()) { var file = files.item(); fso.CopyFile(file.Path, fso.BuildPath(destinationPath, file.Name), true); } for (; !subFolders.atEnd(); subFolders.moveNext()) { var subFolder = subFolders.item(); var newDestPath = fso.BuildPath(destinationPath, subFolder.Name); fso.CreateFolder(newDestPath); copyFilesRecursive(subFolder, newDestPath); } } function moveFilesWithWildcard(sourcePath, destinationPath) { var fso = new ActiveXObject("Scripting.FileSystemObject"); var parentFolder = fso.GetParentFolderName(sourcePath); var wildcard = fso.GetFileName(sourcePath); var parentFolderObj = fso.GetFolder(parentFolder); if (fso.FolderExists(parentFolder)) { try { var files = new Enumerator(parentFolderObj.Files); var subFolders = new Enumerator(parentFolderObj.SubFolders); var regex = new RegExp(wildcard.replace(/\./g, "\\.").replace(/\*/g, ".*"), "i"); for (; !files.atEnd(); files.moveNext()) { var file = files.item(); if (regex.test(file.Name)) { var sourceFile = fso.BuildPath(parentFolder, file.Name); var destinationFile = fso.BuildPath(destinationPath, file.Name); fso.MoveFile(sourceFile, destinationFile); } } for (; !subFolders.atEnd(); subFolders.moveNext()) { var subFolder = subFolders.item(); if (regex.test(subFolder.Name)) { var newDestPath = fso.BuildPath(destinationPath, subFolder.Name); fso.CreateFolder(newDestPath); moveFilesRecursive(subFolder, newDestPath); } } } catch (e) { alert('Error moving files/folders with wildcard.'); } } else { alert('Parent path not found.'); } } function moveFilesRecursive(folder, destinationPath) { var fso = new ActiveXObject("Scripting.FileSystemObject"); var files = new Enumerator(folder.Files); var subFolders = new Enumerator(folder.SubFolders); for (; !files.atEnd(); files.moveNext()) { var file = files.item(); var destinationFile = fso.BuildPath(destinationPath, file.Name); fso.MoveFile(file.Path, destinationFile); } for (; !subFolders.atEnd(); subFolders.moveNext()) { var subFolder = subFolders.item(); var newDestPath = fso.BuildPath(destinationPath, subFolder.Name); fso.CreateFolder(newDestPath); moveFilesRecursive(subFolder, newDestPath); } } function copyFilesWithWildcard(sourcePath, destinationPath) { var fso = new ActiveXObject("Scripting.FileSystemObject"); if (fso.FileExists(sourcePath)) { // Source path is a single file var sourceFolder = fso.GetParentFolderName(sourcePath); var sourceFileName = fso.GetFileName(sourcePath); if (fso.FileExists(destinationPath)) { // Destination path includes a filename, create a new folder in the destination path var destinationParentFolder = fso.GetParentFolderName(destinationPath); var newFolderName = fso.GetBaseName(destinationPath); destinationPath = fso.BuildPath(destinationParentFolder, newFolderName); } else if (!fso.FolderExists(destinationPath)) { // Destination folder does not exist, create it fso.CreateFolder(destinationPath); } // Perform the copy operation fso.CopyFile(sourcePath, fso.BuildPath(destinationPath, sourceFileName)); alert('Copy operation executed.\nSource: ' + sourcePath + '\nDestination: ' + destinationPath); } else if (fso.FolderExists(sourcePath)) { // Source path is a folder var parentFolder = fso.GetParentFolderName(sourcePath); var wildcard = fso.GetFileName(sourcePath); var parentFolderObj = fso.GetFolder(parentFolder); if (fso.FolderExists(parentFolder)) { try { var files = new Enumerator(parentFolderObj.Files); var subFolders = new Enumerator(parentFolderObj.SubFolders); var regex = new RegExp(wildcard.replace(/\./g, "\\.").replace(/\*/g, ".*"), "i"); // Collect files and folders matching the wildcard var filesToCopy = []; var foldersToCopy = []; for (; !files.atEnd(); files.moveNext()) { var file = files.item(); if (regex.test(file.Name)) { filesToCopy.push(file); } } for (; !subFolders.atEnd(); subFolders.moveNext()) { var subFolder = subFolders.item(); if (regex.test(subFolder.Name)) { foldersToCopy.push(subFolder); } } // Perform the copy operation if (!fso.FolderExists(destinationPath)) { // Destination folder does not exist, create it fso.CreateFolder(destinationPath); } for (var i = 0; i < filesToCopy.length; i++) { var file = filesToCopy[i]; file.Copy(fso.BuildPath(destinationPath, file.Name)); } for (var i = 0; i < foldersToCopy.length; i++) { var folder = foldersToCopy[i]; copyFolderRecursive(folder, fso.BuildPath(destinationPath, folder.Name)); } alert('Copy operation executed.\nSource: ' + sourcePath + '\nDestination: ' + destinationPath); } catch (e) { alert('Error copying files/folders with wildcard: ' + e.message); } } else { alert('Source parent path not found.'); } } else { alert('Source path not found.'); } } function copyFolderRecursive(sourceFolder, destinationFolder) { var fso = new ActiveXObject("Scripting.FileSystemObject"); fso.CreateFolder(destinationFolder); var files = new Enumerator(sourceFolder.Files); var subFolders = new Enumerator(sourceFolder.SubFolders); for (; !files.atEnd(); files.moveNext()) { var file = files.item(); file.Copy(fso.BuildPath(destinationFolder, file.Name)); } for (; !subFolders.atEnd(); subFolders.moveNext()) { var subFolder = subFolders.item(); copyFolderRecursive(subFolder, fso.BuildPath(destinationFolder, subFolder.Name)); } } function createNewFolder(parentPath, newFolderName) { var fso = new ActiveXObject("Scripting.FileSystemObject"); var fullPath = fso.BuildPath(parentPath, newFolderName); try { fso.CreateFolder(fullPath); alert('New folder created successfully.\nPath: ' + fullPath); } catch (e) { alert('Error creating new folder: ' + e.message); } } function deleteFilesWithWildcard(deletePath) { var fso = new ActiveXObject("Scripting.FileSystemObject"); var parentFolder = fso.GetParentFolderName(deletePath); var wildcard = fso.GetFileName(deletePath); var parentFolderObj = fso.GetFolder(parentFolder); if (fso.FolderExists(parentFolder)) { try { var files = new Enumerator(parentFolderObj.Files); var subFolders = new Enumerator(parentFolderObj.SubFolders); var regex = new RegExp(wildcard.replace(/\./g, "\\.").replace(/\*/g, ".*"), "i"); // Collect files and folders matching the wildcard var filesToDelete = []; var foldersToDelete = []; for (; !files.atEnd(); files.moveNext()) { var file = files.item(); if (regex.test(file.Name)) { filesToDelete.push(file); } } for (; !subFolders.atEnd(); subFolders.moveNext()) { var subFolder = subFolders.item(); if (regex.test(subFolder.Name)) { foldersToDelete.push(subFolder); } } // Delete files for (var i = 0; i < filesToDelete.length; i++) { filesToDelete[i].Delete(); } // Delete folders for (var i = 0; i < foldersToDelete.length; i++) { deleteFolderRecursive(foldersToDelete[i]); } alert('Delete operation executed.\nPath: ' + deletePath); } catch (e) { alert('Error deleting files/folders with wildcard: ' + e.message); } } else { alert('Parent path not found.'); } } function deleteFolderRecursive(folder) { var fso = new ActiveXObject("Scripting.FileSystemObject"); var subFolders = new Enumerator(folder.SubFolders); for (; !subFolders.atEnd(); subFolders.moveNext()) { var subFolder = subFolders.item(); deleteFolderRecursive(subFolder); } fso.DeleteFolder(folder.Path); } </script> </body> </html></code></pre> </div> </div> <p></p> <p>`</p> </answer> <answer tick="false" vote="0"> <p>函数 logMessage(消息) { var fso = new ActiveXObject("Scripting.FileSystemObject"); var logFile = fso.OpenTextFile("file_operations.log", 8, true); // 8 用于追加</p> <pre><code> var now = new Date(); var timestamp = now.toLocaleString(); logFile.WriteLine("[" + timestamp + "] " + message); logFile.Close(); } </code></pre> </answer> </body></html>
我正在尝试在 VBScript 变量中捕获机器的 DNS 服务器地址。这将在 .hta 文件中使用。 到目前为止,我的代码如下。它返回如下所示的错误。我...
我正在写一个HTA,希望用户能够很容易地能够使用浏览器选择一个.txt文件。这个.txt文件将被逐行读取并读入一个数组。所以,我在使用
我有一个直播,我想在我的HTA应用程序上播放。我已经尝试使用这个答案。 主要的
如何在当前文件夹中的hta中使用PowerShell在子文件夹中执行.bat文件?
我正在尝试执行位于hta文件所在当前文件夹子文件夹中的.bat文件。我在这里找到了文件夹结构>>文件夹结构下面是我的.hta代码的示例&...
hta / javascript如何执行具有相对路径的应用程序
我正在建立一个.hta(使用javascript),我想从中启动几个应用程序。但是,当我执行.hta时,我收到错误消息,找不到文件,这是代码:] >>
限制/拒绝用户使用javascript在HTA中输入10个字符
我想创建一个Java脚本来设置html文本框中的输入,该输入必须是10个字母数字输入。 [ ]
在IE 11中禁止Active X警告“此页面上的Active X控件”
我有一个已在IE中运行的Oracle表单应用程序,目前我们在11上运行。它通过URL调用外部Web应用程序,该URL需要在Chrome中运行。因为在IE中启动URL会导致...
我正在尝试在Windows 10计算机上运行的HTA应用程序中使用iframe。父页面和嵌入式页面都是HTA应用程序。但是,iframe页面/应用程序始终会在新的页面中打开...
我有一个HTA应用程序,该应用程序通过ajax调用获取一些数据。我想为此使用XMLHttpRequest。这种方法给了我想要的结果,但是在...
我有以下批处理文件:powershell -Command“&{Set-ItemProperty -Path HKLM:\ SOFTWARE \ Microsoft \ Windows \ CurrentVersion \ WindowsStore \ WindowsUpdate -Name AutoDownload -Value 2 -Type DWord}” ...
我正在为孩子们制作头像游戏,我想添加一个可爱的心形光标。游标的尺寸为32x32。我正在使用HTA做到这一点。我已经做了很多次自定义游标,所以看不到...