WIndows Api和.Net库实现控制鼠标的坐标
来源:互联网 发布:centos 安装mrtg 编辑:程序博客网 时间:2024/06/03 19:18
该示例实现了控制鼠标的坐标,分别用WIndows Api和.Net库自带的命令实现。
APi控制和获取鼠标分别是: GetCursorPos和SetCursorPost。
下面是截图:
using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- using System.Runtime.InteropServices;//
- namespace 获取和设置鼠标的坐标
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- /// <summary>
- /// 设置鼠标的坐标
- /// </summary>
- /// <param name="x">横坐标</param>
- /// <param name="y">纵坐标</param>
- [DllImport("User32")]
- public extern static void SetCursorPos(int x, int y);
- /// <summary>
- /// 获取鼠标的坐标
- /// </summary>
- /// <param name="lpPoint">传址参数,坐标point类型</param>
- /// <returns>获取成功返回真</returns>
- [DllImport("User32")]
- public extern static bool GetCursorPos(ref Point lpPoint);
- private void button_go_Click(object sender, EventArgs e)
- {
- SetCursorPos(int.Parse(textBox_x.Text), (int.Parse(textBox_y.Text)));
- }
- Point p = new Point(1, 1);//定义存放获取坐标的point变量
- private void timer1_Tick(object sender, EventArgs e)
- {
- GetCursorPos(ref p);
- label_p.Text = "X:" + p.X + "\r\nY:" + p.Y;
- //label_p.Text = "X:" + Cursor.Position.X + "\r\nY:" + Cursor.Position.Y; //用C#自带命令获取
- }
- }
- }
http://www.cnblogs.com/stg609/archive/2008/03/16/1108333.html
protected override void WndProc(ref Message m)
{
const int WM_SYSCOMMAND = 0x0112;
const int SC_CLOSE = 0xF060;
if((m.Msg == WM_SYSCOMMAND) && ((int)m.WParam == SC_CLOSE))
{
return;
}
base.WndProc(ref m);
}
- WIndows Api和.Net库实现控制鼠标的坐标
- Windows CE: 通过Application实现对鼠标光标的隐藏和显示的控制
- windows下控制鼠标移动和点击的c语言实现
- C#使用Windows API实现桌面上的遮罩层(鼠标穿透)
- OpenGL: 实现三维坐标的鼠标拣选
- [C#]获取和设置鼠标的坐标
- C#获取和设置鼠标的坐标
- js获取控件的坐标 和鼠标坐标
- OpenCV—利用回调函数实现返回鼠标点击位置的坐标和灰度值
- MATLAB实现控制鼠标移动和点击
- 获取鼠标的坐标
- 鼠标的坐标
- 鼠标坐标的显示~
- 获取鼠标的坐标
- 获取鼠标的坐标
- windows 鼠标事件API
- 鼠标API函数(windows)
- unity3d 屏幕坐标、鼠标位置、视口坐标和绘制GUI时使用的坐标
- 把cygwin推荐给大家
- Android 权限大全
- POJ 3195 Candies (差分约束)
- Tomcat配置虚拟主机 20111012
- C#获取和设置鼠标的坐标
- WIndows Api和.Net库实现控制鼠标的坐标
- http Form表单的Get和 Post请求深入分析
- Android JNI调用 – 文件操作
- Android中的状态机 机制
- HNOI'97凸多边形的三角形划分问题。。
- Android界面设计工具droiddraw
- Dijkstra算法
- 生产者与消费者-《Java编程语言》
- 重新启动计算机