我在截取窗口的屏幕截图时遇到了问题。
这是我正在使用的代码:
using System;
using System.Drawing;
using System.Drawing.Imaging;
using System.Runtime.InteropServices;
namespace Alerts
{
class ImgSearch
{
[DllImport("user32.dll", CharSet = CharSet.Auto)]
public static extern IntPtr FindWindow(string strClassName, string strWindowName);
[DllImport("user32.dll")]
public static extern bool GetWindowRect(IntPtr hwnd, ref Rect rectangle);
public struct Rect
{
public int Left { get; set; }
public int Top { get; set; }
public int Right { get; set; }
public int Bottom { get; set; }
}
public static void ScreenShotWindow(IntPtr whandle)
{
// Get the …Run Code Online (Sandbox Code Playgroud) 我正在尝试将鼠标右键单击发送到窗口指定的坐标。
我用2个代码测试过
代码1:
[DllImport("user32.dll")]
public static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam);
[DllImport("user32.dll")]
static extern bool ScreenToClient(IntPtr hWnd, ref POINT lpPoint);
public struct POINT
{
public int x;
public int y;
}
var client = Process.GetProcessesByName("client_dx");
var whandle = client.MainWindowHandle;
POINT point = new POINT();
point.x = 1836;
point.y = 325;
ScreenToClient(whandle, ref point);
int lparm = (point.x << 16) + point.y;
int lngResult = SendMessage(whandle, 0x0204, 0, lparm);
int lngResult2 = SendMessage(whandle, 0x0205, 0, lparm); …Run Code Online (Sandbox Code Playgroud)