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

running a user script from a plugin: almost there!

Engaged ,
Dec 22, 2022 Dec 22, 2022

Copy link to clipboard


I've been working on a plugin function that runs a user script, and it seems to work reliably. Here's the code:


	AIActionParamValueRef param;
	AIErr error = kNoErr;
	ActionParamKeyID key1(1769238125);
	std::string val1("_0x60000410dfe0");
	ActionParamKeyID key2(1818455661);
	std::string val2("test_script");
	error = sAIAction->AINewActionParamValue(&param);
	error = sAIAction->AIActionSetString(param, key1, val1.c_str());
	error = sAIAction->AIActionSetString(param, key2, val2.c_str());
	error = sAIAction->PlayActionEvent("adobe_commandManager", kDialogOff, param);
	error = sAIAction->AIDeleteActionParamValue(param);


You can try it by adding a script named "test_script" -- either AS or JS -- to your Scripts folder. The script should show up in your File > Script menu. Also, you must have a document open before running it, or you will get an "Object 'test_script' cannot be found" error.


The wildcard here is the string val1. When I exported my recorded "Insert Menu Item" action it showed string parameter 1 as 5f3078363030303034306337663930, which translates from hex to ascii as "_0x6000040c7f90"


Two questions: Is string parameter 1 a menu item handle? That's not obvious to find via code, since the Scripts menu only populates while the user pulls up the menu. Is there a better way to retrieve this value than by exporting actions?


Question 2: When I add or remove scripts, this code continues to work for me, but does it work for others?


I'm targeting AI 23 through 27. Any comments or suggestions for improvement would be much appreciated.







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

Have something to add?

Join the conversation