Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. GetCaretPos help needed (get keyboard possition)

GetCaretPos help needed (get keyboard possition)

Scheduled Pinned Locked Moved C#
jsonhelpquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    ranzask
    wrote on last edited by
    #1

    Hi all, i am using the API : [DllImport("user32.dll")]public static extern int GetCaretPos(ref Point lpPoint); what i'm trying to do is the show contextMenu above the KB cursor. it's working good with MSN messenger and Notepad (the function returns the cursor's possition in the active window) but, in other programs like:MSWord,Yahoo messenger it returns(X=, Y=0) how is it possible? Sincerely, Ran.

    R.Z

    L 1 Reply Last reply
    0
    • R ranzask

      Hi all, i am using the API : [DllImport("user32.dll")]public static extern int GetCaretPos(ref Point lpPoint); what i'm trying to do is the show contextMenu above the KB cursor. it's working good with MSN messenger and Notepad (the function returns the cursor's possition in the active window) but, in other programs like:MSWord,Yahoo messenger it returns(X=, Y=0) how is it possible? Sincerely, Ran.

      R.Z

      L Offline
      L Offline
      lainoo
      wrote on last edited by
      #2

      How do u work with MSN messager and notepad, i want to get your some source code. Please ,Thank u very much

      Sorry ...

      R 1 Reply Last reply
      0
      • L lainoo

        How do u work with MSN messager and notepad, i want to get your some source code. Please ,Thank u very much

        Sorry ...

        R Offline
        R Offline
        ranzask
        wrote on last edited by
        #3

        Thats the code that give you on msn and notepad. i'm looking to work also on Word and Yahoo... private Point getCaretLocation() { IntPtr hFocus = (IntPtr)GetForegroundWindow(); IntPtr hFore; IntPtr id=IntPtr.Zero; if (hFocus != IntPtr.Zero) { hFore= (IntPtr)GetForegroundWindow (); AttachThreadInput((int)GetWindowThreadProcessId((int)hFore, id), GetCurrentThreadId(), 1); hFocus = (IntPtr)GetForegroundWindow(); Point mypoint=Point.Empty; GetCaretPos(ref mypoint); Console.WriteLine(mypoint.ToString()); ClientToScreen (hFocus, ref mypoint); return mypoint; } return Point.Empty; }

        R.Z

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups