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
use DoScript instead of DoAction
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
Copy link to clipboard
Copied
use DoScript instead of DoAction
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
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
Copy link to clipboard
Copied
Super useful, thanks alot!
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.
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?
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
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
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
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.
Copy link to clipboard
Copied
Great! Thanks for sharing your findings