ATOUTFOX
COMMUNAUTÉ FRANCOPHONE DES PROFESSIONNELS FOXPRO
Visual FoxPro : le développement durable

8 petits programmes d'automation internet explorer   



L'auteur

ybenam
Algérie Algérie
Membre Simple
# 0000002080
enregistré le 21/04/2008


Fiche personnelle


Note des membres
pas de note

Contributions > 09 - Automation > Internet Explorer

8 petits programmes d'automation internet explorer
# 0000000600
ajouté le 03/06/2008 20:24:15 et modifié le 03/06/2008
consulté 9564 fois
Niveau initié

Version(s) Foxpro :
VFP 6.0

Description
Dans la continuité de l'automation du navigateur Internet explorer ,sous VFP6.0 ici, ci joint 8 programmes à exécuter en séparé et en connection internet pour vous aider à maitriser maître IE. Vous pouvez les rajouter au contenu du ZIP déja posté sur l'automation Iexplore. Programmes testés mais me signaler tout bug pour répercuter la correction sur la communauté Fox( si elle nous regarde !) Cordialement ........... benameuryousfi1@gmail.com
Code source :
cr=chr(13)
***************************************************************************************
*Programme 1  Ajouter un lien internet aux favoris   méthode 1
libelle="Atoutfox "
URL="http://www.atoutfox.org/"
x1=libelle
yPath=createObject("WScript.Shell")
aa=yPath.specialFolders("Favorites")+"\"    &&récupère le chemin du dossier des Favoris
Fichier = aa+allt(libelle) +".url"         &&confectionne une chaîne de nom de fichier
x="[internetShortcut]"+chr(13)+"URL="+URL   &&chaine à écrire dans le fichier (extension URL)
=strtofile(x,fichier)
****************
* &&Ajouter un lien internet aux favoris   méthode 2  (déja posté )
libelle="Atoufox Identification"
URL="http://www.atoutfox.org/login.asp"

xShell = createObject("WScript.Shell")
yPath = xShell.specialFolders("Favorites")
Raccourci = xShell.createShortcut(yPath + "\"+libelle+".lnk")
Raccourci.targetPath = URL
Raccourci.Save
messagebox("Votre lien favori 1 :"+x1 +cr+"Votre lien favori 2 :"+libelle+cr+;
" ont été rajoutés au menu favoris Iexplore."+cr+"Ouvrir IE et dérouler le menu Favori pour ;
les voir "
+cr+cr+"(pour supprimer... clic droit sur l'item menu et suppression)",0+32,"Création terminée")
********************************************************************************
*Programme2  récupérer le nom d'une page Web Atoutfox
apIE =createObject("internetexplorer.application")
apIE.navigate("http://www.Atoutfox.org/")
apIE.visible=.f.
do while apIE.busy or apIE.readystate#4
enddo
messagebox("Nom de la page Web="+apIE.locationName)
apIE.Quit
********************************************************************************
*Programme 3 Boucler sur toutes les images d'une page Web sans l'afficher
xURL="http://www.atoutfox.org/"
cr=chr(13)
_screen.windowstate=1
apIE = createObject("internetExplorer.Application")
apIE.Visible = .f.
apIE.navigate(xURL)
do while  apIE.busy or apIE.readystate#4
enddo

oo = apIE.document
*compte le nombre d'images dans la page
xim="Url="+xUrl+cr+"Nombre d'images dans la page : " +allt( str(oo.images.Length)) +cr+cr

For i = 0 To oo.images.Length - 1      &&boucle sur les images
imgHtml = oo.images.Item(i)
xim=xim+"Adresse image:"+ allt(imgHtml.src) +spac(5)+ "W="+allt(str(imgHtml.Width))+" px"+spac(5)+ "h="+allt(str(imgHtml.Height))+" px"+cr
Next i

apIE.document.parentWindow.alert("Vous pouvez récupérer ce contenu dans le presse papier"+cr+xim)
_cliptext=xim
apIE.quit
****************************************************************************************************
*Programme 4  Liste de tous les liens d'une page WEB IE invisible
xURL="http://www.atoutfox.org/"
cr=chr(13)
_screen.windowstate=1
apIE = createObject("internetExplorer.Application")
apIE.Visible = .f.
apIE.navigate(xURL)
do while  apIE.busy or apIE.readystate#4
enddo

oo= apIE.document
xx=allt(str(oo.links.Length)) +" liens trouvés dans "+xURL+cr +cr

For i =0 to oo.links.Length - 1
xx=xx+ allt(str(i))+". "+oo.Links.Item(i).toString+cr
Next
apIE.document.parentWindow.alert("Vous pouvez récupérerer ce contenu dans le presse papier (Notepad et coller)"+cr+xx)
_cliptext=xx

apIE.quit
********************************************************************************
*Programme 5 Enregistrer une page web dans un document  word -Attention certains sites utilisent des scripts
* pour interdire l'enregistrement ou pour le rendre illisible.

xURL="http://www.atoutfox.org/"
#define wdOrientLandscape  1
oWord = createObject("word.application")
oWord.Visible =.t.
oDocument = oWord.Documents.Open(xURL)
With oDocument
.pageSetup.Orientation = 1
.saveAs("C:\yAtoutFox.doc")
EndWith

********************************************************************************
*Programme 6 Lister les fenetres Internet Explorer ouvertes
*Remarque:les fenêtres de l'explorateur Windows sont prises en compte étant un cas particulier Iexplore

cr=chr(13)
oShell = createObject("Shell.Application")
j=0
xx=""
For Each apIE In oShell.Windows
If len(apIE.LocationURL)>0
j=j+1
xx=xx+apIE.LocationURL+cr
*apIE.Quit   &&option pour les fermer
endi
Next apIE
messagebox(allt(str(j))+" Fenêtre(s) IExplore ouverte(s) :"+cr+xx)
 Wn =null
 Sh = Null

********************************************************************************
*Programme 7
_screen.windowstate=1
declare integer Sleep in win32api integer

     *Rafraichir une page Web
apIE =createObject("internetexplorer.application")
apIE.navigate("http://www.Atoutfox.org/")
apIE.visible=.t.
do while apIE.busy or apIE.readystate#4
enddo
apIE.document.parentWindow.alert("La page web a été chargée! attendez la suite !")
***************
apIE.ExecWB(22 ,2 )      &&Constantes OLECMDID_REFRESH, OLECMDEXECOPT_DONTPROMPTUSER marchent sans #define
sleep(4000)
apIE.document.parentWindow.alert("Cette page web a été raffraîchie!")
***************
     *Changer le titre de la page html
*apIE = createObject("internetExplorer.Application")
*apIE.Visible = .t.
*apIE.navigate ("http://www.atoutfox.org/")
*do while apIE.busy or apIE.readystate#4
*enddo
apIE.document.Title = "Mon site préféré"
*apIE.document.parenWindow.alert("Avez vous remarqué que le titre de la page a changé!")
sleep(2000)
apIE.document.parentWindow.alert("Avez vous remarqué que la page web a changé de titre!")

**************
                *déclencher un lien  dans une page Web
*http://www.atoutfox.org/articles.asp   &&contributions
*apIE = createObject("internetExplorer.Application")
*apIE.Visible = .t.
*apIE.navigate ("http://www.atoutfox.org/")
*do while apIE.busy or apIE.readystate#4
*enddo

*ci après quelques liens Atoutfox
*1. http://www.atoutfox.org/index.asp
*2. http://www.atoutfox.org/actualite.asp
*3. http://www.atoutfox.org/membres.asp
*4. http://www.atoutfox.org/articles.asp
*5. http://www.atoutfox.org/applis.asp
*6. http://www.atoutfox.org/offres.asp
*7. http://www.atoutfox.org/telecharger.asp
*8. http://www.atoutfox.org/references.asp
*9. http://www.atoutfox.org/liens.asp
*10. http://www.atoutfox.org/rss.asp
*11. http://www.atoutfox.org/moncompte.asp

lien= apIE.Document.links(4)  &&contributions
lien.Click
apIE.document.parentWindow.alert("Un hyperlien va être automatiquement déclenché sur la page....contributions (4)-Fin du spectacle.!")
********************************************************************************
*Programme 8 Lister les niveaux de sécurité Internet Explorer

set textmerge on to c:\tempor.vbs noshow
text
strComputer = "."
Set objWMIService = getObject("winmgmts:{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2\Applications\MicrosoftIE")
Set colIESettings = objWMIService.execQuery("Select * from MicrosoftIE_Security")
xx=""
For Each strIESetting In colIESettings
xx=xx+  "Zone : " & strIESetting.Zone & "---Niveau de sécurité : " & strIESetting.Level &chr(10)
Next
wscript.echo xx
endtext

set textmerge to
********************

DECLARE INTEGER ShellExecute IN shell32.dll ;
  INTEGER hndWin, STRING cAction, STRING cFileName, ;
  STRING cParams, STRING cDir, INTEGER nShowWin
ShellExecute(0,"open","c:\tempor.vbs","","",1)


t0=seconds()     &&temporiser 5s idem inkey(5)
do while seconds()-t0<=5
enddo

if messagebox("Raser le fichier créé?",4+64,"Nettoyage")=6
set safe off
dele file c:\tempor.vbs
set safe on
endi
*Faites les test de chaque programme séparé en connection Internet et bon courrage !*

Commentaires
Aucun commentaire enregistré ...

Publicité

Les pubs en cours :

www.atoutfox.org - Site de la Communauté Francophone des Professionnels FoxPro - v3.4.0 - © 2004-2024.
Cette page est générée par un composant COM+ développé en Visual FoxPro 9.0-SP2-HF3