Add an identifier like $activewid that works like $active but returns the $wid of the currently active window.

$window($active).wid won't work for that since there can be multiple windows with the same name.