Copy link to clipboard
Copied
What is your way of selecting multiple pages in UI - consecutive or not - so this selection info can be read from the script?
Or how do you select pages from script so selection can be read back.
<Title renamed by MOD>
Copy link to clipboard
Copied
As far as I know, selected items in InDesign panels aren't exposed to scripting.
Copy link to clipboard
Copied
As far as I know, selected items in InDesign panels aren't exposed to scripting.
By @Peter Kahrel
In case of the Pages panel - it is possible to read selection in the script.
But let's make it a brain teaser for today 😉
I can't be the only one who found the solution?
Copy link to clipboard
Copied
No! Uwe laubender has already explained how to play 8 years ago!
https://community.adobe.com/t5/indesign-discussions/active-page-vs-selected-page/m-p/8776559#M35089
(^/)
Copy link to clipboard
Copied
No, my solution is WAY easier - no need to add any TFs or "hope for the best" - WAY less coding required.
Simple
app.selection()
returns selected pages - the same way as if it was bunch of objects selected on the spread.
And you can select pages 1,15,25,55 - or whatever pages you / user wants to select - and you'll get collection of Pages.
And it also works the other way around - you can use:
app.select()
to select bunch of pages.
So, one of the potential uses - let user select bunch of pages - manually - then read this selection, build string for PDF export.
Copy link to clipboard
Copied
Hi @Robert at ID-Tasker , The best you can do is set or get the active page or spread—activePage only returns a single page, not an array of pages:
//make page 2 active
app.activeWindow.activePage=app.activeDocument.pages[1];
//get active page
$.writeln(app.activeWindow.activePage.name)
Also app.activeWindow.activePage can still be unreliable—depends on the zoom level—the frontmost page doesn't always correspond to the selected page in the Pages panel,
Copy link to clipboard
Copied
Copy link to clipboard
Copied
You mean: select pages in the Pages panel?
(^/) The Jedi
Copy link to clipboard
Copied
You mean: select pages in the Pages panel?
(^/) The Jedi
By @FRIdNGE
Both - read selection made manually in the UI and simulate this selection.
Copy link to clipboard
Copied
With nothing selected in the document, and some pages selected in the Pages panel,, app.selection returns undefined. So pages selected in the Pages panel are not exposed to scripting.
Only when you use the Page tool from the Tools panel to select some pages does app.selection return the selected pages.
Sure, you can use app.select() to create an array of selected pages. And then app.selection returns that array.
Copy link to clipboard
Copied
And that's the correct answer 🙂
But, in case of simulating selection of the pages - you need to execute invoke with the correct ID to select Pages Tool first.
I never said it doesn't require one small extra step 😉 but is way easier than creating some temporary TFs - and is very easy to do by the user in the UI.
Copy link to clipboard
Copied
> But, in case of simulating selection of the pages - you need to execute invoke with the correct ID to select Pages Tool first.
No need to invoke(). Not with JavaScript, anyway.
Copy link to clipboard
Copied
> But, in case of simulating selection of the pages - you need to execute invoke with the correct ID to select Pages Tool first.
No need to invoke(). Not with JavaScript, anyway.
By @Peter Kahrel
If you just select pages - you won't be able to read selection back.
Invoke is to make the selection stay and be readable back - for example, you could select some pages, then tell user to select more or unselect some.
Without invoke - you won't be able to read modified selection.
Copy link to clipboard
Copied
I have nothing selected in the document, and in the Tools panel, the selection tool is active.
Then I do
d = app.documents[0];
app.select(d.pages[2]);
app.select(d.pages[4],SelectionOptions.ADD_TO);
And when I then do app.selection, an array with the two selected pages is returned. No invoke() needed.
Copy link to clipboard
Copied
Sorry, just got back home and tested.
invoke() is needed - but even much "earlier" - or user needs to switch to "Page tool" mode himself.
There are two problems - if user won't be in "Pages tool" mode:
1) if you select pages through script then let user select / deselect pages - but user will be in the "Selection tool" mode - you won't get info about changes,
2) if you switch between apps and come back to InDesign - simple ALT+TAB - and user will be in the "Selection tool" mode - you'll loose selection - pages will be selected in the Pages panel - but you'll get empty app.selection.
User HAVE to be in "Page tool" mode BEFORE he starts changing selected pages.
Copy link to clipboard
Copied
Ugh. What a snake-pit scenario.
Copy link to clipboard
Copied
Ugh. What a snake-pit scenario.
By @Peter Kahrel
Unfortunately.
I just tried to test all possible situations.
Copy link to clipboard
Copied
User HAVE to be in "Page tool" mode BEFORE he starts changing selected pages
You can script the tool selection.
app.toolBoxTools.currentTool = UITools.PAGE_TOOL;
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Isn't using invoke() the same?
Not exactly, currentTool is read/write, so you can get and set the tool
//get the current tool
var ct = app.toolBoxTools.currentTool
$.writeln(ct)
//set the current tool
app.toolBoxTools.currentTool = UITools.PAGE_TOOL;
Copy link to clipboard
Copied