InDesign Scripting
same as Photoshop, Illustrator, AfterEffects, Indesign support javascript scripting for auto task and creating UIs.
scripting reference:
http://www.kahrel.plus.com/indesignscripts.html
http://jongware.mit.edu/idcs6js/
use commandline to ask InDesign run a script
C:\PathToID\InDesign.exe d:\PathToScript\my_script.jsx