• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
1

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

Community Beginner ,
Jun 26, 2022 Jun 26, 2022

Copy link to clipboard

Copied

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

TOPICS
Scripting

Views

1.2K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 2 Correct answers

Community Expert , Jun 26, 2022 Jun 26, 2022

use DoScript instead of DoAction

Votes

Translate

Translate
Community Expert , Jun 27, 2022 Jun 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

Votes

Translate

Translate
Adobe
Community Expert ,
Jun 26, 2022 Jun 26, 2022

Copy link to clipboard

Copied

use DoScript instead of DoAction

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jun 27, 2022 Jun 27, 2022

Copy link to clipboard

Copied

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

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 27, 2022 Jun 27, 2022

Copy link to clipboard

Copied

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-...

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jun 27, 2022 Jun 27, 2022

Copy link to clipboard

Copied

Super useful, thanks alot! 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jun 21, 2023 Jun 21, 2023

Copy link to clipboard

Copied

Hi, 

I tried  DoScript in Autohotkey to trigger Illustrator to call an action named (Split) inside the action set called (Flashman)
my code :

=============

^+x::
if WinActive("ahk_class illustrator")
{
app := ComObjActive("Illustrator.Application")
app.DoScript("Split", "Flashman")
}
return

============

I also tried this code but no luck

^+D::

app := ComObjActive("Illustrator.Application")
doc := app.activeDocument
ie := ComObjCreate("Illustrator.Actions")


ie.DoAction("Split", "Flashman")
return

Could you guide me to make it happen, please?
Thanks a lot.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 21, 2023 Jun 21, 2023

Copy link to clipboard

Copied

this code works fine

^+x::
if WinActive("ahk_class illustrator")
{
app := ComObjActive("Illustrator.Application")
app.DoScript("Split", "Flashman")
}
return

 

what keys are you pressing? can you spell them out?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jun 22, 2023 Jun 22, 2023

Copy link to clipboard

Copied

Thanks for replying
I press ( Control + Shift + X)
It gives me this Error:

------------------------------------
Error: Ox800401F3 - Invalid class string
Line*
COI: Return
003: app ComObjActiveClllustrator.Application•)
004: app.DoScriptCSplit•, •Flashman•)
Return
007: Exit
008: Exit
008: Exit
Continue running the script?

-------------------------------------

In Photoshop this code works fine:

^+x::
if WinActive("ahk_class Photoshop")
{
	mvar := ComObjActive("Photoshop.Application")
	mvar.DoAction("Motion", "Fn")
}
return

I have Illustrator 2021 and Autohotkey V.2 

Thanks for your help

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jun 22, 2023 Jun 22, 2023

Copy link to clipboard

Copied

I think it's an Invalid class string because of this ("illustrator.Application")
I tested it in Microsoft Word as ("Word.Application") and it works 

 

app := ComObjActive("Word.Application")
if !app
    MsgBox "Word isn't open."
else
    MsgBox Word.ActiveDocument.FullName

 

 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jun 22, 2023 Jun 22, 2023

Copy link to clipboard

Copied

Double check the action and folder name, the below code is working fine for me:

 

    #q::
        app := ComObjActive("illustrator.Application")
        app.DoScript("vertical dist space","Mohkhasa")
    return

 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jun 22, 2023 Jun 22, 2023

Copy link to clipboard

Copied

Thanks a lot, CarlosCanto 

, and thanks to you too  Mohkhasa 

I confirm it works fine after I install Illustrator 2023.

Still not working V.2021
Thanks for your time.

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 22, 2023 Jun 22, 2023

Copy link to clipboard

Copied

LATEST

Great! Thanks for sharing your findings

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines