еще такой вопрос перекрытое окно скриншот можно в с++ сделать? как?
клик мышью вот так венрнее не знаю что у вас
SendMessage(wndHandle, WM_MOUSEMOVE, 0, coord);
SendMessage(wndHandle, WM_LBUTTONDOWN, 0, coord);
Thread.Sleep(100);
SendMessage(wndHandle, WM_LBUTTONUP, 0, coord);
далее принтскрин неактивного окна, вернее перекрытого, с# код, я думаю кому надо разберется полезно для бота, который работает по поиску в картинке, а не с памятью, что бы не забанили
это если есть манипуляции с масштабом
public class Scale
{
[DllImport("gdi32.dll")]
static extern int GetDeviceCaps(IntPtr hdc, int nIndex);
public enum DeviceCap
{
VERTRES = 10,
DESKTOPVERTRES = 117,
//
http://pinvoke.net/default.aspx/gdi32/GetDeviceCaps.html }
public float getScalingFactor()
{
Graphics g = Graphics.FromHwnd(IntPtr.Zero);
IntPtr desktop = g.GetHdc();
int LogicalScreenHeight = GetDeviceCaps(desktop, (int)DeviceCap.VERTRES);
int PhysicalScreenHeight = GetDeviceCaps(desktop, (int)DeviceCap.DESKTOPVERTRES);
float ScreenScalingFactor = (float)PhysicalScreenHeight / (float)LogicalScreenHeight;
return ScreenScalingFactor; // 1.25 = 125%
}
}
[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);
private static double SCALEoFsCREEN = new Scale().getScalingFactor();
public void CaptureWindow(IntPtr handle)
{
// Get the size of the window to capture
Rectangle rect = new Rectangle();
GetWindowRect(handle, ref rect);
// GetWindowRect returns Top/Left and Bottom/Right, so fix it
rect.Width = rect.Width - rect.X;
rect.Height = rect.Height - rect.Y;
// Create a bitmap to draw the capture into
using (Bitmap bitmap = new Bitmap((int)(rect.Width * SCALEoFsCREEN), (int)(rect.Height* SCALEoFsCREEN)))
{
// Use PrintWindow to draw the window into our bitmap
using (Graphics g = Graphics.FromImage(bitmap))
{
IntPtr hdc = g.GetHdc();
if (!PrintWindow(handle, hdc, 0))
{
int error = Marshal.GetLastWin32Error();
var exception = new System.ComponentModel.Win32Exception(error);
Debug.WriteLine("ERROR: " + error + ": " + exception.Message);
// TODO: Throw the exception?
}
g.ReleaseHdc(hdc);
}
// Save it as a .png just to demo this
bitmap.Save("Example.png");
}
}