如何实现得到屏幕的绝对坐标?

来源:百度知道 编辑:UC知道 时间:2024/06/15 15:41:51
我的目标是 不管电脑在运行什么程序 随时可以知道指针的坐标。(通过文本框显示出来)

也就是 我如何才能知道鼠标在屏幕上的绝对坐标?

我的系统是XP 显示器为17寸LCD 分辨率1024×768

大大们给指条明路(不限语言) 感激啊!!!!!!

通过调api函数来获得系统的鼠标位置,也可以直接调用.net类库中的Cursor类来得到坐标,然后在程序用通过一个线程去实时显示当前鼠标的位置显示到文本框中
下面给出用C#实现的源码:

using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using System.Drawing;

namespace ShowCursor
{
public class frmShowPoint1:Form
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null;

/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispo