1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
| Option Compare Database
Option Explicit
'--------------------------------------------------------------------------------------------
'Déclaration des fonctions pour la récupération du titre de la fenêtre active
Private Declare Function GetForegroundWindow Lib "USER32" () As Long
Private Declare Function GetWindowTextLength Lib "USER32" Alias "GetWindowTextLengthA" (ByVal hWnd As Long) As Long
Private Declare Function GetWindowText Lib "USER32" Alias "GetWindowTextA" (ByVal hWnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
'--------------------------------------------------------------------------------------------
Public Sub NomFenetreActive()
On Error Resume Next
NomFenetreActive = GetForegroundWindow
'Récupération de la longueur du titre
Dim length As Long: length = GetWindowTextLength(NomFenetreActive) + 1
'Réservation d'une chaîne de caractères assez grande
Dim buffer As String: buffer = Space$(length)
'Récupération du titre
length = GetWindowText(NomFenetreActive, buffer, length)
'Suppression du caractère \0 final
buffer = Left$(buffer, length)
'Mon Application" correspond au libellé de la barre de titre
If buffer = "Mon Application" Then
'L'application est de nouveau la fenêtre active
'On stoppe le timer
'On exécute le requery
End Sub |
Partager