Les déclarations des API utilisées
Declare Function GetForegroundWindow Lib "user32" () As Long
Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long |
Pour retrouver le handle de la fenetre au premier plan
GetForegroundWindow()
Pour récupérer le titre
Dim sTitre as string
sTitre = String(GetWindowTextLength(hw) + 1, Chr$(0))
GetWindowText hw, sTitre, Len(sTitre)
sTitre = Left$(sTitre, InStr(sTitre, Chr$(0)) - 1)
J'ai fait ça vite, j'espère que j'ai rien oublié