Skip to main content
Inspiring
October 4, 2013
Question

Any way to click a button on an effect?

  • October 4, 2013
  • 1 reply
  • 3836 views

Hi there.

I'm trying to figure out a way to simulate a user pressing a button on an effect.  I've seen others asking about this w/o success:

http://forums.creativecow.net/thread/227/23289

http://forums.adobe.com/message/5289079#5289079

Seems like this is not possible to do with an script.  I'm wondering if it could be done via a compiled plugin.  I'm no stranger to writing code, but before I jump down the rabbit hole of making a custom ae plugin (AEGP plugin?) I'd like to know if its even possible.  It seems like it might be done via OS specific libraries, but I was hoping I could do it directly with the AE SDK and avoid special case code for each OS.

Thanks in advance for your help!

-Andy

This topic has been closed for replies.

1 reply

Community Expert
October 5, 2013

hi andy!

welcome to the dork side! (pun intended)

(deep inside, we're all nerds here)

i can think of a few hacks that should do what you want. i can also think of a couple of possible problems with it.

lt goes like this:

what are we up against?

setting a value to a param doesn't cut it.

why?

1. because some pamrams have a cutom data type which both javascript and the sdk api can't set. only the effec't creator knows how to access that data type.

2. some ui elements are custom elements, drawn and handleed by the plug-in and not by AE. such parms trigger operations when the param gets a "you have been mouse clikced!" call, and not when a value is set.

solutions:

1. emulate a mouse click.

if you know the screen coordinates of the button you wish to click you can go nuts on it.

http://www.codeproject.com/Articles/15406/Creating-a-Simple-Autoclicker   (c++ example)

http://stackoverflow.com/questions/6157929/how-to-simulate-mouse-click-using-javascript    (js example. not precise, but you get the picture)

2. emulate the call. (in the case of a param with a custom ui, as in the case of soundkeys)

in the sdk API there's a call called CompletelyGeneric(), with which you can harrass any applied plug-in with a call to one of it's entry point functions.

you can use it to emulate an EVENT call, which tells an effect that one of it's custom UI bits was clicked at certain LOCAL cordinates (local meaning, in it's param's ui coordinates and not screen cordinates. that means these are fixend numbers and are not dependant on AE's location on the screen and many other things).

if you know the param index (easy to find), then most likely you can pull that off.

problems:

if the effect controls window if not front most, then solution #1 is not applicable.

if you're running AE without a gui, then #1 is of course out, and #2 may, under some circomstances the depend on the plug-in and not on you, fail.

you'll just have to try and see.

i hope this answers your question.

:-)

AndyR_Author
Inspiring
October 7, 2013

Hi Shachar,  thanks for all the info!

I've been making some progress on this, but I'm a bit stuck at the moment.

I think there are two issues I'm having…

1.  How do I create a properly configured PF_Event_Extra? Can I setup my AEGP plugin to intercept events the effect ui receives so I can inspect the extra sent to it and create a hand crafted duplicate?

2. Is there any utility/usefulness in having an EffectStream for the property I care about?

So far, I've been able to tell the plugin to launch the about window:

PF_Cmd aboutCmd = PF_Cmd_ABOUT;

A_Time fake_timeT = {0, 100};

ERR(suites.EffectSuite3()->AEGP_EffectCallGeneric(S_my_id, effectH, &fake_timeT, aboutCmd, NULL));

You hinted about the property index being useful.  I have a handle to the property stream with the button I would like to click:

ERR(suites.StreamSuite2()->AEGP_GetNewEffectStreamByIndex(S_my_id, effectH, ParamIndex, &streamH));

What can I do with this stream, can I somehow send a mouse click event directly to the stream?

I noticed in the CCU example project that the entry point is specifically handling the PF_Cmd_EVENT.  Does this mean the Effect I'm trying to interact with must of also implemented handling PF_Cmd_EVENT's as well, or does that come for free with all properties?

Am I way off the map, or am I close?

thanks again,

-Andy

Community Expert
October 7, 2013

let's make something clear.

not only are you NOT off the map, you're advancing at an alarming pace.

are you sure you're new to the AE SDK?

because from the looks of it, your just a LIAR!

let's make some sense of the assumptions made:

1.  How do I create a properly configured PF_Event_Extra? Can I setup my AEGP plugin to intercept events the effect ui receives so I can inspect the extra sent to it and create a hand crafted duplicate?

well, you can't get between an existing layer effect and AE...

you can disect the source code of the "extra" param passed in the EVENT call, or you can run a sample which implements a UI and see what data is passed and when.

(not the whole "extra" structure is filled and valid at every event)

2. Is there any utility/usefulness in having an EffectStream for the property I care about?

So far, I've been able to tell the plugin to launch the about window:

PF_Cmd aboutCmd = PF_Cmd_ABOUT;

A_Time fake_timeT = {0, 100};

ERR(suites.EffectSuite3()->AEGP_EffectCallGeneric(S_my_id, effectH, &fake_timeT, aboutCmd, NULL));

You hinted about the property index being useful.  I have a handle to the property stream with the button I would like to click:

ERR(suites.StreamSuite2()->AEGP_GetNewEffectStreamByIndex(S_my_id, effectH, ParamIndex, &streamH));

What can I do with this stream, can I somehow send a mouse click event directly to the stream?

the AEGP_StreamRefH is very much useful for accessing the stream data. (get value, set value, change name, ect...)

but for our purposes, it's not needed. the param's numerical index will go in the EVENT "extra" structure, along with such data as what part of the param was clicked, and in what window.

before you dive any deeper, you should probably conduct the following experiment:

have your AEGP communicate with the ColorGrid example, which you can monitor internnaly.

have your AEGP send that  sample a call for the EVENT call, and see that you indeed get your delivered pointer as the "extra" param in the event function.

once you get the ColorGrid sample to be your bi7ch, THEN try to affect soundkeys, which is opaque to you and you won't be able to tell what's going wrong.

i'm recommenting ColorGrid and not CCU because it timplements an effects controls window UI, and not a comp UI as the CCU does.

I noticed in the CCU example project that the entry point is specifically handling the PF_Cmd_EVENT.  Does this mean the Effect I'm trying to interact with must of also implemented handling PF_Cmd_EVENT's as well, or does that come for free with all properties?

every effect with a custom UI must implement a PF_Cmd_EVENT handler. otherwise it's custom params UI will be blank and non functional.

all calls (such as draw, click, drag ect..) for all paramas and all parts (title, body) on all windows (ECW, COMP, LAYER) that belong to a certain effect go through this single handler. the params number, part and the rest of the indetifiying stuff, comes in the call's "extra" structure.

so assuming the soundkeys effect uses a custom UI for it's "process" button ( it's it's not standard looking then it has to be a custom UI), the yes, it has to implement that call.

while it doesn't "come free with all properties" (almost nothing does), calling an effect which doesn't implement such a call won't make AE crash and burn. the generic call actually calls the effect's entry point function. if there's no EVENT handler, the call will simply be ignored.