3

I've created Actions that include scripts (by using Insert Menu Item). I managed to get the scripts to show up in the menu by adding them to the folder ~\Presets\en_US\Scripts in my Illustrator directory.

The issue is that every Illustrator is restarted, the line in the Action that executes the script is gone. I suppose it is because there's a moment while Illustrator is launching before it checks that folder for scripts that it looks like that line is pointing to an item that isn't there.

I know this is an obscure question, but has anyone encountered this? And does anyone know a workaround?

(Or even a better way to assign a hotkey to a script would probably be fine)

4

Yes its a well known limitation. There is no good workaround. Adobe has refused to fix this bug for some reason. For a very long time too, read more than 5 years. Ive been told that even very high profile clients have requested this in direct talks with adobe. Believe or not.

You can delete and reload the actions and they will work. You can even write a plugin that does this automatically, but the only way i know how to do this breaks adobes license so i dont do it. You can not map hotkeys for scripts for some reason.

Alternatively you can just use auto hotkey to circumvent the problem.

  • Does it break the license due to 'reverse engineering' clause? Otherwise, what is the issue? – Silly-V Sep 16 '16 at 16:17
  • @Silly-V Bingo! Yes that is the problem indeed. – joojaa Sep 16 '16 at 16:28
4

[Now FIXED: Illustrator CC2017 October update!]

The problem has been going on forever, it's due to the need to physically-visually show the File menu so that the scripts that are installed in the scripts folder of Adobe Illustrator are visible. Only then can you re-load the actions which contain the scripts by loading the action sets, to get the working script menu items back. A light-weight semi-automatic scripting way can be used in versions CS6+ to save some clicks: it depends on your action sets being saved in a pre-determined folder. It also needs to be installed as a script in your File > Scripts menu. Once it is there, it works by having you manually activate this script through the file menu which by definition shows the file menu. Since the menu is shown at the point of the script activation, the actions which are automatically reloaded by the script will be working.

 #target illustrator
function ReloadActions(){
    function removeActionSet(setName){
        var errorFlag = false;
        while(!errorFlag){
            try {
                app.unloadAction(setName, "");
            } catch (e) {
                errorFlag = true;
            }
        }
    };
    function loadActionSet(aiaFile){
        app.loadAction(aiaFile);
    };
    function reloadActionSet(aiaFile, setName){
        removeActionSet(setName);
        loadActionSet(aiaFile);
    };
    if((app.version.substr(0, 2) * 1) < 16){
        alert("Sorry, the Action Reloader script only works in versions CS6 and above.");
        return;
    }
    var actionFolder = Folder(Folder.myDocuments + "/" + "Illustrator Actions");
    if(!actionFolder.exists){
        alert("The folder for script-reloadable Actions is not found at '" + decodeURI(actionFolder) + "'");
        return;
    }
    var fileMask = ($.os.match("Windows"))? "*.aia" : function(f){return f.name.match(/\.aia$/);}
    var actionFiles = actionFolder.getFiles(fileMask);
    var thisFile, thisSetName;
    for (var i = 0; i < actionFiles.length; i++) {
        thisFile = actionFiles[i];
        thisSetName = decodeURI(thisFile.name).replace(".aia", "");
        reloadActionSet(thisFile, thisSetName);
    }
};
ReloadActions();
  • You know you can do/launch this in vbscipt or applescript. Then launch it on load and put a timer waiting say a minute and trigger after that. Offcourse its a bit of a cludge. – joojaa Sep 16 '16 at 17:29
  • Yes - but due to all the issues, I choose to stop peddling this solution at this level. (Some issues are not even readily apparent: some email clients will not send .vbs files via email, so you have to change the extension or paste the script text into the email ) Well, in this case, if the goal is to simply trigger scripts via shortcut, you might as well use like you said AHK on Windows or Keyboard Maestro on Mac, etc. – Silly-V Sep 16 '16 at 21:24
  • Agreed. This is also ond reason why i abandoned the plugin as it became later possible to do this. But maintaining the plugin is not free and i can live without the hotkeys. Anyway if you make a plugin with your own menuitems launcing scripts you also do not have problems. – joojaa Sep 16 '16 at 21:31
  • Oh and by the way you can write same scripts without VBS in say python or c# if you wish same applies to appliescript as VBS api is actually a COM api which works the same as VBS and applescript is a similar api. Just a common lie to children to say that its for visual basic or applescript. – joojaa Sep 16 '16 at 21:34
  • True - I hear that .aip plugins are most affected by version changes, etc. I suppose logically this makes sense as the Extendscript is an abstracted layer for the app functionalities, and OS scripts which do menu items are further abstracted to 'bot' level. On a different subject - Hey I am learning all about this stuff and want to get into the AI SDK - using C# and Visual Studio 2015 - you think it's possible? Their developer PDF says VS 2010... – Silly-V Sep 16 '16 at 21:38

Not the answer you're looking for? Browse other questions tagged or ask your own question.