private void ThreadRun(object arg) { if (!_running) { _running = true; while (!_exitEvent.WaitOne(0, false)) { IntPtr windowHandle = (IntPtr)arg; //Get the active window so we can translate it. Tree window = _windowCapture.CaptureWindowWithPixels(windowHandle, UsePrintWindow, false); if (window != null) { Prefab.Bitmap capture = window["capturedpixels"] as Prefab.Bitmap ; System.Drawing.Bitmap bmp = _pool.GetInstance(capture.Width, capture.Height); Bitmap.ToSystemDrawingBitmap(capture, bmp); // Get Window features Win32.WINDOWINFO windowinfo = new Win32.WINDOWINFO(true); Win32.GetWindowInfo(windowHandle, ref windowinfo); // Save as png image String filename = string.Format("{0}_f{1:D4}.png", _saveLoc.Substring(0, _saveLoc.Length - 4), frame_num); bmp.Save(@filename, ImageFormat.Png); frame_num++; if (_videoStream == null) { _videoStream = _aviManager.AddVideoStream(false, 20, bmp); } else _videoStream.AddFrame(bmp); _pool.ReturnInstance(bmp); } //Let's not melt our processor ;) Thread.Sleep(50); } _running = false; _aviManager.Close(); } }
public Tree CaptureWindowWithoutPixels(IntPtr hwnd) { Win32.WINDOWINFO windowinfo = new Win32.WINDOWINFO(true); Win32.GetWindowInfo(hwnd, ref windowinfo); return CaptureWindowWithoutPixels(hwnd, windowinfo); }
public Tree CaptureWindowWithPixels(IntPtr hwnd, bool usePrintWindow, bool fixedSize = false) { Win32.WINDOWINFO windowinfo = new Win32.WINDOWINFO(true); Win32.GetWindowInfo(hwnd, ref windowinfo); return CaptureWindow(hwnd, windowinfo, usePrintWindow, fixedSize); }
/// <summary> /// Currently determines the closest window to the cursor. /// </summary> /// <param name="hwnd"></param> /// <param name="lparams"></param> /// <returns></returns> private bool EnumWindows(IntPtr hwnd, IntPtr lparams) { Win32.WINDOWINFO windowinfo = new Win32.WINDOWINFO(true); Win32.GetWindowInfo(hwnd, ref windowinfo); Tree occurrence = CaptureWindowWithoutPixels(hwnd, windowinfo); _windows.Add(occurrence); return true; }