Skip to main content
Participant
October 5, 2026
Question

AEGP_GetMainHWND: supported callback context, threading, and HWND lifetime

  • October 5, 2026
  • 1 reply
  • 10 views

Hello After Effects SDK Support,

We are developing an internal native AEGP plug-in for After Effects 2026, using After Effects Plug-in SDK 26.5 on Windows x64.

The plug-in would retrieve the host window handle through AEGP_UtilitySuite6::AEGP_GetMainHWND. An external component would use this handle solely for read-only association with the running After Effects process. No UI manipulation or write automation is involved.

Could you clarify these API contract details?

  1. Supported calling context
    Is calling AEGP_GetMainHWND from a registered AEGP IdleHook officially supported? If not, which AEGP callback or lifecycle point is recommended?

  2. Thread requirement
    Must this function run on the After Effects main/UI thread? If so, which supported AEGP callbacks guarantee that thread context?

  3. Initial availability
    At what lifecycle point is the main window guaranteed to exist? Is this call supported during the plug-in initialization entry point defined by AEGP_PluginInitFuncPrototype, or only afterward? Can a supported call succeed while returning a null HWND?

  4. Lifetime and invalidation
    Is the returned HWND guaranteed to remain valid and unchanged for the lifetime of that After Effects process? If not:

    • Which host/UI events can invalidate or replace it?
    • Is there an AEGP callback or notification for those events?
    • Does Adobe recommend calling AEGP_GetMainHWND again before each use instead of caching it?

Explicit supported/unsupported, thread requirement, and handle lifetime guidance would be helpful. Please point us to an official reference if available.

Thank you.

    1 reply

    Community Expert
    October 5, 2026

    Hi Sebastian.

    1. AEGP_GetMainHWND is definitely supported to be called from the idle hook function.​​​​​​
      ​
    2. generally speaking, all uses of the sdk AEGP suites (with very rare exceptions) are requred to be used during a call rom AE to you plugin, and only on the calling thread. the idle hook function qualifies, as it is a call from AE. idle calls used to be called on the main AE thread, but since 26.5 i think this changed… non the less, the idle calls are still a legitimate time to use AEGP suites.
       
    3. very good question! i’m not sure if the window already exists dring the inital (and only) call to AEGP_PluginInitFuncPrototype. however, the first call to the idle hook function IS after AE has finished all initalization and the window is already displayed.
       
    4. another good question! i’ve never seen the HWND change in mid session… that doesn’t mean this is by design. there is no callback i know of to let you know that hdnale has changed, but i can’t think of any reason for that handle to change under you…
      assuming you’re asking this because you intened to frequently use that handle and wish to avoid the overhead of fetching it repeatedly, i would suggest:
      a) check the performance… fetch it a 10000 times and measure the delay. it might be absolutely negligible and therefore not worth trying to hang on to the handle.
      b) having that handle, perhaps you could add a listener to a “close” event? (again, that seems SO unlikely to me...)

    some side notes:
    1. i think this call only applies to the windows os… if i recall correctly.
    2. since all interactions with AE are required to happen during AE’s calls (i.e, when AE invokes your plugin), you can always get a fresh HWND beofre operating. UNLESS, you wish to use that handle asynchronously on a separate thread, and only interact with AE during it’s calls, in which case i’ll only say AE is VERY fussy about async fiddleing with it outside of it’s calls… just be ware.