Simple example:
Code: Select all
html =
(
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta charset="utf-8" />
<title>HTMLFile</title>
<script>
function test() {
var canvas = document.getElementById('canvas');
var ctx = canvas.getContext('2d');
ctx.fillStyle = 'green';
ctx.fillRect(10, 10, 100, 100);
}
function setColor(__color) {
var canvas = document.getElementById('canvas');
var ctx = canvas.getContext('2d');
ctx.fillStyle = __color;
ctx.fillRect(10, 10, 100, 100);
}
</script>
</head>
<body>
<canvas id="canvas"></canvas>
</body>
</html>
)
Gui, Add, ActiveX, w400 h400 vDoc, about:<!DOCTYPE html><meta http-equiv="X-UA-Compatible" content="IE=edge">
Doc.document.Open()
Doc.document.Write(html)
Doc.document.Close()
Gui, Show
Doc.document.parentWindow.test()
return
!i::Doc.document.parentWindow.setColor("red")
@
kczx3 many thanks for sharing the idea of using canvas.
[EDIT] same as above using ahk functions:
Code: Select all
html =
(
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta charset="utf-8" />
<title>HTMLFile</title>
</head>
<body>
<canvas id="canvas"></canvas>
</body>
</html>
)
Gui, Add, ActiveX, w400 h400 vDoc, about:<!DOCTYPE html><meta http-equiv="X-UA-Compatible" content="IE=edge">
Doc.document.Open()
Doc.document.Write(html)
Doc.document.Close()
Gui, Show
canvas := Doc.document.getElementById("canvas")
init()
return
!i::setColor("red")
init() {
global canvas
ctx := canvas.getContext("2d")
ctx.fillStyle := "green"
ctx.fillRect(10, 10, 100, 100)
}
setColor(__color) {
global canvas
ctx := canvas.getContext("2d")
ctx.fillStyle := __color
ctx.fillRect(10, 10, 100, 100)
}