Skip to main content
Known Participant
May 13, 2015
Answered

Is there a way to clear or delete actions through scripting?

  • May 13, 2015
  • 1 reply
  • 8759 views

Hello Everyone!

Menu Commands Outline Stroke

I'm trying to make a script that will clear and then reload actions to try to get around that bug. Thanks to quertyfly and moluapple I now know how to make actions through script so all I need to know if there is a way to clear actions through script.

Thanks Everyone!

This topic has been closed for replies.
Correct answer Qwertyfly___

as a place to get started.

do we even know if sendScriptMessage can do anything with the ActionPalette?

if you know of an example that can achieve something then we would have somewhere to start.


Woo Hoo....

feeling a bit stupid that I had not tried this.

But it works.

You don't even need to first unload each action

to remove a set...

app.unloadAction('Test Set','');

now to activate the file menu...

1 reply

Qwertyfly___
Braniac
May 14, 2015

this is a tricky one...

initial problem:

scripts can be added to an action so we can run via a keyboard shortcut,

BUT, on restart the scripts are not loaded back into the action.

added issue:

removing the action set and loading it again from a saved '.aia' file does not work.

To get this to work we first need to wake the illustrator script menu.(dumbfounded expression)

This is just a matter of opening the File menu. (I do this by pressing "ALT" then "f" then "ESC")

now the actions can be loaded and attached scripts will be linked in correctly.

What we Can do:

We can add an action set and actions to the action panel via a script.

We can load the above actions using a Startup script.

We can unload a script from the actions panel.

What we Can't do: ( or more to the point, What I Can't work out how to do:...)

I can't work out how to remove an action set.

When actions are added via a startup script, it does not register any linked scripts

I can't work out how to activate the file menu via a script.

Known Participant
May 14, 2015

Thanks for your help, I definitely learned something.

I was ignorant on the real cause of the script actions not registering when you reloaded them. On my own trial and error I found a way that always worked, by opening a new file (through the menu), and then loading the actions. I thought by opening a file via script, then loading the actions, then closing the file it would solve the not registering issue. I now know that I was wrong, opening a file does nothing, like you said, all that matters is opening the file menu. I tested this by instead of going to file < new through the menu like I would always do, I hit control N for a new file instead, then I loaded my script actions, and none of them registered.

So crap, that is another issue I was not prepared for haha. So we are two steps away instead of one.

Silly-V
Braniac
October 19, 2015

The issue with this approach is to do with when things run.

we tend to lose control as we are now running 2 threads.

if you run the executeMenuComand then we get the script pausing till the dialog is dismissed.

so run the SendKeys function first, so it is in play before the dialog has displayed.

but if the dialog gets delayed for any reason I don't think the sendKeys will are going to wait for it to arrive.

the vb should really be testing for the window to be displayed before it starts sending the keys.

not sure if I have this correct or not.

but I think I am at least on the right track.


Right, and if checking is even possible, it's a coon new level of complexity to do both in mac and pc. However, if a generic function is created, it could be used to take care of many cases.

Speaking of which, I wanted to add to the "Action Re-loader" on the Mac part, but my .applescript always opens in the script editor vs running. I have worked around this before by always having an executing .app file which does run when used .execute() on, and I made it always open up a written .scpt file ( which I think is the same as .applescript)  in the script editor , play it and then delete it. Looking for a smarter way which can still accept an applescript string as an argument to make it possible to run any dynamically written applescript.