如何点击特定的(x,y)坐标 [英] How to make click on particular (x, y) co-ordinates

查看:91
本文介绍了如何点击特定的(x,y)坐标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想单击特定的(x,y)坐标.假设x = 10和y = 20,则应在该点上单击鼠标右键..

如果您知道如何使点击请帮助我..

提前谢谢...

最好的..

I want to make click on particular (x,y)co-ordinates.. suppose x=10 and y=20 it should make a right click on that points..

If you know how to make click pls help me..

Thank you in advance...

All the best..

推荐答案

查看以下链接:
http://msdn.microsoft.com/en-us/library/ms171548.aspx [ ^ ]
http://stackoverflow.com/questions/2416748/how-to-simulate- mouse-click-in-c [ ^ ]
Check out these links:
http://msdn.microsoft.com/en-us/library/ms171548.aspx[^]
http://stackoverflow.com/questions/2416748/how-to-simulate-mouse-click-in-c[^]


据我了解,您需要模拟一次点击. Windows API SendInput是执行此操作的综合方法,您需要P/Invoke.
请参阅: http://msdn.microsoft.com/en-us/library /ms646310(v=vs.85).aspx [ ^ ].

—SA
As I understand, you need to simulate a click. The comprehensive way of doing this is Windows API SendInput, which you need to P/Invoke.
See: http://msdn.microsoft.com/en-us/library/ms646310(v=vs.85).aspx[^].

—SA


尝试:
[DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
public static extern void mouse_event(long dwFlags, long dx, long dy, long cButtons, long dwExtraInfo);
private const int MOUSEEVENTF_LEFTDOWN = 0x02;
private const int MOUSEEVENTF_LEFTUP = 0x04;
private const int MOUSEEVENTF_RIGHTDOWN = 0x08;
private const int MOUSEEVENTF_RIGHTUP = 0x10;
public void MakeMouseClick()
    {
    int X = System.Windows.Forms.Cursor.Position.X;
    int Y = System.Windows.Forms.Cursor.Position.Y;
    mouse_event(MOUSEEVENTF_RIGHTDOWN | MOUSEEVENTF_RIGHTUP, X, Y, 0, 0);
    }

这将导致在光标位置上单击鼠标右键

This causes a Right Click at the cursor position


这篇关于如何点击特定的(x,y)坐标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆