Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/261.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 捕获鼠标移动并导出到图像[代码|应用程序]_C#_Drawing_Capture - Fatal编程技术网

C# 捕获鼠标移动并导出到图像[代码|应用程序]

C# 捕获鼠标移动并导出到图像[代码|应用程序],c#,drawing,capture,C#,Drawing,Capture,为了获得有关WinForm或Webapplications使用的更深入的信息,我想捕获鼠标移动并单击信息。如果可以将其渲染为图像,那将是完美的 结果会是这样的: 问题是如何开始创建这样的应用程序 当它是来自另一个应用程序的进程时,我如何接收鼠标移动和单击 如何将鼠标移动转换为图像 (有人知道是否有免费/便宜的开源应用程序可以做到这一点) 能够做到这一点,但它是Java的,而且是免费的,但不是开源的。我会尝试捕获您的窗口的任何鼠标移动/单击,并将其存储在一个集合中。当您完成录制后-尝试绘制

为了获得有关WinForm或Webapplications使用的更深入的信息,我想捕获鼠标移动并单击信息。如果可以将其渲染为图像,那将是完美的

结果会是这样的:


问题是如何开始创建这样的应用程序

  • 当它是来自另一个应用程序的进程时,我如何接收鼠标移动和单击
  • 如何将鼠标移动转换为图像
(有人知道是否有免费/便宜的开源应用程序可以做到这一点)


能够做到这一点,但它是Java的,而且是免费的,但不是开源的。

我会尝试捕获您的窗口的任何鼠标移动/单击,并将其存储在一个集合中。当您完成录制后-尝试绘制您的图像。我建议在谷歌搜索“捕获鼠标”或“鼠标挂钩”。不久前,我这样做是为了得到一个键盘挂钩。你可以看一看

就代码而言,这可能有助于:

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;
}
Dictionary dict=new Dictionary();
///请参阅给定的链接以找到获取此类事件的正确方法
公共无效鼠标事件(…)
{
///获取鼠标坐标
///创建点结构
///检查DICT中是否存在点
///否-在点处添加新的MouseEventInfo
///是-访问MouseEventInfo对象并根据事件增加值
}
公共无效已完成()
{
///根据屏幕结果创建新位图/图像-宽度/高度
///遍历所有MouseEventInfo对象并绘制任何信息
}
///存储点的鼠标事件信息
类MouseEventInfo
{
p点;
int=0;
int=0;
int=0;
}
我知道这只是一段伪代码-无论如何-我希望这能帮助你!啊-请记住,任何类型的钩子(键盘、鼠标或其他任何东西)都可能导致您的抗病毒药物出现病毒警报


hth

如果您正在寻找可以在外部运行并跟踪鼠标移动和单击的东西,您可能会发现这个位于codeproject.com的鼠标/键盘挂钩项目非常有用:


有一个示例应用程序和一个具有完整源代码的挂钩库。这将是您在工作中使用的一个起点。

在应用程序的屏幕截图上呈现这一点也会很有趣。事实上,它还将添加一个捕获作为背景。