Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Forums Adobe After Effects Expressions Script – How can I access mouse cursor position in comp viewer?

  • Script – How can I access mouse cursor position in comp viewer?

  • Nick Graves

    December 30, 2021 at 1:16 pm

    My end-goal is to create a script that allows you to press a hotkey and “snap” or set the position of a selected layer to the position of your mouse cursor in the After Effects viewer. Basically I have to hand position a lot of elements or track things to video a lot and I would like to just press a button or click and have a layer snap to where my mouse is pointing.

    I’ve seen some discussion about how to do this in other posts using ScriptUI to get the size of the entire screen or monitor coordinates (found here: https://creativecow.net/forums/thread/get-mouse-cursor-x-and-y-location-in-script/), but I’m looking to get the specific location based on the *composition* coordinates.

    The two images below show what information I’m hoping to get. When my mouse is in the corner of the comp you can see the Info window is able to display that my mouse is currently near 0,0 in comp space, at precisely -8,-8 pixels.

    I would like to get exactly that data from the Info panel if possible, but if not I would love to know if there is a workaround that will allow me to get the cursor relative to the dimensions of the comp. Perhaps I need to autofit the viewer to comp size, and then create a new ScriptUI window to get the mouse position? Or maybe I can get the mouse position *based* on the viewer window itself without creating a new window?

    Thanks in advance if you can shed some light on this!

     

    get mouse cursor x and y location in script

Viewing 1 of 1 posts

Log in to reply.

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy