首页 > 解决方案 > Trying to detect and gather data on click outside application

问题描述

I would like to know if it is possible to, while running a WPF window application in Visual Studio, wait for the user to click anywhere on the screen (not necessarily inside the window of my application - for the purpose of my application, the click would most likely occur inside a browser page) and then gather the information about the click (like inside the window of which application the user clicked, or the selector of the html element the user clicked)? I know this question might be very confunsing but this is basically my last resort since researching on the Internet hasn't helped me much. Just to provide a better idea of what I seek, it's like what the 'Extract Structured Data' Activity does in UiPath. Oh and I'm using C# by the way.

标签: c#wpfwpf-controls

解决方案


您可以尝试使用这个名为GlobalMouseHook的外部库。

即使应用程序处于非活动状态并在后台运行,该库也允许您点击键盘和鼠标,检测并记录它们的活动。

这是您可以使用此库执行的操作:

  • 鼠标坐标
  • 单击鼠标按钮
  • 鼠标拖动动作
  • 鼠标滚轮滚动
  • 按键和释放
  • 特殊键状态

希望这可以帮助。


推荐阅读