J'essai désesperement de recuperer le text d'un control de type "static"
dans une fenetre d'une appli du commerce.
Mon apli externe affiche une fenetree qui contient un dessin (premier
control static) et un texte (deuxieme controle static)
J'arrivie à recuperer le handle du premier control (dessin donc pas de
texte) mais je ne sais pas comment passer au control suivante (mon texte).
Ma demarche est la suivante :
Findwindow pour recuperer le handle de la fenetre ou se trouve les controles
à partir du nom de la fenetre.
findwindowsex pour recupere le handle du premier controle de le fenetre a
partir du handle de la fenetre en precisant le type de class "static"
Je ne sais pas comment passer au control suivant !!!
Cette action est irreversible, confirmez la suppression du commentaire ?
Signaler le commentaire
Veuillez sélectionner un problème
Nudité
Violence
Harcèlement
Fraude
Vente illégale
Discours haineux
Terrorisme
Autre
Zoury
Salut Olivier !
Réutilise FindWindowEx() en lui passant le handle du dernier contrôle "enfant" trouvé dans le deuxième paramètre de la méthode. Il trouvera le contrôle qui suit.
Ex (non testé) : '*** Option Explicit
Private Declare Function FindWindow _ Lib "user32" _ Alias "FindWindowA" _ ( _ ByVal lpClassName As String, _ ByVal lpWindowName As String _ ) As Long
Private Declare Function FindWindowEx _ Lib "user32" _ Alias "FindWindowExA" _ ( _ ByVal hWnd1 As Long, _ ByVal hWnd2 As Long, _ ByVal lpsz1 As String, _ ByVal lpsz2 As String _ ) As Long
Private Declare Function GetWindowTextA _ Lib "user32" _ ( _ ByVal hWnd As Long, _ ByVal lpString As String, _ ByVal cch As Long _ ) As Long
Private Sub Main()
Dim hWndParent As Long Dim hWndChild As Long
' trouve la fenêtre hWndParent = FindWindow(vbNullString, "Options") ' trouve le premier contrôle "static" hWndChild = FindWindowEx(hWndParent, 0, "static", vbNullString) ' trouve le contrôle "static" suivant hWndChild = FindWindowEx(hWndParent, hWndChild, "static", vbNullString) ' affiche le texte du contrôle Debug.Print GetWindowText(hWndChild)
End Sub
Private Function GetWindowText(ByRef hWnd As Long) As String GetWindowText = Space$(256) GetWindowText = Left$(s, GetWindowTextA(hWnd, s, 256)) End Function '***
-- Cordialement Yanick MVP pour Visual Basic
Salut Olivier !
Réutilise FindWindowEx() en lui passant le handle du dernier contrôle
"enfant" trouvé dans le deuxième paramètre de la méthode. Il trouvera le
contrôle qui suit.
Ex (non testé) :
'***
Option Explicit
Private Declare Function FindWindow _
Lib "user32" _
Alias "FindWindowA" _
( _
ByVal lpClassName As String, _
ByVal lpWindowName As String _
) As Long
Private Declare Function FindWindowEx _
Lib "user32" _
Alias "FindWindowExA" _
( _
ByVal hWnd1 As Long, _
ByVal hWnd2 As Long, _
ByVal lpsz1 As String, _
ByVal lpsz2 As String _
) As Long
Private Declare Function GetWindowTextA _
Lib "user32" _
( _
ByVal hWnd As Long, _
ByVal lpString As String, _
ByVal cch As Long _
) As Long
Private Sub Main()
Dim hWndParent As Long
Dim hWndChild As Long
' trouve la fenêtre
hWndParent = FindWindow(vbNullString, "Options")
' trouve le premier contrôle "static"
hWndChild = FindWindowEx(hWndParent, 0, "static", vbNullString)
' trouve le contrôle "static" suivant
hWndChild = FindWindowEx(hWndParent, hWndChild, "static", vbNullString)
' affiche le texte du contrôle
Debug.Print GetWindowText(hWndChild)
End Sub
Private Function GetWindowText(ByRef hWnd As Long) As String
GetWindowText = Space$(256)
GetWindowText = Left$(s, GetWindowTextA(hWnd, s, 256))
End Function
'***
Réutilise FindWindowEx() en lui passant le handle du dernier contrôle "enfant" trouvé dans le deuxième paramètre de la méthode. Il trouvera le contrôle qui suit.
Ex (non testé) : '*** Option Explicit
Private Declare Function FindWindow _ Lib "user32" _ Alias "FindWindowA" _ ( _ ByVal lpClassName As String, _ ByVal lpWindowName As String _ ) As Long
Private Declare Function FindWindowEx _ Lib "user32" _ Alias "FindWindowExA" _ ( _ ByVal hWnd1 As Long, _ ByVal hWnd2 As Long, _ ByVal lpsz1 As String, _ ByVal lpsz2 As String _ ) As Long
Private Declare Function GetWindowTextA _ Lib "user32" _ ( _ ByVal hWnd As Long, _ ByVal lpString As String, _ ByVal cch As Long _ ) As Long
Private Sub Main()
Dim hWndParent As Long Dim hWndChild As Long
' trouve la fenêtre hWndParent = FindWindow(vbNullString, "Options") ' trouve le premier contrôle "static" hWndChild = FindWindowEx(hWndParent, 0, "static", vbNullString) ' trouve le contrôle "static" suivant hWndChild = FindWindowEx(hWndParent, hWndChild, "static", vbNullString) ' affiche le texte du contrôle Debug.Print GetWindowText(hWndChild)
End Sub
Private Function GetWindowText(ByRef hWnd As Long) As String GetWindowText = Space$(256) GetWindowText = Left$(s, GetWindowTextA(hWnd, s, 256)) End Function '***
-- Cordialement Yanick MVP pour Visual Basic
olivier
ça marche nickel , merci !!!!!
olivier
"Zoury" <yanick_lefebvre at hotmail dot com> a écrit dans le message de news:
Salut Olivier !
Réutilise FindWindowEx() en lui passant le handle du dernier contrôle "enfant" trouvé dans le deuxième paramètre de la méthode. Il trouvera le contrôle qui suit.
Ex (non testé) : '*** Option Explicit
Private Declare Function FindWindow _ Lib "user32" _ Alias "FindWindowA" _ ( _ ByVal lpClassName As String, _ ByVal lpWindowName As String _ ) As Long
Private Declare Function FindWindowEx _ Lib "user32" _ Alias "FindWindowExA" _ ( _ ByVal hWnd1 As Long, _ ByVal hWnd2 As Long, _ ByVal lpsz1 As String, _ ByVal lpsz2 As String _ ) As Long
Private Declare Function GetWindowTextA _ Lib "user32" _ ( _ ByVal hWnd As Long, _ ByVal lpString As String, _ ByVal cch As Long _ ) As Long
Private Sub Main()
Dim hWndParent As Long Dim hWndChild As Long
' trouve la fenêtre hWndParent = FindWindow(vbNullString, "Options") ' trouve le premier contrôle "static" hWndChild = FindWindowEx(hWndParent, 0, "static", vbNullString) ' trouve le contrôle "static" suivant hWndChild = FindWindowEx(hWndParent, hWndChild, "static",
vbNullString)
' affiche le texte du contrôle Debug.Print GetWindowText(hWndChild)
End Sub
Private Function GetWindowText(ByRef hWnd As Long) As String GetWindowText = Space$(256) GetWindowText = Left$(s, GetWindowTextA(hWnd, s, 256)) End Function '***
-- Cordialement Yanick MVP pour Visual Basic
ça marche nickel , merci !!!!!
olivier
"Zoury" <yanick_lefebvre at hotmail dot com> a écrit dans le message de
news:uvJvmEEcFHA.1044@TK2MSFTNGP10.phx.gbl...
Salut Olivier !
Réutilise FindWindowEx() en lui passant le handle du dernier contrôle
"enfant" trouvé dans le deuxième paramètre de la méthode. Il trouvera le
contrôle qui suit.
Ex (non testé) :
'***
Option Explicit
Private Declare Function FindWindow _
Lib "user32" _
Alias "FindWindowA" _
( _
ByVal lpClassName As String, _
ByVal lpWindowName As String _
) As Long
Private Declare Function FindWindowEx _
Lib "user32" _
Alias "FindWindowExA" _
( _
ByVal hWnd1 As Long, _
ByVal hWnd2 As Long, _
ByVal lpsz1 As String, _
ByVal lpsz2 As String _
) As Long
Private Declare Function GetWindowTextA _
Lib "user32" _
( _
ByVal hWnd As Long, _
ByVal lpString As String, _
ByVal cch As Long _
) As Long
Private Sub Main()
Dim hWndParent As Long
Dim hWndChild As Long
' trouve la fenêtre
hWndParent = FindWindow(vbNullString, "Options")
' trouve le premier contrôle "static"
hWndChild = FindWindowEx(hWndParent, 0, "static", vbNullString)
' trouve le contrôle "static" suivant
hWndChild = FindWindowEx(hWndParent, hWndChild, "static",
vbNullString)
' affiche le texte du contrôle
Debug.Print GetWindowText(hWndChild)
End Sub
Private Function GetWindowText(ByRef hWnd As Long) As String
GetWindowText = Space$(256)
GetWindowText = Left$(s, GetWindowTextA(hWnd, s, 256))
End Function
'***
"Zoury" <yanick_lefebvre at hotmail dot com> a écrit dans le message de news:
Salut Olivier !
Réutilise FindWindowEx() en lui passant le handle du dernier contrôle "enfant" trouvé dans le deuxième paramètre de la méthode. Il trouvera le contrôle qui suit.
Ex (non testé) : '*** Option Explicit
Private Declare Function FindWindow _ Lib "user32" _ Alias "FindWindowA" _ ( _ ByVal lpClassName As String, _ ByVal lpWindowName As String _ ) As Long
Private Declare Function FindWindowEx _ Lib "user32" _ Alias "FindWindowExA" _ ( _ ByVal hWnd1 As Long, _ ByVal hWnd2 As Long, _ ByVal lpsz1 As String, _ ByVal lpsz2 As String _ ) As Long
Private Declare Function GetWindowTextA _ Lib "user32" _ ( _ ByVal hWnd As Long, _ ByVal lpString As String, _ ByVal cch As Long _ ) As Long
Private Sub Main()
Dim hWndParent As Long Dim hWndChild As Long
' trouve la fenêtre hWndParent = FindWindow(vbNullString, "Options") ' trouve le premier contrôle "static" hWndChild = FindWindowEx(hWndParent, 0, "static", vbNullString) ' trouve le contrôle "static" suivant hWndChild = FindWindowEx(hWndParent, hWndChild, "static",
vbNullString)
' affiche le texte du contrôle Debug.Print GetWindowText(hWndChild)
End Sub
Private Function GetWindowText(ByRef hWnd As Long) As String GetWindowText = Space$(256) GetWindowText = Left$(s, GetWindowTextA(hWnd, s, 256)) End Function '***