Rather than messaging the active window, you should message the $chan. The active window could be a completely different chan then wanted.