By default, Adobe Script Runner is set up for After Effects. To configure it for InDesign, open Keyboard Shortcuts, search for "adobescriptrunner", and reset the keybinding for Command+R to be for InDesign. Refer to this guide for help with binding keyboard shortcuts.
Now it's time to write your first script! Now's the time to make sure you have InDesign open.
Open a new text file (Command+N), and paste the script below into it.
When you press Command+R, you should get this popup in InDesign.
And that's all there is to it! Happy coding!
I'm a software developer and comic book letterer living in NYC. I have a CS degree from NYU and strong opinions on science fiction.