Code : Tout sélectionner
[spoiler=]#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_icon=googletrack.ico
#AutoIt3Wrapper_outfile=googletrack.exe
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <IE.au3>
#include <file.au3>
$hwmd_Reciver = GUICreate("GoogleMapsTrack", 800, 700, 0, 0,$WS_OVERLAPPEDWINDOW)
global $wikipedia="off"
$OK = GUICtrlCreateButton("OK", 620, 650, 60, 40)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
$WikipediaONOFF = GUICtrlCreateButton("Wikipedia", 700, 600, 80, 40)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
$Annuler = GUICtrlCreateButton("Annuler", 700, 650, 80, 40)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
GUICtrlCreateLabel("Ville de Départ",80,630,200,20)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
$Ville1 = GUICtrlCreateInput("", 80, 660, 250, 20)
GUICtrlSetTip(-1, "Entrez une Ville de départ")
GUICtrlCreateLabel("Ville d'Arrivée",350,630,200,20)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
$Ville2 = GUICtrlCreateInput("", 350, 660, 250, 20)
GUICtrlSetTip(-1, "Entrez une Ville d'arrivée")
$url=@ScriptDir & "\gmapsroute.html";lecture de la page html
_IEErrorHandlerRegister()
$ie = _IECreateEmbedded()
$ieobject = GUICtrlCreateObj($ie, -14, -14, 805, 600)
FileCopy($url,$url&"_tmp")
local $lat = "40"
_ReplaceStringInFile($url, "LATITUDE", $lat, 1, 0) ;Paramètre 1 = Sensible a la casse || Paramètre 0 = Remplace le premier trouvé
local $lon = "-100"
_ReplaceStringInFile($url, "LONGITUDE", $lon, 1, 0) ;Paramètre 1 = Sensible a la casse || Paramètre 0 = Remplace le premier trouvé
local $ZoomLevel = "12"
_ReplaceStringInFile($url, "ALTITUDE", $ZoomLevel, 1, 0) ;Paramètre 1 = Sensible a la casse || Paramètre 0 = Remplace le premier trouvé
_IENavigate($ie, $url, 0)
Sleep(2000)
$oForms=_IEFormGetCollection($ie);,0)
$nb_form=@extended
ConsoleWrite("nb form = "&$nb_form&@CRLF)
Dim $formulaire0,$formulaire1
for $i = 0 to $nb_form - 1
; MsgBox(0, "Form Info", $oForm.name)
Assign("formulaire"&$i,_IEFormGetCollection($ie,$i))
Next
ConsoleWrite(@error&@CRLF)
$oQueryfrom=_IEFormElementGetCollection( $formulaire0,0)
ConsoleWrite(@error&@CRLF)
$oButtonfrom=_IEFormElementGetCollection( $formulaire0,1)
$oQueryto = _IEFormElementGetCollection( $formulaire1,0)
ConsoleWrite(@error&@CRLF)
$oButtonto=_IEFormElementGetCollection( $formulaire1,1)
GUISetState()
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE , $Annuler
Exit
Case $OK
local $depart = GUICtrlRead($Ville1)
_IEFormElementSetValue ($oQueryfrom, $depart)
_IEAction($oButtonfrom,"click")
Sleep(2000)
ConsoleWrite(@error&@CRLF)
local $arrivee = GUICtrlRead($Ville2)
_IEFormElementSetValue ($oQueryto, $arrivee)
_IEAction($oButtonto,"click")
sleep(3000)
If FileExists($url&"_tmp") Then FileCopy($url&"_tmp",$url,1)
FileDelete($url&"_tmp")
Case $WikipediaONOFF
Switch $wikipedia
Case "off"
_ReplaceStringInFile($url, '//map.addOverlay(new GLayer("org.wikipedia.en"))', 'map.addOverlay(new GLayer("org.wikipedia.en"))', 1, 0) ;Paramètre 1 = Sensible a la casse || Paramètre 0 = Remplace le premier trouvé
_IEAction($ie, "refresh")
IniWrite("Settings.ini", "Google Maps", "Wikipedia", 'on')
Case "on"
_ReplaceStringInFile($url, 'map.addOverlay(new GLayer("org.wikipedia.en"))', '//map.addOverlay(new GLayer("org.wikipedia.en"))', 1, 0) ;Paramètre 1 = Sensible a la casse || Paramètre 0 = Remplace le premier trouvé
_IEAction($ie, "refresh")
IniWrite("Settings.ini", "Google Maps", "Wikipedia", 'off')
EndSwitch
EndSwitch
Wend[/spoiler]
Les lignes en rouge sont celle que je souhaite valider ou pas avec un bouton pour chaque commande.