Skip to main content
Mohkhasa
Participating Frequently
June 26, 2022
Answered

[Help] Run Illustrator actions directly from AHK(AutoHotKey) script

  • June 26, 2022
  • 1 reply
  • 2297 views

Hello,

 

I am trying to run Illustrator actions directly from AHK(AutoHotKey) script,  just like the below but for Illustrator.

z::
if WinActive("ahk_class Photoshop")
{
	psApp := ComObjActive("Photoshop.Application")
	psApp.DoAction("action name", "action set name")
}
return

 

I tried multiple versions, like the following: but it didn't work

z::
if WinActive("ahk_class illustrator")
{
	aiApp := ComObjActive("illustrator.Application")
	aiApp.DoAction("action name", "action set name")
}
return

 

How can I adjust this command for Illustrator?

 

Thank you

This topic has been closed for replies.
Correct answer CarlosCanto

Illustrator's Object Model is different than photoshop's, so scripts for one app won't work on the other.

 

You can start with the official guides adobe provides

 

check this post for links and resources

https://community.adobe.com/t5/illustrator-discussions/javascript-reference-for-adobe-illustrator/m-p/12911518#M320092

1 reply

CarlosCanto
Community Expert
Community Expert
June 27, 2022

use DoScript instead of DoAction

Mohkhasa
MohkhasaAuthor
Participating Frequently
June 27, 2022

Thank you CarlosCanto, 

 

Do you know any good resources to learn more about this? so I can adjust the below for Illustrator

6::
;ExportJPG
    app := ComObjActive("Photoshop.Application")
    doc := app.activeDocument
    options := ComObjCreate("Photoshop.ExportOptionsSaveForWeb")
    options.Quality := 90
    options.Format := 6 ; 6=jpeg 13=png 17=tif
    options.Optimized := ComObj(0xB, -1) ; 0xB = VT_Bool || -1 = true, 0 = false

    ;inputBox, filename, file name, file name(no extension)
    filename := app.activeDocument

    WinActivate, ahk_class Photoshop
    doc.export(doc.path . filename.name . ".jpg",SAVEFORWEB:=2,options)
    ;this works, but it does
    ;thumb-atx-12-vo.psd.jpg
    ;instead of
    ;thumb atx 12 vo.jpg
return

 

CarlosCanto
Community Expert
CarlosCantoCommunity ExpertCorrect answer
Community Expert
June 27, 2022

Illustrator's Object Model is different than photoshop's, so scripts for one app won't work on the other.

 

You can start with the official guides adobe provides

 

check this post for links and resources

https://community.adobe.com/t5/illustrator-discussions/javascript-reference-for-adobe-illustrator/m-p/12911518#M320092