# Getting the object under the mouse

**URL:** https://forum.highend3d.com/t/getting-the-object-under-the-mouse/6585
**Category:** Maya
**Tags:** mel
**Created:** [January 16, 2002, 6:21pm UTC](https://forum.highend3d.com/t/getting-the-object-under-the-mouse/6585 "2002-01-16T18:21:58Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![gergely](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/g/958977/32.png) [@gergely](https://forum.highend3d.com/u/gergely)
#### Post date: [January 16, 2002, 6:21pm UTC](https://forum.highend3d.com/t/getting-the-object-under-the-mouse/6585/1 "2002-01-16T18:21:58Z")

</div>

What commands cen help returning the object`s name under the mousepointer? An A|W factory script does that when presssing the left button over an object, it displays a Marking Menu. One of these related scripts contain a suspicious command named dagObjectHit. But surprisingly, it is undocumented.

---

<div class="post-metadata">

### Author: ![glocker](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/g/a9adbd/32.png) [@glocker](https://forum.highend3d.com/u/glocker)
#### Post date: [January 17, 2002, 3:56pm UTC](https://forum.highend3d.com/t/getting-the-object-under-the-mouse/6585/2 "2002-01-17T15:56:51Z")

</div>

> [@](#):
>
> In reply to:   
> What commands cen help returning the object`s name under the mousepointer?

Once you get the x/y location of the mouse, you can use MGlobal::selectFromScreen(mouseX, mouseY) to select the object under the mouse.

You can get the mouse position in a couple of different ways. If you are making a context tool, you can use MEvent::getPosition(mouseX, mouseY). You can also write some windows code that gets the Window context and uses GetCursorPos and some other math to figure out the position of the mouse.

g-
