问题
How can I simulate a button click in the sendmessage API in C#?
回答1:
C code:
#include <Windows.h>
//...
SendMessage(hWndButton, BM_CLICK, 0, 0);
C# code:
[DllImport("user32.dll")]
static extern IntPtr SendMessage(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam);
...
Button myButton = ...;
const int BM_CLICK = 0x00F5;
SendMessage(myButton.Handle, BM_CLICK, IntPtr.Zero, IntPtr.Zero);
But be aware that, in C#, you can just as easily do:
myButton.PerformClick();
来源:https://stackoverflow.com/questions/4665463/button-click-in-sendmessage-api