gpt4 book ai didi

c# - 捕获鼠标移动并导出为图像 [code |应用程序]

转载 作者:太空狗 更新时间:2023-10-29 21:52:02 25 4
gpt4 key购买 nike

为了更深入地了解 WinForm 或 Web 应用程序的使用情况,我想捕获鼠标移动和单击信息。如果可以将其渲染为图像,那就太完美了。

结果会是这样的:

Google: capture display "mouse movement" app to image
问题是如何开始创建这样的应用程序?

  • 当它是来自另一个应用程序的进程时,我如何接收鼠标移动和点击?
  • 如何将鼠标移动转换为图像?

(任何人都知道是否有可以做到这一点的免费/廉价应用程序的开源)

IOGraphica能够做到这一点,但它是在 Java 中,它是免费的,但不是开源的。

最佳答案

我会尝试捕获您窗口的任何鼠标移动/点击并将其存储在一个集合中。当您完成录制时 - 尝试画出您的图像。我建议在 google 中寻找 “c# capture mouse”“mouse hook”。前段时间我这样做是为了获得键盘 Hook 。你可以看看 Processing Global Mouse Events .

就代码而言,这可能会有所帮助:

Dictionary<Point, MouseEventInfo> dict = new Dictionary<Point, MouseEventInfo>();

/// see given link to find the correct way to get this kind of event
public void mouse_event(....)
{
/// get mouse coordinates

/// create point struct

/// check if point exists in DICT

/// no - add new MouseEventInfo at Point

/// yes - access MouseEventInfo object and increase a value according to the event

}

public void onFinished()
{
/// create new bitmap/image - width/height according to your screen resultion

/// iterate through all MouseEventInfo objects and draw any information

}

/// stores mouse event info for a point
class MouseEventInfo
{
Point p;
int moved=0;
int clicked=0;
int doubleClicked=0;
}

我知道这只是一段伪代码——无论如何——我希望这对你有帮助!啊 - 请记住,任何类型的 Hook (键盘、鼠标或其他任何东西)都可能导致您的 antiVir 发出病毒警报

第一个

关于c# - 捕获鼠标移动并导出为图像 [code |应用程序],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5181500/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com