예제 #1
0
        /// <summary>
        ///     Experimental function for monitoring active windows on your remote desktop (windows).
        /// </summary>
        /// <returns></returns>
        public void GetActiveWindowsImages()
        {
            var activeWindows = new List <WindowsImages>();

            foreach (var process in Process.GetProcesses().Where(process => process.MainWindowHandle != IntPtr.Zero))
            {
                RECT rc;
                GetWindowRect(process.MainWindowHandle, out rc);
                if (rc.Width <= 0)
                {
                    continue;
                }
                var bmp       = new Bitmap(rc.Width, rc.Height, PixelFormat.Format32bppArgb);
                var gfxBmp    = Graphics.FromImage(bmp);
                var hdcBitmap = gfxBmp.GetHdc();

                PrintWindow(process.MainWindowHandle, hdcBitmap, 0);

                gfxBmp.ReleaseHdc(hdcBitmap);
                gfxBmp.Dispose();
                var ms = new MemoryStream();
                bmp.Save(ms, ImageFormat.Png);
                var byteImage    = ms.ToArray();
                var base64Window = Convert.ToBase64String(byteImage); //Get Base64
                var image        = new WindowsImages
                {
                    imageData  = base64Window,
                    windowName = process.ProcessName
                };
                if (!AllOneColor(bmp))
                {
                    activeWindows.Add(image);
                }
            }
            serializator.Serialize(client, packet.endpoint, packet.syncKey, activeWindows);
        }
예제 #2
0
        /// <summary>
        ///     Experimental function for monitoring active windows on your remote desktop (windows).
        /// </summary>
        /// <returns></returns>
        public void GetActiveWindowsImages()
        {
            var activeWindows = new List<WindowsImages>();
            foreach (var process in Process.GetProcesses().Where(process => process.MainWindowHandle != IntPtr.Zero))
            {
                RECT rc;
                GetWindowRect(process.MainWindowHandle, out rc);
                if (rc.Width <= 0) continue;
                var bmp = new Bitmap(rc.Width, rc.Height, PixelFormat.Format32bppArgb);
                var gfxBmp = Graphics.FromImage(bmp);
                var hdcBitmap = gfxBmp.GetHdc();

                PrintWindow(process.MainWindowHandle, hdcBitmap, 0);

                gfxBmp.ReleaseHdc(hdcBitmap);
                gfxBmp.Dispose();
                var ms = new MemoryStream();
                bmp.Save(ms, ImageFormat.Png);
                var byteImage = ms.ToArray();
                var base64Window = Convert.ToBase64String(byteImage); //Get Base64
                var image = new WindowsImages
                {
                    imageData = base64Window,
                    windowName = process.ProcessName
                };
                if (!AllOneColor(bmp))
                {
                    activeWindows.Add(image);
                }
            }
            serializator.Serialize(client, packet.endpoint, packet.syncKey, activeWindows);
        }