private void Timer_Tick(object sender, EventArgs e) { if (new WindowInteropHelper(this).Handle != HotKey.GetActiveWindow()) { this.timer.Stop(); this.Close(); } }