【问题标题】:How to run python inside an HTA application如何在 HTA 应用程序中运行 python
【发布时间】:2016-03-17 16:07:06
【问题描述】:

如何在 HTA 应用程序中运行 python。

操作系统 = Windows 8.1

Python = ActivePython-2.7.10.12-win64-x64

<html>
<head>
<title>demo</title>
</head>
<body>
<form name=fom1>
<input type=button name=b1 value=add onclick=s1()><br>
<input type=button name=b2 value=add onclick=d1()><br>
<input type=button name=b3 value=add onclick=f1()><br>
</form>

<script language=vbscript>
sub s1
msgbox "from vbscript"
end sub
</script>

<script language=python>
alert("hi");

def d1():
    alert("from python");

</script>

<script language=jscript>
function f1(){
    alert("from jscript");
}
</script>
</body>
</html>

这是我现在的代码。 vbscript 和 jscript 有效。但是python代码似乎没有运行。当我单击 b2 时,我收到一条错误消息,提示“属性 d1 的值为 null 或未定义。”

【问题讨论】:

  • 您是否以管理员身份安装了 ActivePython?
  • 是的。我的意思是系统上只有 1 个用户。
  • 看看这个答案,看看它是否有帮助:stackoverflow.com/questions/7637210/…
  • 我刚试过。那也没有用。但是现在,安装 PyWin32 后,HTA 文件本身并没有打开。
  • 成功了!我有 ActivePython 2.7,所以我得到了适用于 2.7 的 Pywin32,但它不起作用。我卸载了 activePython 并安装了 Python 2.7,但这也没有用。然后我卸载了 Python 2.7 和相应的 Pywin。我安装了 Python 3.5.1 和相应的 Pywin32,它可以工作。 :) 谢谢马丁。

标签: python hta


【解决方案1】:

原因是因为Python没有alert()函数。

除此之外,它应该可以工作。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2010-11-08
    • 1970-01-01
    • 2019-11-13
    • 2020-11-16
    • 1970-01-01
    • 1970-01-01
    • 2017-11-18
    相关资源
    最近更新 更多