/// <summary>
/// 返回包含了指定点的窗口的句柄。忽略屏蔽、隐藏以及透明窗口
/// </summary>
/// <param name="Point">指定的鼠标坐标</param>
/// <returns>鼠标坐标处的窗口句柄,如果没有,返回</returns>
[DllImport("user32.dll")]
internal static extern IntPtr WindowFromPoint(Point Point);

/// <summary>
/// 获取鼠标处的坐标
/// </summary>
/// <param name="lpPoint">随同指针在屏幕像素坐标中的位置载入的一个结构</param>
/// <returns>非零表示成功,零表示失败</returns>
[DllImport("user32.dll")]
internal static extern bool GetCursorPos(out Point lpPoint);

private void timer1_Tick(object sender, EventArgs e)
{
    Point p;
    GetCursorPos(out p);//获取鼠标坐标
    this.Text = WindowFromPoint(p).ToString("X");//转换为16进制
}

相关文章:

  • 2022-01-31
  • 2022-01-08
  • 2021-08-18
  • 2021-05-15
  • 2021-12-27
  • 2021-12-10
猜你喜欢
  • 2021-10-03
  • 2022-12-23
  • 2022-03-09
  • 2022-12-23
  • 2021-12-12
  • 2021-12-03
相关资源
相似解决方案