[英]Catch click-event of button in external app
I would like to know whether a button in an external app is clicked. 我想知道是否单击了外部应用程序中的按钮。 Before I had to do the clicking myself, for which I used the following code: 在必须自己单击之前,我使用了以下代码:
//Get window
IntPtr wrapUp = Win32API.FindWindowByText(Win32API.GetDesktopWindow(), "WRAP-UP");
if ((int)wrapUp > 0)
{
Win32API.SetFocus(wrapUp);
IntPtr okButton = Win32API.FindWindowByText(wrapUp, "OK");
Win32API.SetFocus(okButton);
Win32API.PostMessage(okButton, Win32API.BM_CLICK, 0, 0);
}
But now I need to know when the user clicks that button. 但是现在我需要知道用户何时单击该按钮。 Is there a way to do this? 有没有办法做到这一点?
I've been searching a bit and I've found several ways to perform the clicking from code, but not for listening to an event. 我一直在搜索,已经找到了几种方法来执行单击代码的操作,而不是监听事件。
您可以使用SetWinEventHook设置事件挂钩函数,并收听EVENT_OBJECT_INVOKED
,该事件指示已调用对象(例如,单击了按钮)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.