Code : Tout sélectionner
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=Qbuico.ico
#AutoIt3Wrapper_Res_Comment=
#AutoIt3Wrapper_Res_Description=
#AutoIt3Wrapper_Res_Fileversion=1.0.0.2
#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=p
#AutoIt3Wrapper_Res_Language=1036
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Misc.au3>
#include <IE.au3>
#include <MsgBoxConstants.au3>
If _Singleton("example.exe", 1) = 0 Then
MsgBox(0, "Instance en cours", "Le logiciel est déjà démarré")
Exit
EndIf
$nameGUI = "Example"
Global $oIE, $GUIActiveX, $GUI_Button_Back, $GUI_Button_Forward
Global $GUI_Button_Reload, $GUI_Button_Reboot, $msg
Global $stopwhile = 0
Global $oIE = ObjCreate("Shell.Explorer.2")
Global $oIEEvents = ObjEvent($oIE, "_IEEvent_", "DWebBrowserEvents2")
Global $bCancelNav = False
GUICreate($nameGUI, (@DesktopWidth - 100), (@DesktopHeight - 100), 0, 0, BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS, $WS_CLIPCHILDREN))
$GUIActiveX = GUICtrlCreateObj($oIE, 10, 20, (@DesktopWidth - 40), (@DesktopHeight - 160))
;~ $GUI_Button_Back = GUICtrlCreateButton("Back", 10, 420, 100, 30)
;~ $GUI_Button_Forward = GUICtrlCreateButton("Forward", 120, 420, 100, 30)
$GUI_Button_Reload = GUICtrlCreateButton("Reload", 6, (@DesktopHeight - 136), 100, 30)
;~ $GUI_Button_Reboot = GUICtrlCreateButton("Reboot", 126, 732, 100, 30)
$GUI_Button_Stop = GUICtrlCreateButton("Fermer", (@DesktopWidth - 206), (@DesktopHeight - 136), 100, 30)
GUISetState() ;Show GUI
$oIE.navigate("http://www.w3schools.com/tags/tryit.asp?filename=tryhtml_a_target")
While 1
If $oIE.readyState = "complete" Or $oIE.readyState = 3 Or $oIE.readyState = 4 Then ExitLoop
Sleep(10)
WEnd
$bCancelNav = True ; si à True alors on ne peut plus naviguer sur d'autres pages
WinActivate($nameGUI)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $GUI_Button_Reload
$oIE.navigate("http://www.w3schools.com/tags/tryit.asp?filename=tryhtml_a_target")
;~ Case $msg = $GUI_Button_Reboot
;~ $oIE.stop
;~ Case $msg = $GUI_Button_Back
;~ $oIE.GoBack
;~ Case $msg = $GUI_Button_Forward
;~ $oIE.GoForward
Case $GUI_Button_Stop
Exit
EndSwitch
WEnd
Volatile Func _IEEvent_NewWindow3($oIEpDisp, ByRef $bIECancel, $iIEFlags, $sIEURLContext, $sIEURL)
$bIECancel = True ; la nouvelle fenêtre ne s'ouvrira pas
If Not $bCancelNav Then $oIE.navigate($sIEURL) ; (facultatif) ouvre le lien dans la fenêtre active, mais je ne sais pas si c'est une bonne façon de faire
EndFunc ;==>_IEEvent_NewWindow3
Volatile Func _IEEvent_BeforeNavigate2($oIEpDisp, $sIEURL, $iIEFlags, $sIETargetFrameName, $sIEPostData, $iIEHeaders, ByRef $bIECancel)
If $bCancelNav Then $bIECancel = True ; $bIECancel = True pour annuler la navigation
EndFunc ;==>_IEEvent_BeforeNavigate2