Marcus
Marcus

Reputation: 449

How to use Sendmessage in C#?

I got the hwnd = FindWindow(""); but how to do Sendmessage with mouse clicks with this window ?? Thx.

Upvotes: 0

Views: 7775

Answers (2)

Govert
Govert

Reputation: 16907

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.

Upvotes: 0

Svisstack
Svisstack

Reputation: 16656

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.

Upvotes: 1

Related Questions