Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

[JS] Get Mouse Cursor Position

New Here ,
Dec 16, 2009 Dec 16, 2009

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

TOPICS
Scripting
2.8K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Dec 16, 2009 Dec 16, 2009

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 16, 2009 Dec 16, 2009

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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Dec 16, 2009 Dec 16, 2009

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 17, 2009 Dec 17, 2009

Look at LayoutWindow.bounds -- "The bounds of the window (specified in pixels) in the form [top, left, bottom, right]."

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 17, 2009 Dec 17, 2009

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 17, 2009 Dec 17, 2009

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Dec 17, 2009 Dec 17, 2009
LATEST

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines