我想在运行时从内部更改正在运行的 HTA 的图标(你知道,窗口左上角的小图标,运行时位于任务栏上)(所以很可能使用 VBScript或 JavaScript)。我怎样才能做到这一点?
(所以我们很清楚,因为谷歌搜索这个问题给了我所有错误的答案:我不想做的是在资源管理器中查看时更改 .hta 文件本身的图标,并且我'我不想创建任何具有特定图标的快捷方式。我想让 HTA 在运行时随时任意更改其自己的运行图标。)
感觉好像很简单,但我找不到。
我已经尝试设置(我的 HTA 应用程序对象).Icon,尽管它不会引发错误,但我什至可以读取该属性,并且它会显示新值,实际图标不会改变。
最佳答案
如有疑问,请阅读 documentation :
Remarks
Note The
icon
property is read-only; however, theICON
attribute can be used to set the initial value.
基本上,你所要求的是不可能的。
即使您可以在运行时更改属性,也不会更改标题栏中的实际图标:
<html>
<hta:application id="oHTA"
icon="C:\path\to\some.ico"
/>
<script language="VBScript">
Sub ChangeIcon
MsgBox oHTA.icon 'output: C:\path\to\some.ico
oHTA.icon = "C:\path\to\other.ico"
MsgBox oHTA.icon 'output: C:\path\to\other.ico
'icon in titlebar still remains the same, b/c only the attribute was updated!
End Sub
</script>
<body>
<p><input id="foo" type="button" value="Change Icon" onClick="ChangeIcon"></p>
</body>
</html>
关于javascript - 在 .HTA 程序中,如何更改脚本中的运行图标(VBScript 或 Javascript 都可以)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57486514/