gpt4 book ai didi

vbscript - 需要使用命令提示符打开本地镜像文件的 VBScript

转载 作者:行者123 更新时间:2023-12-01 12:01:13 33 4
gpt4 key购买 nike

我需要一个 Vbscript,它可以从我的 PC 打开一个图像文件,并在几分钟后自动关闭。我计划通过命令提示符运行脚本,非常感谢任何帮助。

最佳答案

使用 HTML Application 可能更容易做到这一点而不是普通的 VBScript。这是一个示例 HTML 应用程序,它在 5 秒后自动关闭的弹出窗口中显示图像(您没有说是否需要参数化图像名称和超时,所以我假设它们是预定义的并且可以硬编码):

<html>
<hta:application id="oHTA"
border="none"
caption="no"
contextmenu="no"
innerborder="no"
scroll="no"
showintaskbar="no"
/>
<script language="VBScript">
Sub Window_OnLoad
' Resize and position the window
width = 500 : height = 400
window.resizeTo width, height
window.moveTo screen.availWidth\2 - width\2, screen.availHeight\2 - height\2

' Automatically close the windows after 5 seconds
idTimer = window.setTimeout("vbscript:window.close", 5000)
End Sub
</script>
<body>
<table border=0 width="100%" height="100%">
<tr>
<td align="center" valign="middle">
<img src="myimage.jpg"/>
</td>
</tr>
</table>
</body>
</html>

只需将此代码粘贴到文本编辑器中,用您的值替换窗口宽度和高度、超时和图像文件名,然后保存为 .HTA 文件(例如 showimage.hta)。

HTA 可以通过名称从命令行运行,例如

showimage.hta

要从 VBScript 运行 HTA,您可以使用 WshShell.Run方法:

CreateObject("WScript.Shell").Run "showimage.hta"

关于vbscript - 需要使用命令提示符打开本地镜像文件的 VBScript,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1221145/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com