如何模拟按钮单击

如何模拟按钮单击

本文介绍了给定按钮窗口的句柄,如何模拟按钮单击?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想模拟对对话框中按钮的单击。

I want to simulate a click on a button located in a dialog box.

我有该窗口的句柄。这是中止/重试/忽略窗口。

I have the handle to that window. This is an Abort/Retry/Ignore kind of window.

我不想模拟具有X和Y坐标的点击,因为它不符合我的需求。

I don't want to go with simulating a click having X and Y coordinates as it doesn't suit my needs.

推荐答案

找到要单击的按钮的句柄(通过使用 FindWindowEx ),然后仅发送单击消息:

Find the handle to the button that you want to click (by using FindWindowEx), and just send click message:

SendMessage(hButton, WM_LBUTTONDOWN, MK_LBUTTON, MAKELPARAM(0, 0));
SendMessage(hButton, WM_LBUTTONUP, MK_LBUTTON, MAKELPARAM(0, 0));

这篇关于给定按钮窗口的句柄,如何模拟按钮单击?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-13 04:24