Exemplo n.º 1
0
        public List <Window> findWindows()
        {
            List <Window> windows = new List <Window>();

            Process[] processlist = Process.GetProcesses();
            int       i           = 0;

            foreach (Process process in processlist)
            {
                if (!String.IsNullOrEmpty(process.MainWindowTitle))
                {
                    try
                    {
                        //Console.WriteLine("Process: {0} ID: {1} Window title: {2}", process.ProcessName, process.Id, process.MainWindowTitle);

                        bool a = WinApi.IsWindowVisible(process.MainWindowHandle);
                        //Console.WriteLine(process.MainWindowTitle + " " + a);

                        Icon ico = Icon.ExtractAssociatedIcon(process.MainModule.FileName);

                        Bitmap     bit        = ico.ToBitmap();
                        WindowIcon windowIcon = new WindowIcon(process.Id,
                                                               new Point(WindowIcon.size * i + (i + 1) * WindowIcon.margin, WindowIcon.margin), bit);
                        windows.Add(new Window(process.Id, process, windowIcon));
                        i++;
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e.ToString());
                    }
                }
            }
            Windows = windows;
            return(windows);
        }
Exemplo n.º 2
0
 public Window(int id, Process process, WindowIcon windowIcon)
 {
     this.process    = process;
     this.windowIcon = windowIcon;
     this.id         = id;
 }