Skip to main content
dublove
Legend
July 30, 2026
Question

How to generate static captions and switch the operation object to the captions?

  • July 30, 2026
  • 7 replies
  • 32 views

I have currently selected multiple images, and I want to use a script to generate captions. 

After generating static captions, automatically select the captions as the operating objects.
In the future, I will make other adjustments to the captions.


 

 

    7 replies

    babarbrohio
    Participating Frequently
    July 30, 2026

    That sounds like a useful workflow improvement. It would be especially helpful if the script could automatically switch the selection from the images to the newly created captions, making it easier to apply additional formatting or positioning changes right away. Saving those extra clicks can make a big difference when working with large batches of images.

    rob day
    Community Expert
    Community Expert
    July 30, 2026

    Hi ​@dublove , I think you will have to select the image’s parent frame and invoke the Generate Live Caption menu item

     

    var img = app.activeDocument.allGraphics
    //select the document’s first image frame
    app.select(img[0].parent)
    //invoke generate live caption
    var makeCap = app.menuActions.itemByName("Generate Live Caption")
    makeCap.invoke();
    //caption is the active page’s top textframe
    app.activeDocument.select([app.activeWindow.activePage.textFrames[0]])

     

     

    dublove
    dubloveAuthor
    Legend
    July 30, 2026

    Hi ​@rob day 

    It seems wrong, the content is unknown before generating the caption.
    It can be applied to any number of images.

     

    The process is as follows:
    I selected multiple images, ran the script, generated captions for each image, and then selected all captions.

    Equivalent to performing menu operations:

     

    rob day
    Community Expert
    Community Expert
    July 30, 2026

    My example just shows how to create a caption for the first image in the document. If you want to add captions to a range of images you would need a loop. This would get all the graphics in the document. You can not select objects that are on different spreads

     

    var img = app.activeDocument.allGraphics
    for (var i = 0; i < img.length; i++){
    app.select(img[i].parent)
    var makeCap = app.menuActions.itemByName("Generate Live Caption")
    makeCap.invoke();
    };