Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/264.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工具提示报告3d party窗口上的鼠标坐标_C#_Mouseevent - Fatal编程技术网

C# C工具提示报告3d party窗口上的鼠标坐标

C# C工具提示报告3d party窗口上的鼠标坐标,c#,mouseevent,C#,Mouseevent,这个问题是关于一个工具提示,你可以很容易地实现 通过鼠标坐标跟踪鼠标位置 对我来说唯一的问题是添加跟踪特定区域上坐标的功能 窗口设置为前景后。。。它不是表单,而是第三方 应用程序 在VisualStudioWindows窗体上适用于我的代码是 ToolTip trackTip; private void TrackCoordinates() { trackTip = new ToolTip(); this.MouseMove += new Mou

这个问题是关于一个工具提示,你可以很容易地实现 通过鼠标坐标跟踪鼠标位置 对我来说唯一的问题是添加跟踪特定区域上坐标的功能 窗口设置为前景后。。。它不是表单,而是第三方 应用程序

在VisualStudioWindows窗体上适用于我的代码是

ToolTip trackTip;

    private void TrackCoordinates()
    {
        trackTip = new ToolTip();
        this.MouseMove += new MouseEventHandler(Form1_MouseMove);
    }

    void Form1_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
    {
        String tipText = String.Format("({0}, {1})", e.X, e.Y);
        trackTip.Show(tipText, this, e.Location);
    }
//这是我在网上的某个地方看到的一段代码,在谷歌搜索之后又出现了 在url处找到msdn源:

因此,如果您愿意回答,问题仍然存在: 如何获取除Vs winform window之外的第三方在目标窗口和消息中的工具提示坐标


使用计时器并抓取按钮。

如中所述,您需要使用以下选项之一:

1.使用Windows窗体。添加对System.Windows.Forms的引用

public static Point GetMousePositionWindowsForms() 
{ 
    System.Drawing.Point point = Control.MousePosition; 
    return new Point(point.X, point.Y); 
} 
2.使用Win32

[DllImport("user32.dll")] 
[return: MarshalAs(UnmanagedType.Bool)] 
internal static extern bool GetCursorPos(ref Win32Point pt); 

[StructLayout(LayoutKind.Sequential)] 
internal struct Win32Point 
{ 
    public Int32 X; 
    public Int32 Y; 
}; 
public static Point GetMousePosition() 
{ 
    Win32Point w32Mouse = new Win32Point(); 
    GetCursorPos(ref w32Mouse); 
    return new Point(w32Mouse.X, w32Mouse.Y); 
} 

您是否需要将鼠标放置在特定应用程序上?还是鼠标在屏幕上的绝对位置?我想我更喜欢。。。现在我确定了……脱落位置