Beispiel #1
0
        // Based on http://www.codeproject.com/Articles/34520/Getting-Caret-Position-Inside-Any-Application.
        public static Point GetPosition(IntPtr window)
        {
            GUITHREADINFO info = new GUITHREADINFO();
             info.cbSize = (UInt32)Marshal.SizeOf(info);
             GetGUIThreadInfo(0, out info);

             //var caret = info.rcCaret;
             //if (caret.Left == 0 && caret.Bottom == 0)
             //{
             //   // Try again using a more specific thread id.
             //   var curThreadId = GetCurrentThreadId();
             //   var threadId = GetWindowThreadProcessId(window, IntPtr.Zero);
             //   var b1 = AttachThreadInput(curThreadId, threadId, true)
             //   var focus = GetFocus();
             //   //var b2 = GetGUIThreadInfo(threadId, out info);
             //   //caret = info.rcCaret;
             //   Point point;
             //   GetCaretPos(out point);
             //   AttachThreadInput(curThreadId, threadId, false);
             //}

             Point caretPos;
             caretPos.X = info.rcCaret.Left;
             caretPos.Y = info.rcCaret.Bottom;

             ClientToScreen(info.hwndCaret, ref caretPos);

             return caretPos;
        }
Beispiel #2
0
        // Based on http://www.codeproject.com/Articles/34520/Getting-Caret-Position-Inside-Any-Application.
        public static Point GetPosition(IntPtr window)
        {
            GUITHREADINFO info = new GUITHREADINFO();

            info.cbSize = (UInt32)Marshal.SizeOf(info);
            GetGUIThreadInfo(0, out info);

            //var caret = info.rcCaret;
            //if (caret.Left == 0 && caret.Bottom == 0)
            //{
            //   // Try again using a more specific thread id.
            //   var curThreadId = GetCurrentThreadId();
            //   var threadId = GetWindowThreadProcessId(window, IntPtr.Zero);
            //   var b1 = AttachThreadInput(curThreadId, threadId, true)
            //   var focus = GetFocus();
            //   //var b2 = GetGUIThreadInfo(threadId, out info);
            //   //caret = info.rcCaret;
            //   Point point;
            //   GetCaretPos(out point);
            //   AttachThreadInput(curThreadId, threadId, false);
            //}

            Point caretPos;

            caretPos.X = info.rcCaret.Left;
            caretPos.Y = info.rcCaret.Bottom;

            ClientToScreen(info.hwndCaret, ref caretPos);

            return(caretPos);
        }
Beispiel #3
0
        // Based on http://www.codeproject.com/Articles/34520/Getting-Caret-Position-Inside-Any-Application.
        public static Point GetPosition(IntPtr window)
        {
            GUITHREADINFO info = new GUITHREADINFO();

            info.cbSize = (UInt32)Marshal.SizeOf(info);
            GetGUIThreadInfo(0, out info);

            Point caretPos;

            caretPos.X = info.rcCaret.Left;
            caretPos.Y = info.rcCaret.Bottom;

            ClientToScreen(info.hwndCaret, ref caretPos);

            return(caretPos);
        }
Beispiel #4
0
 private static extern Boolean GetGUIThreadInfo(UInt32 idThread, out GUITHREADINFO lpgui);
Beispiel #5
0
 private static extern Boolean GetGUIThreadInfo(UInt32 idThread, out GUITHREADINFO lpgui);