应用程序运行时最小化所有正在运行的窗口

时间:2012-12-04 16:53:03

标签: c# minimize

我正在开发一个C#windows窗体应用程序。如何在我的网络摄像头检测到超过2个面孔的情况下编辑我的代码。

更多信息:

当“FaceDetectedLabel.Text =”检测到面部时:“+ cam.facesdetected.ToString();”变为检测到面部:2 或更多......

我如何做到以下几点:

  • 最小化除我的应用程序以外的所有程序运行。

这是我的代码:

namespace PBD
{
    public partial class MainPage : Form
    {
        //declaring global variables
        private Capture capture;        //takes images from camera as image frames

        public MainPage()
        {
            InitializeComponent();
        }

        private void ProcessFrame(object sender, EventArgs arg)
        {
            Wrapper cam = new Wrapper();

            //show the image in the EmguCV ImageBox
            WebcamPictureBox.Image = cam.start_cam(capture).Resize(390, 243, Emgu.CV.CvEnum.INTER.CV_INTER_CUBIC).ToBitmap();
            FaceDetectedLabel.Text = "Faces Detected : " + cam.facesdetected.ToString();
        }

        private void MainPage_Load(object sender, EventArgs e)
        {

            #region if capture is not created, create it now
            if (capture == null)
            {
                try
                {
                    capture = new Capture();
                }
                catch (NullReferenceException excpt)
                {
                    MessageBox.Show(excpt.Message);
                }
            }
            #endregion

            Application.Idle += ProcessFrame;
        }

1 个答案:

答案 0 :(得分:3)

查看这篇文章:

How to programmatically minimize opened window folders

您必须枚举所有进程并排除当前进程(您的进程)而不是获取“资源管理器”进程。我建议还要进行异常处理和一些检查,因为并非所有进程都有窗口要最小化

这篇文章也适用于注销部分:

Log off user from Win XP programmatically in C#