发送鼠标点击特定位置不移动鼠标 [英] Sending a Mouse Click to a Specific Position without Moving the Mouse

查看:150
本文介绍了发送鼠标点击特定位置不移动鼠标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想找发送一个鼠标点击在屏幕上的特定位置,而不会影响鼠标光标的位置。

I'm looking to send a mouse click to a specific position on a screen without affecting the mouse cursor's location.

我已经冲刷,并试图在阳光下一切与mouse_event(这是应该做到这一点)

I've scoured and have tried everything under the sun with mouse_event (which is supposed to do this)

mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, X, Y, 0, 0);

不过,这最终只能发送鼠标点击到​​哪里鼠标的位置。所以,我最终不得不将鼠标移动到得到它的工作。

However this ends up only sending a mouse click to wherever the position of the mouse is. So I end up having to move the mouse to get it to work.

Cursor.Position = new Point(X, Y);

任何人有任何想法如何,我可以做到这一点,而无需移动鼠标?我也试过以下code座,但没有成功,因为它仍然只是点击,其中鼠标光标位置被这着实把我一个循环,我想这将工作过......

Anyone have any idea how I can do this WITHOUT having to move the mouse? I've also tried the following code block with no success as it still only clicked where the mouse cursor position was which really threw me for a loop as I figured this would have worked...

        Cursor.Position = new Point(X, Y);
        mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, X, Y, 0, 0);
        Cursor.Position = new Point(oldX, oldY);

在此先感谢您的帮助!

Thanks in advance for any help!

推荐答案

您不包括MOUSEEVENTF_MOVE标志,所以光标不会移动。

You didn't include the MOUSEEVENTF_MOVE flag, so the cursor isn't going to move.

我会建议做3个不同的电话(移动,向下,向上),一切在同一时间是前途未卜。但可能工作,实验,如果你真的想削减下来。顺便说一句,SendInput是什么SDK建议您使用。

I would recommend making 3 distinct calls (move, down, up), doing everything at the same time is iffy. But might work, experiment if you really want to cut that down. Btw, SendInput is what the SDK recommends you use.

这篇关于发送鼠标点击特定位置不移动鼠标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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