tomar teclado pantalla mac lightshot las laptop hacer guardan donde como capturas captura c# windows winapi unity3d rdp

c# - teclado - Obtenga una captura de pantalla de escritorio en la aplicación 3D de pantalla completa



donde se guardan las capturas de pantalla windows 7 (1)

¿Es posible convertir el escritorio en una captura de pantalla cuando se utiliza una aplicación 3D a pantalla completa (como un juego)? ¿O Windows cierra el motor de renderizado mientras el juego se está ejecutando?

Estoy buscando formas de convertir el escritorio en una textura en mi juego. ¿Pueden RDP como los protocolos ser una solución?

Editar: para aclarar, ¿hay algún mecanismo de api de nivel profundo para forzar el procesamiento en otro búfer, como cuando se hacen capturas de pantalla? No importa si solo es Windows 7 o Windows 8/9.


Puede obtener una captura de pantalla llamando a la función PrintWindow Win32 API en el hWnd de la ventana del escritorio. Intenté esto con Windows 7 y Windows 8.1, funcionó incluso cuando se estaba ejecutando otra aplicación (VLC Player) en pantalla completa, por lo que existe la posibilidad de que funcione también con los juegos. Esto solo le dará la imagen del escritorio sin la barra de tareas, pero ninguna de las otras aplicaciones en ejecución visibles se mostrarán en ella. Si los necesita también, entonces necesita obtener su HWND también (por ejemplo, enumerando todos los procesos en ejecución y obteniendo su identificador de ventana) y luego use el mismo método.

using System; using System.Drawing; // add reference to the System.Drawing.dll using System.Drawing.Imaging; using System.IO; using System.Runtime.InteropServices; namespace DesktopScreenshot { class Program { static void Main(string[] args) { // get the desktop window handle without the task bar // if you only use GetDesktopWindow() as the handle then you get and empty image IntPtr desktopHwnd = FindWindowEx(GetDesktopWindow(), IntPtr.Zero, "Progman", "Program Manager"); // get the desktop dimensions // if you don''t get the correct values then set it manually var rect = new Rectangle(); GetWindowRect(desktopHwnd, ref rect); // saving the screenshot to a bitmap var bmp = new Bitmap(rect.Width, rect.Height); Graphics memoryGraphics = Graphics.FromImage(bmp); IntPtr dc = memoryGraphics.GetHdc(); PrintWindow(desktopHwnd, dc, 0); memoryGraphics.ReleaseHdc(dc); // and now you can use it as you like // let''s just save it to the desktop folder as a png file string desktopDir = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory); string screenshotPath = Path.Combine(desktopDir, "desktop.png"); bmp.Save(screenshotPath, ImageFormat.Png); } [DllImport("User32.dll", SetLastError = true)] [return: MarshalAs(UnmanagedType.Bool)] static extern bool PrintWindow(IntPtr hwnd, IntPtr hdc, uint nFlags); [DllImport("user32.dll")] static extern bool GetWindowRect(IntPtr handle, ref Rectangle rect); [DllImport("user32.dll", EntryPoint = "GetDesktopWindow")] static extern IntPtr GetDesktopWindow(); [DllImport("user32.dll", CharSet = CharSet.Unicode)] static extern IntPtr FindWindowEx(IntPtr parentHandle, IntPtr childAfter, string lclassName, string windowTitle); } }