Running INDD scripts from Autohotkey

Post your working scripts, libraries and tools
Drako
Posts: 30
Joined: 14 Jan 2016, 15:08

Running INDD scripts from Autohotkey

29 Aug 2016, 05:41

HI!

I'm working a lot with InDesign and I always wanted to be able to run an InDesign script directly from Autohotkey however I never managed to. I ended up assigning a shortcut to a script and then have Autohotkey to modify its content, select InDesign and send the shortcut. This was working however it was not what I wanted.
Yesterday a friend figured out how to do it and here it is, in case anyone needs it:

Code: Select all

Enabled := ComObjError(false) ; this is to avoid getting an error in case the script fails and so tha tthe script continues after the INDD script rans (same as run instead of ranwait) use true to make it like run.

ID := ComObjCreate("InDesign.Application")

if script not contains .jsx,.js
	ID.doScript(script `, 1447185511) ; this code is to run visual basic scripts or any exe file
else
	ID.doScript(script `, 1246973031) ; this is for javascript

The variable script contains the full path of the script to be run. The only problem i have with this is that the Autohotkey script does not continue until the InDesign script is fully executed, if anyone knows how to avoid that, please let me know!
S1eepy
Posts: 1
Joined: 06 Oct 2020, 09:24

Re: Running INDD scripts from Autohotkey

06 Oct 2020, 09:41

I made an account just to reply to this 4 year old post, as it saved my day. God I love the internet.

For those in the future trying to automate Indisgn using COM, AHK & JSX and running into;
Error: 0x80020006 - Unknown name.
Specifically: DoJavaScriptFile

Use;

Code: Select all

ID.doScript(script `, 1246973031) ; this is for javascript

Maybe someone in the future will run across this when they need it. So heres some more keywords to help find it
I tried searching for;
  • ComObjCreate Indesign adobe error
    com DoJavaScriptFile Indesign
    com DoJavaScriptFile Syntax
    comobjactive "indesign" -illustrator
    comobjactive indesign error 0x80020006 - Unknown name
swagfag
Posts: 4092
Joined: 11 Jan 2017, 17:59

Re: Running INDD scripts from Autohotkey

08 Oct 2020, 18:40

the Autohotkey script does not continue until the InDesign script is fully executed
if the method is a blocking call, u cant avoid it. launch a separate AHK instance and invoke the method there.
zuzu_kuc
Posts: 35
Joined: 30 Mar 2016, 12:36

Re: Running INDD scripts from Autohotkey

18 Oct 2020, 17:14

can I somehow specify which indesign the script should execute? I have versions 20 and 21 installed and by default I have 20. but when I run the script according to your instructions, version 21 will start.

Return to “Scripts and Functions”

Who is online

Users browsing this forum: Jinpachi, mildruchu and 19 guests