Voici le script final
Code : Tout sélectionner
#include <GUIConstants.au3>
#include <IE.au3>
Global $archive = "C:\zabbix\archive.txt"
Global $userselected = "wyselab01"
Global $passselected = "wyselab01"
Global $visible = 0
_Check($userselected, $passselected, $visible)
;===============================================================
Func _Check($username, $password, $scriptvisible)
$wb = _IECreate ("https://courrier.csbe.qc.ca/owa/auth/logon.aspx?replaceCurrent=1&url=https%3a%2f%2fcourrier.csbe.qc.ca%2fowa%2f", 0, $scriptvisible, 1, 1)
$identif = _IEFormGetObjByName ($wb, "logonForm")
$login = _IEFormElementGetObjByName ($identif , "username")
$mdp = _IEFormElementGetObjByName ($identif , "password")
Local $oSubmit = _IEGetObjByName($wb, "submitExample")
_IEFormElementSetValue ($login, $username)
_IEFormElementSetValue ($mdp, $password)
WinActivate("Outlook")
$handle = ControlGetHandle("Outlook", "", "[CLASS:Internet Explorer_Server; INSTANCE:1]")
ControlFocus("Outlook", "", $handle)
ControlSend("Outlook", "", $handle , "{tab}")
ControlSend("Outlook", "", $handle , "{enter}")
_IELoadWait ($wb)
$file = FileOpen($archive, 2) ; 2 = Write mode (erase previous contents)
If StringInStr($wb.locationurl, "logon") Then
FileWrite($file, "0") ; ECHEC
Else
FileWrite($file, "1") ; SUCCES
EndIf
FileClose($file)
$wb.visible = 1 ; vérification
_IEAction ($wb, "quit") ; ferme IE
EndFunc

