Running scripts via Visual Basic

Find out why the . goes before the /

Moderator: Paul Tuersley

Post Reply
dvding
Posts: 2
Joined: January 16th, 2009, 3:07 pm

Hey,
I wrote a program in VB that loads a .aep project, then executes a script. Only problem is VB doesn't come with an After Effects library like it does for photoshop, so there isn't a nice clean way of doing this. It can be done, but it's kinda messy.

I had to launch after effects as a windows process, then make a call to shell, passing the script I want to run as an argument. So that works, it launches after effects and begins executing the script. But the problem is that while AE is loading (splash screen.. etc) the script tries to run. It gives an error because at that point the script library isn't yet loaded in AE.

So I have to manually add a delay, say 5 or 10 seconds, to wait for AE to open, then run the script.

Basically, there's no way that Visual Basic can communicate with after effects. So I can't say.. 'wait until after effects loads, then run the script'. It runs the script immediately. So it looks like I need a way of determining when after effects is loaded and ready to run scripts in VB. Or I need an alternate way of launching AE + run script in visual basic beside the method I'm using.

Does anybody know of a way?? Or am I out of luck?? Thanks~
User avatar
lloydalvarez
Enhancement master
Posts: 460
Joined: June 17th, 2004, 9:27 am
Location: New York City, NY
Contact:

If your VB works with Photoshop, try using photoshop to talk to AE through BridgeTalk. It would involve having Photoshop open but it might work.

-Lloyd
dvding
Posts: 2
Joined: January 16th, 2009, 3:07 pm

lloydalvarez wrote:If your VB works with Photoshop, try using photoshop to talk to AE through BridgeTalk. It would involve having Photoshop open but it might work.

-Lloyd
Thanks I haven't thought of that, but seems possible. I'm not too familiar with BridgeTalk so this might be a harder solution than trying to hack it somehow. From what I know bridgetalk can do things like detect selected items in bridge, etc.. But how would it, say, determine AE is open and a composition has fully loaded?

This is probably more of a visual basic question I suppose.. There's gotta be a way VB can know when after effects has loaded. It does, sorta, but it defines "loaded" as meaning that point when the splash screen first begins loading. But if you're trying to run a script, "loaded" should be that point that the composition and all those little panels show up.
User avatar
Atomic
Posts: 157
Joined: April 30th, 2007, 5:55 am
Location: United States, Ohio

You can detect if AE is running via VB, but you have to scan what is called the "Top Level List". Initially AE is launched and returns a handle to your VB program. You can use that handle (technically an hWnd) to scan for children of that window. Once the splash screen loads, the app will come up ready for use. By watching the list (via a Timer) you can determine if the splash is gone. Once it is gone, you can make the assumption that AE can accept your script command.

To identify the name of Splash screen you can use an API Spy program (do a search on http://www.planetsourcecode.com in the VB, not .Net section). Once you know the internal name of the splash window, you can write VB code to search for that name in the top level list. When it disappears, you are good to go.

A simple method is to setup a series of steps that are fired off by a timer.
Step 1: Launch AE. (Wait 10-seconds or what ever it takes on your systme to load).
Step 2: Issue command to AE.

Are you using VB6 or .NET?

I recently went through this with automating Firefox and the ScreenGrab plugin.
"Up And Atom

No...No

Up And At Them!"
Post Reply