简体   繁体   English

如何在C#中使用Sendmessage?

[英]How to use Sendmessage in C#?

I got the hwnd = FindWindow(""); 我得到了hwnd = FindWindow(“”); but how to do Sendmessage with mouse clicks with this window ?? 但是如何在此窗口中单击鼠标来发送Sendmessage? Thx. 谢谢。

using System.Runtime.InteropServices;
...
[DllImport("user32.dll")]
private static extern IntPtr SendMessage
    (IntPtr hWnd, int Msg, IntPtr wParam, IntPtr lParam);

For usage information look at http://msdn.microsoft.com/en-us/library/ms644950%28VS.85%29.aspx Generaly you must only call this function with good arguments, to know what arguments you need you must look at msdn. 有关使用情况的信息,请参见http://msdn.microsoft.com/zh-cn/library/ms644950%28VS.85%29.aspx一般情况下,您只能使用具有良好参数的函数来调用此函数,以了解所需的参数在msdn。

You want to simulate mouse clicks using SendMessage? 您想使用SendMessage模拟鼠标单击吗?

This is a duplicate question to this one: Using SendMessage for Simulating User Mouse Clicks . 这是一个重复的问题: 使用SendMessage模拟用户鼠标点击

The answer there recommends that you investigate WIN32 journal hooks, thus sending WH_JOURNALPLAYBACK. 那里的答案建议您调查WIN32日记帐挂钩,从而发送WH_JOURNALPLAYBACK。

And another duplicate with what is reported to be a working snippet: Clicking mouse by sending messages 另一个重复的报告是有效的代码段: 通过发送消息单击鼠标

This discussion on MSDN indicates that it's not so easy using the raw mouse messages: http://social.msdn.microsoft.com/Forums/hu-HU/vbide/thread/5352d3b8-4f9e-4a0a-8575-fdd592ae45f8 . 在MSDN上的讨论表明,使用原始鼠标消息并不容易: http : //social.msdn.microsoft.com/Forums/hu-HU/vbide/thread/5352d3b8-4f9e-4a0a-8575-fdd592ae45f8

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM