예제 #1
0
파일: Caret.cs 프로젝트: ragarad/SymWin
        // 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;
        }
예제 #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);
        }
예제 #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);
        }
예제 #4
0
파일: Caret.cs 프로젝트: ragarad/SymWin
 private static extern Boolean GetGUIThreadInfo(UInt32 idThread, out GUITHREADINFO lpgui);
예제 #5
0
 private static extern Boolean GetGUIThreadInfo(UInt32 idThread, out GUITHREADINFO lpgui);