ever thought of $appactive ? returns true or false... if mIRC is active, do this, else, well, you get the picture