There is no documented public API combination that lets an ordinary external process authoritatively associate another application’s active TSF composition with a separate MSCTFIME rendering HWND, so this requires explicit application/input-provider cooperation or capture of a surface already covered by the selected Windows Graphics Capture item.
Why the TSF interfaces do not provide the relationship
- A TSF thread manager maintains documents, contexts, and input focus for its thread.
TF_GetThreadMgrobtains a manager previously created within the calling thread, whileITfThreadMgr2operations such as activation, enumeration, and focus are also defined in terms of the calling thread.^1^ ^2^ -
ITfThreadMgr::GetFocusreturns the document manager that has TSF input focus; it does not accept a foreign HWND or provide a system-wide lookup from HWND to another thread’s document manager.^3^ -
ITfContextView::GetWnd,ITextStoreACP::GetWnd, and their equivalents return the window corresponding to the document or text-store view. They may legitimately returnNULL; their contracts do not identify a TIP-owned preedit window.^4^ ^5^ -
ITfCompositionViewrepresents a logical composition and exposes its range and owner CLSID, but no rendering HWND or capturable surface.^6^
Consequently, those interfaces cannot be joined into:
foreign HWND
→ foreign focused ITfContext
→ active ITfCompositionView
→ authoritative rendering HWND
The missing arrows are not public TSF contracts.
Composition lifetime is available only to participating context owners
An application that owns the TSF context can implement ITfContextOwnerCompositionSink. TSF installs that sink while creating the context and calls it for composition start, update, and end.^7^ The application therefore has an authoritative logical lifetime boundary, including commit/cancel termination, but that notification is part of application-side TSF integration—not an external subscription to an arbitrary process.
ITfThreadMgrEventSink similarly reports document-manager/context events such as focus changes and context pushes or pops for the associated thread manager; it does not provide a foreign-HWND association service.^8^
WinEvents are lifecycle hints, not authorization or association
The documented meanings are limited to:
-
EVENT_OBJECT_IME_SHOW: an IME window became visible. -
EVENT_OBJECT_IME_HIDE: an IME window became hidden. -
EVENT_OBJECT_IME_CHANGE: an IME window’s size or position changed. -
EVENT_OBJECT_CREATE/DESTROY: an accessible object was created or destroyed.^9^
WinEventProc says that hwnd is the window generating the event, or NULL, and that idObject/idChild identify its accessible object. It does not define a composition ID, document manager, selected top-level application, or trusted provider identity.^10^
Therefore, these events can trigger rescanning or invalidate a previously observed HWND, but cannot establish that the HWND belongs to the selected application’s current composition. Class names, owner chains, process identity, timing, and matching event sequences remain heuristics.
Supported cooperation models
The selected application can provide a private integration contract that exposes:
- A stable application/document instance identifier.
- A per-composition generation or opaque token.
- The capturable
HWND/surface associated with that generation, if separate. - Start, update, end, focus-loss, surface-replacement, and process-exit notifications.
- An atomic validation operation so the capturer can reject stale HWND reuse.
No particular IPC technology or token format is prescribed by TSF. The association is authoritative because the context-owning application vouches for it, not because the external process inferred it from window topology.
Alternatively, the application can render composition display attributes directly in its captured document surface. Microsoft’s TSF composition model places composition monitoring and display-attribute rendering with the application/context owner.^11^
For cooperating applications and TIPs, TSF UI-less mode offers structured BeginUIElement, UpdateUIElement, and EndUIElement notifications. The application may suppress the TIP’s original UI and render supported UI-element content itself; the TIP must support the UI-element model.^12^ This is in-process TSF participation and may expose candidate/reading content, not an external API for discovering an existing Microsoft IME HWND.
Windows Graphics Capture fallback
On Windows 11 24H2, IncludeSecondaryWindows includes qualifying intersecting WS_POPUP or WS_EX_TOOLWINDOW windows according to documented style and Z-order rules. It does not claim semantic inclusion of every IME window or provide a composition association.^13^
If the IME surface does not qualify and the application/provider does not cooperate, the stated constraints leave no supported authoritative way to add it while excluding unrelated windows.
References
- TF_GetThreadMgr function (msctf.h)
- ITfThreadMgr2 interface (msctf.h)
- ITfThreadMgr::GetFocus method (msctf.h)
- ITfContextView::GetWnd method (msctf.h)
- ITextStoreACP::GetWnd method (textstor.h)
- ITfCompositionView interface (msctf.h)
- ITfContextOwnerCompositionSink interface (msctf.h)
- ITfThreadMgrEventSink interface (msctf.h)
- Event Constants (Winuser.h)
- WINEVENTPROC callback function (winuser.h)
- Compositions
- UILess Mode Overview
- GraphicsCaptureSession.IncludeSecondaryWindows Property-Definition