How to get the handle of the active window
Posted on January 4, 2009
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | 'System & API - How to get the handle of the active window Option Explicit Private Declare Function GetForegroundWindow Lib "user32" () As Long Private Declare Function GetParent Lib "user32" (ByVal hwnd As Long) As Long Public Function GetActiveWindow(ByVal ReturnParent As Boolean) As Long Dim I As Long, J As Long I = GetForegroundWindow If ReturnParent Then Do While I <> 0 J = I I = GetParent(I) Loop I = J End If GetActiveWindow = I End Function |
Related posts:
- How to get the title of the Active Window
- How to check if a task exists by searching for (part or all of) the window title
- How to bring an external window to top using its caption
- How to get the window title of external application
- How to get Caption and Thread ID of Window under cursor
- How to handle Size & Position of Console Application with Windows Application in VB6
- How to bring our Window to the foreground
- How to clear the text in active control if the active form name is “frmCustomer”
- How to window caption to flash repeatedly
- Check & Terminate Process using Window Title