2009-08-10 9 views
1

Est-il possible d'obtenir HWND de fenêtre actuellement focalisée? Pour toute la station Windows, pas l'application actuelle. L'application cible est Win32. Je peux obtenir la fenêtre courante en utilisant: GetForegroundWindow() cependant, ceci est la fenêtre principale seulement. Je peux énumérer les fenêtres enfants, mais comment déterminer si elle est ciblée?Mise au point à l'échelle du système

Répondre

2
HWND RemoteGetFocus() 
{ 
    HWND hwnd = GetForegroundWindow(); 
    DWORD remoteThreadId = GetWindowThreadProcessId(hwnd, NULL); 
    DWORD currentThreadId = GetCurrentThreadId(); 
    AttachThreadInput(remoteThreadId, currentThreadId, TRUE); 
    HWND focused = GetFocus(); 
    AttachThreadInput(remoteThreadId, currentThreadId, FALSE); 
    return focused; 
} 
+0

Brilliant! Merci! –

Questions connexes