sendmessage API中的按钮点击 [英] Button click in sendmessage API

查看:64
本文介绍了sendmessage API中的按钮点击的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在 C# 中模拟 sendmessage API 中的按钮点击?

How can I simulate a button click in the sendmessage API in C#?

推荐答案

C 代码:

#include <Windows.h>
//...
SendMessage(hWndButton, BM_CLICK, 0, 0);

C# 代码:

[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);

但请注意,在 C# 中,您也可以轻松做到:

But be aware that, in C#, you can just as easily do:

myButton.PerformClick();

这篇关于sendmessage API中的按钮点击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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