[System.Runtime.InteropServices.DllImport("user32")] private static extern IntPtr GetActiveWindow();//获取当前窗体的活动状态 // 判断当前窗口是否处于活动状态的方法 private bool ThisIsActive(){ return (GetActiveWindow() == this.Handle);} private void timer1_Tick(object sender, EventArgs e){ if (!ThisIsActive()){ this.Activate(); } this.WindowState = FormWindowState.Normal; }