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

Script to access Info panel values -- possible?

Explorer ,
Mar 15, 2020 Mar 15, 2020

Copy link to clipboard

Copied

Specifically the mouse X/Y values....

 

Thanks

Views

682

Translate

Translate

Report

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

correct answers 1 Correct answer

Community Expert , Mar 26, 2020 Mar 26, 2020

Hi Akiva,

finally I put all my ideas for doing "crosshair guides by click" together. Watch my video here:

https://www.dropbox.com/s/rck9mlsn1ah68rf/2020-03-25_17-06-10-AddCrossHairGuides-v10-DEMO.mp4?dl=0

 

The script is creating a helper group that is exported to IDMS and loaded two times to the placeGun of the active document. In the moment the user clicks with the loaded placeGun an eventlistener for "afterPlace" recognizes this. The position of the placed helper group of elements is noticed,

...

Votes

Translate

Translate
Community Expert ,
Mar 17, 2020 Mar 17, 2020

Copy link to clipboard

Copied

Hi Akiva,

I see no direct way.

 

What do you like to achieve in the end?

 

Regards,
Uwe Laubender

( ACP )

Votes

Translate

Translate

Report

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
Explorer ,
Mar 19, 2020 Mar 19, 2020

Copy link to clipboard

Copied

Add guidelines just by clicking on the page

I'd like to add 4 guidelines with 2 clicks -- top left and bottom right

Votes

Translate

Translate

Report

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 ,
Mar 19, 2020 Mar 19, 2020

Copy link to clipboard

Copied

There isn’t a way to listen for a click event, so I don’t think you can use an event listener.

 

You could have a script that draws guides around a selected object.

 

var bds= app.activeDocument.selection[0].geometricBounds

with(app.activeDocument.selection[0].parentPage){
    guides.add(undefined, {orientation:HorizontalOrVertical.vertical,location:bds[1]});
    guides.add(undefined, {orientation:HorizontalOrVertical.vertical,location:bds[3]});
    guides.add(undefined, {orientation:HorizontalOrVertical.horizontal,location:bds[0]});
    guides.add(undefined, {orientation:HorizontalOrVertical.horizontal,location:bds[2]});
}

Votes

Translate

Translate

Report

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
Explorer ,
Mar 20, 2020 Mar 20, 2020

Copy link to clipboard

Copied

You can listen for clicks when text is selected (either an insertion point or actual text) -- I have several right-click extenstions I wrote that do that. 

 

My problem is that I need to add guidelines around PART of a PDF page placed in ID -- to indicate what part of the PDF the facing page is a translation of...

 

Thanks for the suggestion though

Votes

Translate

Translate

Report

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 ,
Mar 17, 2020 Mar 17, 2020

Copy link to clipboard

Copied

If you are using OSX there is an AppleScript OSAX addition that will get and set mouse coordinates. Not sure if it will work with Catalina, but does with HS. AppleScript Toolbox: https://astoolbox.wordpress.com/installation/

 

Screen Shot 15.png

Votes

Translate

Translate

Report

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 ,
Mar 19, 2020 Mar 19, 2020

Copy link to clipboard

Copied

Hi Rob,

also did some experiments.

 

What is working:

Start running a script that would:

1. add a rectangle to the page
2. export the rectangle to an idms file
3. remove the rectangle that was added at step 1
4. load the idms file two times to the placegun
5. remove the idms file
6. add an eventlistener for "afterPlace" to the document.

 

Then click two times wherever you want on the page.
The eventlistener for "afterPlace" will register this and a function will add the guides like crosshairs to the upper left corner position of the placed rectangle.

 

What is not working:
Removing both helper rectangles as part of the function that adds the guides.

If I try to do this I run into the following error with my German InDesign:

 

Error number: 30493

Error message: Das Ziel eines aktiven Skriptereignisses kann nicht gelöscht werden.

Message translated: $ID/kCantDeleteTargetOfActiveScriptEvent

 

Maybe I find a workaround. If yes, I'll post some code tomorrow.

 

Regards,
Uwe Laubender

( ACP )

Votes

Translate

Translate

Report

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 ,
Mar 23, 2020 Mar 23, 2020

Copy link to clipboard

Copied

Hi Akiva,

so you have experience with eventlisteners?

I'd try my idea with loading the placeGun with a helper element like a rectangle or perhaps better, a group of crosshair graphic lines because of the preview in the cursor. Together with a "afterPlace" listener that would add guides to the upper left corner of the placed helper element.

 

Regards,
Uwe Laubender

( ACP )

Votes

Translate

Translate

Report

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 ,
Mar 24, 2020 Mar 24, 2020

Copy link to clipboard

Copied

A second listener that is added to an idleTask, could remove the helper elements.

We could do a counter and a timer as well. The idleTask will be removed after the second helper element was removed or after, let's say, 60 seconds after the timer starts.

 

The timer will start when the first afterPlace event took place or the first helper element was removed by the idleTask.

 

Regards,
Uwe Laubender

( ACP )

Votes

Translate

Translate

Report

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 ,
Mar 26, 2020 Mar 26, 2020

Copy link to clipboard

Copied

Hi Akiva,

finally I put all my ideas for doing "crosshair guides by click" together. Watch my video here:

https://www.dropbox.com/s/rck9mlsn1ah68rf/2020-03-25_17-06-10-AddCrossHairGuides-v10-DEMO.mp4?dl=0

 

The script is creating a helper group that is exported to IDMS and loaded two times to the placeGun of the active document. In the moment the user clicks with the loaded placeGun an eventlistener for "afterPlace" recognizes this. The position of the placed helper group of elements is noticed, at the upper left corner of the placed group two guides are added as crosshairs. The helper group is removed with an idleTask with an eventlistener that is looking for a layer named "Helper Layer" that removes the layer together with its element(s), the group of placed objects.

 

Some screenshots that I did from a video showing this:

 

1. Script is executed by the user with a double-click.

Indicated by the blue circle in the Scripts panel.

 

1-Test-2-v10-Execute-Script.png

 

2. Now watch the loaded cursor where two snippets are loaded. Each with the same contents, a group of straight graphic lines, so that the preview of the cursor is showing something like a crosshair:

2-Test-2-v10-LoadedPlaceGun-TwoSnippets-with-HelperGroup.png

 

3. Immediately after the user clicked, two crosshair guides are added at the upper left corner of the placed helper group. The position is exactly at the tip of the cursor while the user clicks. Also watch the Layers panel. The script added a "Helper Layer" where the placed group is moved to:

 

3-Test-2-v10-AfterClick-HelperGroup-HelperLayer-Visible.png

 

4. A moment later the "Helper Layer" together with the group vanished. The idleTask's eventlistener did that. The cursor is still loaded with the second snippet:

4-Test-2-v10-IdleTask-Removed-HelperLayer.png

 

5. To complete this, the user navigates the curser and clicks a second time:

5-Test-2-v10-AfterSecondClick-HelperGroup-HelperLayer-Visible.png

 

And as before the "Helper Layer" will be removed again by the idleTask's eventlistener.

 

How to get rid of the "afterPlace" eventlistener? Check if there are snippets in the placeGun, if no, remove the listener.

How to stop the idleTask eventlistener? Do a timer after the first snippet is placed so that, after the user clicked the first time to create the crosshair guides, the idleTask is removed after a while; in my case I set that timer to 30 seconds. Half a minute the user has time to complete doing the second pairs of guides. Or if you like to count the events with "afterPlace", do that after the second time that event fired.

 

What else?

With some of my tests I came accross the issue that the preview in the loaded placeGun was the wrong one. Don't know how and why InDesign picked the wrong one, but here is a screenshot I took from a different video:

 

2020-03-25_15-32-05-PlaceGun-PicksUp-Wrong-Preview-BUG-1.png

 

2020-03-25_15-32-05-PlaceGun-PicksUp-Wrong-Preview-BUG-1-1.png

2020-03-25_15-32-05-PlaceGun-PicksUp-Wrong-Preview-BUG-2.png

 

Also note: Listening for events with an idleTask on documents that were never saved is not a good idea.

Had strange error messages. However, dismissing the error messages was no problem. The results were as expected. But for a user this could be very irritating.

 

Regards,
Uwe Laubender

( ACP )

 

PS: Did some edits.

 

 

Votes

Translate

Translate

Report

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
Explorer ,
Mar 27, 2020 Mar 27, 2020

Copy link to clipboard

Copied

LATEST

Thanks -- this gives me what I need to do.

Votes

Translate

Translate

Report

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