Soyez le premier à donner votre avis sur cette source.
Snippet vu 12 190 fois - Téléchargée 18 fois
#include <Windows.h> #include <stdio.h> // Fonction qui récupère l'URL courante d'Internet Explorer char * GetCurrentURLFromIE(void) { HWND hWnd,hWnd2,hWnd3; // Handles de fenêtre DWORD size; // Taille URL char * pURL=NULL; // Buffer de sortie // Récupération du handle de la fenêtre de IE hWnd = FindWindow("IEFrame",NULL); if (hWnd) { // Parcours de la hiérarchie de classes (merci Spy++) pour trouver l'Edit contenant l'URL hWnd=FindWindowEx(hWnd,0,"WorkerW",NULL); // Fenêtre de travail hWnd=FindWindowEx(hWnd,0,"ReBarWindow32",NULL); // Toolbar hWnd2=FindWindowEx(hWnd,0,"Address Band Root",NULL); // Bandeau, IE 7 if(hWnd2) hWnd=hWnd2; hWnd3=FindWindowEx(hWnd,0,"ComboBoxEx32",NULL); // Combo Box Entendue, pas sous IE8 if(hWnd3) hWnd=hWnd3; hWnd3=FindWindowEx(hWnd,0,"ComboBox",NULL); // Combo Box, pas sous IE8 if(hWnd3) hWnd=hWnd3; hWnd=FindWindowEx(hWnd,0,"Edit",NULL); // Edit contenant l'URL // Récupération de la taille de la chaine et allocation du buffer en conséquence size=SendMessage(hWnd,WM_GETTEXTLENGTH,0,0); pURL=(char *)malloc(size+1); // Get de l'URL SendMessage(hWnd,WM_GETTEXT,size+1,(DWORD)pURL); } return pURL; } int main(int argc, char *argv[]) { char lastURL[MAX_PATH]; // Dernière URL visitée char * pURL=NULL; // URL courante while (1) { // Récupération de l'URL courante dans IE pURL=GetCurrentURLFromIE(); // Si changement, affichage et stockage de l'URL if (pURL!=NULL && stricmp(lastURL,pURL)) { strcpy(lastURL,pURL); printf("URL: %s\n",pURL); } free(pURL); Sleep(500); } return 0; }
Tu ne vois pas de fen$etre? Comment fais-tu pour naviguer dans ce cas?
Comment peut-on voir la classe "IEFrame" d'Iexplore tournant dans une session CITRIX,
en faite dans une session citrix on voit le processus "iexplore" mais on peut pas voir la fenêtre d'ie
il y a un moyen pour énumérer les fenêtres citrix?
Merci
Hayir kaldirmaniz gerekmez. zaten ben kodun düzeltilmis halini vermistim.
Hem IE 6-7 hemde IE 8 için düzeltilmis halidir.
Dikkat ederseniz asagida degistirmis haliyle Edit Compenent araniyor bulursa içerigi okunur bulamazsa, NULL dönrese ComboBox'lari arayacak yine Edit'i bulup içerigini okur.
hWnd2=FindWindowEx(hWnd,0,"Edit",NULL);
if(!hWnd2)
{
hWnd=FindWindowEx(hWnd,0,"WorkerW",NULL);
....
}
else hWnd=hWnd2;
Yanliz unutulmamasi gereken konu malloc ile ayrilmis bellek sisteme geri verilmeli!..
__finally Borland'a ait sonlama, String ise gene borland nesnesi AnsiString'dir siz C++ string sinifi ile geri dönebilirsiniz.
Ben düzeltilmis halini IE 6,7,8 de basariyla kullaniyorum.
Basarilar.
SHURZAN
char * GetCurrentURLFromIE(void)
{
HWND hWnd, hWnd2, hWnd3;
DWORD size;
char * nURL = NULL;
hWnd = FindWindow("IEFrame",NULL);
if (hWnd)
{
hWnd=FindWindowEx(hWnd,0,"WorkerW",NULL);
hWnd=FindWindowEx(hWnd,0,"ReBarWindow32",NULL);
hWnd2=FindWindowEx(hWnd,0,"Address Band Root",NULL);
if(hWnd2)
hWnd = hWnd2;
hWnd3=FindWindowEx(hWnd,0,"ComboBoxEx32",NULL);
if(hWnd3)
hWnd = hWnd3;
hWnd3=FindWindowEx(hWnd,0,"ComboBox",NULL);
if(hWnd3)
hWnd = hWnd3;
hWnd=FindWindowEx(hWnd,0,"Edit",NULL);
size=SendMessage(hWnd,WM_GETTEXTLENGTH,0,0);
nURL=(char *)malloc(size);
}
return pURL;
}
Vous n'êtes pas encore membre ?
inscrivez-vous, c'est gratuit et ça prend moins d'une minute !
Les membres obtiennent plus de réponses que les utilisateurs anonymes.
Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.
Le fait d'être membre vous permet d'avoir des options supplémentaires.