110,534
社区成员
发帖
与我相关
我的任务
分享
public Bitmap GetScreenBmp(Rectangle rect)
{
Bitmap screenBmp = new Bitmap(rect.Width, rect.Height);
using (Graphics g = Graphics.FromImage(screenBmp))
{
g.CopyFromScreen(rect.X, rect.Y, 0, 0, rect.Size);
Cursor.Current.Draw(g, new Rectangle(Cursor.Position.X, Cursor.Position.Y, 33, 33));
}
return screenBmp;
}
以上是截屏的代码,可以截屏然后判断像素是否改变
不过如果你只想判断鼠标是否进入某一区域,直接获取Cursor.Position.X, Cursor.Position.Y,判断是否在你定义的区域内就好了