Hallo zusammen,
zwar bin ich kein guter Programmierer aber folgendes Skript führt zum Ziel. Da ich aber glaube das mein Skript ressourcenverschwendend ist, wollte ich mal eure Meinungen/Verbesserunsvorschläge hören.
Das Skript ruft den IE auf und steuert das interne Intranet an. Dort wird dann der Login geprügt und ein Aufruf einer Testseite. Danach wird der User wieder abgemeldet und der IE geschlossen.
Über Rückmeldungen würde ich mich sehr freuen.
AutoIt
#include <IE.au3>
#include <String.au3>
#include <Date.au3>
RunWait('taskkill /F /IM "iexplore.exe"')
Global $totalTimer = TimerInit ()
Global $navigationTimer =TimerInit ()
Global $oIE = _IECreate ("https://intranet.de/")
$HWND = _IEPropertyGet($oIE, "hwnd")
WinSetState($HWND, "", @SW_MAXIMIZE)
_IEAction($oIE, "visible")
_IELoadWait($oIE)
Global $Login = 0
Global $Search = 0
Global $result = ""
Call ("loginIntranet")
Call ("logOut")
Call ("quitCheck")
Func loginIntranet ()
Local $username = _IEGetObjByName ($oIE,"os_username")
Local $password = _IEGetObjByName ($oIE,"os_password")
Local $login_button = _IEGetObjById ($oIE,"loginButton")
_IEFormElementSetValue ($username, "xxxxxxxxxxx")
_IEFormElementSetValue ($password, "xxxxxxxxxxx")
Global $navigationDiff = Round(TimerDiff($navigationTimer)/1000, 2)
Global $LoginTimer = TimerInit()
_IEAction ($login_button, "click")
_IELoadWait($oIE)
Local $resultPageTitle = _IEPropertyGet ($oIE,"title")
If $resultPageTitle == ("Welcome to the intranet") Then
$Login = 1
$result = $result & 'Login: OK, '
Else
$Login = 0
$result = $result & 'Login: ERROR, '
EndIf
Global $loginDiff = Round(TimerDiff($LoginTimer)/1000, 2)
EndFunc
Func logOut ()
Global $logoutTimer = TimerInit ()
Local $logout_button = _IEGetObjById ($oIE,"logout-link")
_IEAction ($logout_button, "click")
_IELoadWait($oIE)
Global $logoutDiff = Round(TimerDiff($logoutTimer)/1000, 2)
Global $totalDiff = Round(TimerDiff($totalTimer)/1000, 2)
EndFunc
Func quitCheck ()
$loginDuration = $loginDiff
$logoutDuration = $logoutDiff
$totalDuration = $totalDiff
If ($statusLogin = 1) Then
$result = 'P IntranetCheck EndToEnd=1|time=' & $totalDuration & ";9.5" & ";11" & '|Login=' & $loginDuration & '|SiteNavigation=' & $navigationDiff & '|Logout=' & $logoutDuration & ' Sucessfull in '& $totalDuration &' seconds: '& $result & 'Login: ' & $loginDuration & "s, " & 'SiteNavigation: ' & $navigationDiff & "s, " & 'Logout: ' & $logoutDuration & "s." &@CRLF
Else
$result = '2 IntranetCheck EndToEnd=0|time=' & $totalDuration & '|Login=' & $loginDuration & '|SiteNavigation=' & $navigationDiff & '|Logout=' & $logoutDuration & ' Error in '& $totalDuration &' seconds: '& $result & 'Login: ' & $loginDuration & "s, " & 'SiteNavigation: ' & $navigationDiff & "s, " & 'Logout: ' & $logoutDuration & "s."&@CRLF
EndIf
If FileExists("C:\Intranet_check_result.txt") then FileDelete("C:\Intranet_check_result.txt")
FileWrite("C:\Intranet_check_result.txt", $result)
FileClose("filehandle")
_IEQuit ($oIE)
EndFunc
Alles anzeigen