请问怎样让鼠标到达指定的坐标?

ithinkso 2003-10-17 10:14:07
例如我想mouse移动到坐标(100,100),请问怎样实现呢? 先谢谢了.
...全文
46 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
coudoufu 2003-10-19
  • 打赏
  • 举报
回复
那确实,呵呵
feigehao 2003-10-19
  • 打赏
  • 举报
回复
同意 alron(*落花有意随流水,而流水无心恋落花*) 的写法
FileNewExit 2003-10-19
  • 打赏
  • 举报
回复
不好意思,上面粘得有些随意了(与什么menuItem3_Click无关)
更正如下:
using using System.Runtime.InteropServices;

[DllImport("User32.dll")]
public static extern bool SetCursorPos(int x,int y);//定位鼠标的位置

在使用的时候
SetCursorPos(100,100);
就OK了

FileNewExit 2003-10-19
  • 打赏
  • 举报
回复
[DllImport("User32.dll")]
public static extern bool SetCursorPos(int x,int y);//定位鼠标的位置

private void menuItem3_Click(object sender, System.EventArgs e)
{
SetCursorPos(100,100);
}
qupd 2003-10-19
  • 打赏
  • 举报
回复
System.Windows.Forms.Cursor.Position是property
试试这样写:
System.Windows.Forms.Cursor.Position=new point(100,100);
Stevetan81 2003-10-19
  • 打赏
  • 举报
回复
yes,System.Windows.Forms.Cursor.Position是只读的
jknight 2003-10-19
  • 打赏
  • 举报
回复
无法修改“System.Windows.Forms.Cursor.Position”的返回值,因为它不是变量?
alron 2003-10-17
  • 打赏
  • 举报
回复
System.Windows.Forms.Cursor.Position.X=100;
System.Windows.Forms.Cursor.Position.Y=100;
ithinkso 2003-10-17
  • 打赏
  • 举报
回复
up

110,533

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧