1

How do I run python inside an HTA application.

OS = 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>

That is my code for now. The vbscript and jscript works. But the python code does not seem to run. When I click on on b2 i get an error saying "the value of the property d1 is null or undefined."

Jazz
  • 639
  • 1
  • 11
  • 28
  • Did you install ActivePython as administrator? –  Mar 17 '16 at 17:39
  • Ya. I mean there is only 1 user on the system. – Jazz Mar 17 '16 at 17:52
  • 1
    Have a look at this answer and see if it helps: http://stackoverflow.com/questions/7637210/getting-activepython-to-work-with-wsh –  Mar 17 '16 at 21:20
  • I just tried it. That did not work too. But now, after installing PyWin32 the HTA file itself does not open. – Jazz Mar 18 '16 at 05:46
  • It worked! I had ActivePython 2.7 so i got the Pywin32 that was meant for 2.7 but it did not work. I uninstalled activePython and installed Python 2.7 but that too did not work. I then uninstalled Python 2.7 and that corresponding Pywin. I installed Python 3.5.1 and the corresponding Pywin32 and it works. :) Thank you Martin. – Jazz Mar 18 '16 at 06:37

1 Answers1

0

The reason is because Python has no alert() function.

Other than that, it should work.

Red
  • 26,798
  • 7
  • 36
  • 58
Da Mammoth
  • 19
  • 6