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. Get mouse coordinates relative to control in separate application...

Get mouse coordinates relative to control in separate application...

Scheduled Pinned Locked Moved C#
tutorialcsharpwinformsquestiondiscussion
3 Posts 2 Posters 1 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.
  • E Offline
    E Offline
    Edmundisme
    wrote on last edited by
    #1

    Hello, I'm wondering how to go about getting the mouse cursor position relative to a child window in a given windows application. I'm writing an application that is interested in this data. Example: The user clicks a button in some winforms app, and my application uses low level hooks (or some other strategy) to determine the mouse coordinates relative to the clicked button in the other application. Any thoughts on how to proceed? I'm hooking the mouse so I get the screen coordinates when the mouse is clicked, but I'm not sure how to get position (relative or absolute) of the control that generated the "click" event. Thanks!

    C 1 Reply Last reply
    0
    • E Edmundisme

      Hello, I'm wondering how to go about getting the mouse cursor position relative to a child window in a given windows application. I'm writing an application that is interested in this data. Example: The user clicks a button in some winforms app, and my application uses low level hooks (or some other strategy) to determine the mouse coordinates relative to the clicked button in the other application. Any thoughts on how to proceed? I'm hooking the mouse so I get the screen coordinates when the mouse is clicked, but I'm not sure how to get position (relative or absolute) of the control that generated the "click" event. Thanks!

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      You can get screen co-ordinates and do the conversion yourself, it's pretty straightforward, just get the position of the window in question.

      Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

      E 1 Reply Last reply
      0
      • C Christian Graus

        You can get screen co-ordinates and do the conversion yourself, it's pretty straightforward, just get the position of the window in question.

        Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

        E Offline
        E Offline
        Edmundisme
        wrote on last edited by
        #3

        Yeah, I guess my question is really how to get the position of a child window that generated the event (where the child window is running in a separate application from the code that is interested in its position). I see that Spy++ is able to identify the positions of child windows, I just don't know what APIs are being used.

        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