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 37 38 39 40 41 42 43 44
| Option Explicit
'Declare Function GetActiveWindow Lib "user32" () As Long 'on ne s'en sert plus elle fonctionne correctement qu'avec les userform dans l'application excel depuis les system 64 bits
'MODIFIE LAFFICHAGE DE LA FENETRE 3 POUR PLEIN ECRAN
Declare Function ShowWindow Lib "user32" (ByVal hWnd As Long, ByVal nCmdShow As Long) As Long
'pour capter le handle de la fenetre ON NE S EN SERT PAS DANS CET EXERCICE
Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
' pour determiner le texte de la caption de la fentre
Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hWnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
' POUR DETERMIBER QUELLE CLASSE A LA FENTRE ON NE S EN SERT PAS DANS CET EXERCICE
'Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hWnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long
' capter la fenetre suivante dans la hierarchie de l affichage c est la qui est importants dans cet exercice
Declare Function GetNextWindow Lib "user32" Alias "GetWindow" (ByVal hWnd As Long, ByVal wFlag As Long) As Long
'POUR CAPTER LE HANDLE DU DESKTOP QUI EST LE HANDLE 0!!!!!!!!!! on par de celui ci vers les autre avec getnextindow
Declare Function GetDesktopWindow Lib "user32.dll" () As Long
Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
'ta sub il faudra la remtre comme tu l'avais fait
Public Sub Ouvrir_exports()
'Application.DisplayAlerts = False
Dim Chemin As String, zname As String
'Debug.Print Len(ch_exports) = 0
Chemin = "C:\Users\polux\Desktop\Nouveau dossier"
zname = StrReverse(Split(StrReverse(Chemin), "\")(0)) 'on recupere le nom court qui est certainement le nom de la fenetre
'Debug.Print Chemin
ThisWorkbook.FollowHyperlink Chemin, NewWindow:=True
agrandit_fenetre zname
End Sub
Public Function agrandit_fenetre(sname As String)
Dim pointeur As Long, res As String, strBuff As String * 255
Sleep 200 ' un laps de temps pour laisser la fentre arriver
pointeur = GetDesktopWindow() ' on capte le hendle du desktop
pointeur = GetNextWindow(pointeur, 5) 'on saute la taskbar qui est une fenetre aussi et tout y cointi !!!!!
Do
'c'est parti!!!!!!!!!!
DoEvents
res = GetWindowText(pointeur, strBuff, Len(strBuff)) 'on capte le texte de la caption
If Left(strBuff, Len(sname)) = sname Then Exit Do 'on verifie qu'il correspond a notre titre de fenetre: si oui on sort de la boucle
pointeur = GetNextWindow(pointeur, 2) 'on continu on descend dans la hierarchie
Loop Until strBuff = "Progman" 'progman c'est le shelluser window il ne s'arete jamais
'on est sorti alors soit il n'y a pas la fenetre du nom de sname soit elle est trouver alors .....
ShowWindow pointeur, 3 'alors voila
End
End Function |
Partager