帮助SendInput和移动/单击鼠标。 [DELPHI] [英] Help with SendInput and Moving/Clicking mouse. [DELPHI]

查看:93
本文介绍了帮助SendInput和移动/单击鼠标。 [DELPHI]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我希望有人可以帮我解决我的问题。所以我开始研究在delphi中移动和点击鼠标,我记得以前人们习惯使用Mouse_Events但现在已经被SendInput取代了,而SendInput与旧方法相比看起来很复杂。最重要的是,我找不到一个关于如何使用它的好的直接例子!那么有人可以帮帮我,告诉我如何使用SendInput移动并单击鼠标?另外我还有另一个与上述问题直接相关的问题。



我很难弄清楚如何模拟鼠标点击等在最小化或当前没有的窗口中活性。如果不清楚,我希望我的鼠标能够在没有实际使用鼠标的情况下点击和填充。



例如,当我在浏览网页时希望我的程序能够同时在另一个应用程序内部单击。

解决方案

感谢您显示代码。



在您的第一个片段中,问题是:您的 XCoordinate YCoordinate 的值丢失后,您稍后用0覆盖这些值。在调试器下,在分配点检查这些值,并在调用 SendInput 时检查。



在第二个片段中,问题是 dwFlags 。一次尝试一件事。您无法同时向下和向上设置鼠标左键。您需要对 SendInput 进行2或3次单独调用。例如,第一次调用移动鼠标,另一次按下按钮,另一次调用此按钮。



祝你好运。

-SA

Hello everyone I hope someone can help me with my question. So i started researching on moving and clicking the mouse within delphi, From what i remember people used to use Mouse_Events but that is now replaced by SendInput, And SendInput just seems so complicated compared to the old way. On top of that i cannot find an good straightfoward examples on how to use it! So could someone please help me out and tell me how to use SendInput to move and click the mouse? Also i have another question directly related to the above.

Im having a hard time figuring out how to simulate mouse clicks and such in a window that is minimized or not currently active. In case it not clear, I want my mouse to be able to click and stuff without actually using the mouse.

For example, while I'm browsing the web I would like my program to be able to be clicking inside of another application at the same time.

解决方案

Thank you for showing the code.

In your first fragment, the problem is: your values of XCoordinate and YCoordinate are lost, you later overwrite these values with 0. Under the debugger, check up these values at the point of assignment, and also at the point of calling SendInput.

In the second fragment, the problem is dwFlags. Try one thing at a time. You cannot set left mouse button down and up at the same time. You many need 2 or 3 separate calls to SendInput. For example, first call moves mouse, another presses a button down, another one releases this button.

Good luck.
—SA


这篇关于帮助SendInput和移动/单击鼠标。 [DELPHI]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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