Hum, i'm not sure about what you mean since you don't use the right syntax.
if ($hget($active) == $active) {
could be
var %x $hfind($active,$+($mouse.x,.*),0,w),%y $hfind($active,$+($mouse.y,.*),0,w)
You're using wildcare incorrectly here, %y should be :
$hfind($active,$+(*.,$mouse.y),0,w)
You're using %x %y but the while is based on %a
you have an /while inside an /if statement
one of your condition is a /while...
explain more precisely what you want ?