简体   繁体   中英

How to use Sendmessage in C#?

I got the hwnd = FindWindow(""); but how to do Sendmessage with mouse clicks with this window ?? 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.

You want to simulate mouse clicks using SendMessage?

This is a duplicate question to this one: Using SendMessage for Simulating User Mouse Clicks .

The answer there recommends that you investigate WIN32 journal hooks, thus sending 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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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