Bootstrap

C# 不管光标在哪,获取光标(不是鼠标)位置。

找了半天,吐了,网上一大堆虚假重复信息,一个个把光标和鼠标混为一谈!

挨个挨个试终于找到能用的,但转过头发现,诶,那片有用的文章到哪了?

为了让后人不被坑,做了点微小贡献,争取让后人复制粘贴就能用。

    using System.Runtime.InteropServices;
    public class GetGuangbiao
    {
        //获得当前窗口的句柄
        [DllImport("user32.dll", EntryPoint = "GetForegroundWindow")]
        public static extern IntPtr GetForegroundWindow();
        // 获取拥有输入焦点的窗口的句柄
        [DllImport("user32.dll", EntryPoint = "GetFocus")]
        public static extern IntPtr GetFocus();
        //将一个线程的输入处理机制附加或分离到另一个线程的输入处理机制;

        [DllImport("user32")]
        public static extern bool GetCaretPos(out Point lpPoint);

        [DllImport("user32.dll")]
        private static extern IntPtr AttachThreadInput(IntPtr idAttach, IntPtr idAttachTo, int fAttach);
        [DllImport("user32.dll")]
        private static extern I
;