[JS] Get Mouse Cursor Position
Copy link to clipboard
Copied
I have looked through the documentation and forums here and haven't found any reference to getting the cursor mouse position. I see info about text cursor position, but I am looking to capture the coordinates of mouse position. Is that possible with JavaScript (ExtendScript)?
Thanks for any help you can offer.
Dan

Copy link to clipboard
Copied
Hi Dan,
Sorry, there's not a way to do that with InDesign scripting.
What are you trying to do that you need this? It might be possible to do what you want via some other approach.
Thanks,
Ole
Copy link to clipboard
Copied
I want the script to create a specific sized picture frame on the page. It would be cool to make it at the current mouse position. Yes I can draw the frame myself, but I am trying to automate a tedious process, so having the script create the frame with all the proper options such as size and style will speed things up. I can create it in the middle of the page with the script, and then drag it into position manually, but it would be even better to use the mouse position when the script creates the frame.
Maybe an AppleScript could get the mouse position?
But then how would I pass that to my JavaScript?
Copy link to clipboard
Copied
You can get the position indirectly via AppleScript, however that's going to be the position in screen coordinates -- I'm not sure how you're going to convert that to coordinates in the document you have open.
Copy link to clipboard
Copied
Look at LayoutWindow.bounds -- "The bounds of the window (specified in pixels) in the form [top, left, bottom, right]."
Copy link to clipboard
Copied
Jong,
What's he suposed to do with that information?
I've used Window bounds to zoom specific amounts, etc. But it's going
to be a real hack to try to get something placed and sized correctly
based on this info...
Harbs
Copy link to clipboard
Copied
Yeah, well, it could be useful if you got the coordinates from Applescript, wouldn't it? A translation from screen to document? I'm not AS savvy enough to try it.
Copy link to clipboard
Copied
Window bound will get you from screen to window, but you still have to work out where the page of the document is in terms of the window.

