Copy link to clipboard
Copied
Copy link to clipboard
Copied
You can't do what you're trying to do. That API is purely so you can create & manage your own panels, not manipulate other plugin's panels.
There is no C++ API for interacting with the UI of any shipped pluign directly.
Copy link to clipboard
Copied
It's possible to record an action for that, so it's probably also possible to create and run that action on the fly. If you search this forum, I'm sure you'll find it.
Copy link to clipboard
Copied
That's a fair answer. Playing an action is often a workaround to a missing C++ API, though it can come with constraints. For something like this though, it probably does the job. @Rick E Johnson is right as well about examples on the forum: I know I've read & answered many questions on PlayAction, just do a search for that.
Copy link to clipboard
Copied
One issue when using actions this way is that you won't get back much meaningful information, just an error code. If the action creates or changes art, it will be selected -- the same is true for the swatches in your case. You will have to figure out for yourself if the action did anything useful.
Copy link to clipboard
Copied
Hi Rick E Johnson,
Thanks for the help!!!
How to create new action to trigger “Select All Unused” flyout menu of swatches panel in illustrator sdk using c++
Can you please provide sample code for this.
Copy link to clipboard
Copied
This post on this forum isn't specifically about swatches, but will show you how to create and run a path offset action on the fly.
The SDK header AIActionManager.h has a lot of helpful information in it, as well as the Tutorial project in the SDK sample code.
If you record your menu selection as an action, then save the actions and open your .aia file, you can see the values the action manager needs.
/action-28 {
/name [ 11
737761746368206d656e75
]
/keyIndex 0
/colorIndex 0
/isOpen 1
/eventCount 1
/event-1 {
/useRulersIn1stQuadrant 0
/internalName (ai_plugin_swatches)
/localizedName [ 8
5377617463686573
]
/isOpen 0
/isOn 1
/hasDialog 0
/parameterCount 1
/parameter-1 {
/key 1835363957
/showInPalette 4294967295
/type (enumerated)
/name [ 17
53656c65637420416c6c20556e75736564
]
/value 11
}
}
}
In the "name" field, note that 53656c65637420416c6c20556e75736564 translates from hex to ascii as "Select All Unused"
I haven't tested this code, but it should at least give you a good start. I use a lot of std::string, but you'll likely want to use char* instead.
AIActionParamValueRef param;
AIErr error = kNoErr;
ActionParamKeyID key(1835363957);
std::string val("Select All Unused");
error = sAIAction->AINewActionParamValue(¶m);
error = sAIAction-> AIActionSetEnumerated(param, key, val.c_str(), 11);
error = sAIAction->PlayActionEvent("ai_plugin_swatches", kDialogOff, param);
error = sAIAction->AIDeleteActionParamValue(param);
Copy link to clipboard
Copied
Hi Rick E Johnson,
It's working fine, Thanks for the help!!!