Microsoft Spy++ download: https://social.msdn.microsoft.com/Forums/vstudio/en-US/8d06750a-8d6c-4aca-9896-6ca49a631c07/where-can-i-get-microsoft-spy?forum=vcgeneral
Highlight flashes window borders - find which window handle is FFT spectrum analyzer
notsrccopy
C# code
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Imaging;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace WindowsFormsApplication3
{
public partial class Form1 : Form
{
[StructLayout(LayoutKind.Sequential)]
public struct RECT
{
public int left;
public int top;
public int right;
public int bottom;
}
[DllImport("user32.dll")]
public static extern IntPtr GetDesktopWindow();
[DllImport("user32.dll")]
public static extern IntPtr GetWindowDC(IntPtr hWnd);
[DllImport("user32.dll")]
public static extern IntPtr ReleaseDC(IntPtr hWnd, IntPtr hDC);
[DllImport("user32.dll")]
public static extern IntPtr GetWindowRect(IntPtr hWnd, ref RECT rect);
[DllImport("gdi32.dll")]
public static extern bool BitBlt(IntPtr hObject, int nXDest, int nYDest,
int nWidth, int nHeight, IntPtr hObjectSource, int nXSrc, int nYSrc, int dwRop);
[DllImport("gdi32.dll")]
public static extern IntPtr CreateCompatibleBitmap(IntPtr hDC, int nWidth, int nHeight);
[DllImport("gdi32.dll")]
public static extern IntPtr CreateCompatibleDC(IntPtr hDC);
[DllImport("gdi32.dll")]
public static extern bool DeleteDC(IntPtr hDC);
[DllImport("gdi32.dll")]
public static extern bool DeleteObject(IntPtr hObject);
[DllImport("gdi32.dll")]
public static extern IntPtr SelectObject(IntPtr hDC, IntPtr hObject);
public Form1()
{
InitializeComponent();
}
private void button_GetGFX_Click(object sender, EventArgs e)
{
int i = Convert.ToInt32(textBox_Handle.Text, 16);
IntPtr hwnd = new IntPtr(i);
IntPtr hdcSrc = GetWindowDC(hwnd);
RECT windowRect = new RECT();
GetWindowRect(hwnd, ref windowRect);
int w = windowRect.right - windowRect.left;
int h = windowRect.bottom - windowRect.top;
IntPtr hdcDest = CreateCompatibleDC(hdcSrc);
IntPtr hBitmap = CreateCompatibleBitmap(hdcSrc, w, h);
IntPtr hOld = SelectObject(hdcDest, hBitmap);
BitBlt(hdcDest, 0, 0, w, h, hdcSrc, 0, 0, 0x00330008); // notsrccopy
SelectObject(hdcDest, hOld);
DeleteDC(hdcDest);
ReleaseDC(hwnd, hdcSrc);
pictureBox_Img.Image = Image.FromHbitmap(hBitmap);
DeleteObject(hBitmap);
var encoder = ImageCodecInfo.GetImageEncoders().First(c => c.FormatID == ImageFormat.Jpeg.Guid);
var encParams = new EncoderParameters(1);
encParams.Param[0] = new EncoderParameter(System.Drawing.Imaging.Encoder.Quality, 60L);
pictureBox_Img.Image.Save(@"c:\temp\sa.jpg", encoder, encParams);
}
}
}
Kommentit
Tämän blogin kommentit tarkistetaan ennen julkaisua.