Search code examples
javascriptadobe-indesign

How can I get the first character after the selected text in InDesign?


I want to get the two characters surrounding my selected text in indesign.

I can get the character right before the selection with:

var myStory = app.selection[0].parentStory;
var myIndex = app.selection[0].index;

var myChar1 = myStory.characters[myIndex-1];

How can I get the first character right after the selection?


Solution

  • I got it to work with this:

    var myStory = app.selection[0].parentStory;
    var myIndex = app.selection[0].index;
    
    var toplam = app.selection[0].characters.length;
    
    var myChar1 = myStory.characters[myIndex-1];
    var myChar2 = myStory.characters[myIndex+toplam];