aa2zz6 Posted September 21, 2018 Share Posted September 21, 2018 At my workplace I put together a small browser application using Autoit to display our Portal maps in a GUI. The issue I'm running into now is that the program will open all 4 maps at once, requiring the user to input his/her username and password 4 times if they're not signed in already. Is there a way to tell the program to only open the first tab, allow the user to input his credentials, and then proceed to open the remaining tabs? Open this tab first if user isn't signed in> GUICtrlCreateTabItem("Portal") $GUIActiveX = GUICtrlCreateObj($oIE, 5, 28, $width, $height) _IENavigate($oIE, $address) These tabs should wait if user isn't signed in > GUICtrlCreateTabItem("Gas Network") $oIE1 = _IECreateEmbedded() $address1 = "URL" $GUIActiveX1 = GUICtrlCreateObj($oIE1, 5, 30, $width, $height) _IENavigate($oIE1, $address1) GUICtrlCreateTabItem("Gas Leaks") $oIE1 = _IECreateEmbedded() $address1 = "URL" $GUIActiveX1 = GUICtrlCreateObj($oIE1, 5, 30, $width, $height) _IENavigate($oIE1, $address1) GUICtrlCreateTabItem("Cathodic Protection") $oIE2 = _IECreateEmbedded() $address2 = "URL" $GUIActiveX2 = GUICtrlCreateObj($oIE2, 5, 30, $width, $height) _IENavigate($oIE2, $address2) Full script expandcollapse popup#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon=ICO NEO_LOGO.ico #AutoIt3Wrapper_Compression=4 #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** ;#NoTrayIcon ; ; Simple Browser based on Internet Explorer ActiveX Component. ; #include <ColorConstantS.au3> #include <WindowsConstants.au3> #include <WinAPI.au3> #include <GUIConstants.au3> #include <IE.au3> #include <INet.au3> #include <GUIConstantsEx.au3> #include <Date.au3> #include <File.au3> Opt("GUIOnEventMode", 1) ; Variables Global $connectionFailed ; Clean up folder Global $path = "C:\temp" $files = _FileListToArray($path, "*.txt", 2) ;create an array of files in the specified folder $date = @YEAR & "/" & @MON & "/" & @MDAY ;getting the current date $newdate = _DateAdd("D", -10, $date) ;adding -10 days (subtract 10 days) $formatdate = StringSplit($newdate, "/") ;removing the / $newdate = $formatdate[1] & $formatdate[2] & $formatdate[3] & @HOUR & @MIN & @SEC ;putting the date back together in a format easily compared to the FileGetTime func If IsArray($files) Then ;Making sure an array was created For $i = 1 To UBound($files) - 1 ;Loop through all the files found $aTime = FileGetTime($path & $files[$i], 1, 1) ;get the creation time of the file If $aTime < $newdate Then ;check to see if creation time is older than 10 days FileDelete($files[$i]) ;delete the file if it is EndIf Next EndIf _IEErrorHandlerRegister() $oIE = _IECreateEmbedded() $name = "Northeast Ohio Natural Gas | Version 1.0 | Created by: Jordan Miller" $address = "https://URL.net/webadapter/" ; Calculate visible screen dimensions. $one_percent_width = @DesktopWidth / 100 $one_percent_height = @DesktopHeight / 100 $width = $one_percent_width * 98 $height = $one_percent_height * 91 Local $form = GUICreate($name, @DesktopWidth, @DesktopHeight, 1, 1, $WS_MAXIMIZE + $WS_OVERLAPPEDWINDOW + $WS_VISIBLE) ;GUISetBkColor(0x00E0FFFF) GUISetFont(9, 300) GUICtrlCreateTab(5, 5, $width, $height) ;GUICtrlCreateTab(10, 50, $width, $height) GUICtrlCreateTabItem("Portal") $GUIActiveX = GUICtrlCreateObj($oIE, 5, 28, $width, $height) _IENavigate($oIE, $address) GUICtrlCreateTabItem("Gas Network") $oIE1 = _IECreateEmbedded() $address1 = "URL" $GUIActiveX1 = GUICtrlCreateObj($oIE1, 5, 30, $width, $height) _IENavigate($oIE1, $address1) GUICtrlCreateTabItem("Gas Leaks") $oIE1 = _IECreateEmbedded() $address1 = "URL" $GUIActiveX1 = GUICtrlCreateObj($oIE1, 5, 30, $width, $height) _IENavigate($oIE1, $address1) GUICtrlCreateTabItem("Cathodic Protection") $oIE2 = _IECreateEmbedded() $address2 = "URL" $GUIActiveX2 = GUICtrlCreateObj($oIE2, 5, 30, $width, $height) _IENavigate($oIE2, $address2) ; Show GUI. GUISetState(@SW_MAXIMIZE) GUISetOnEvent($GUI_EVENT_CLOSE, "_Close") $i = 0 $Timer = TimerInit ; Waiting for user to close the window. While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop Select Case $msg = $GUI_EVENT_CLOSE ExitLoop EndSelect checkConnection() Sleep(10) WEnd GUIDelete() Exit Func checkConnection() While 1 $Ping = Ping("URL") $Delay = TimerDiff($Timer) If $Delay >= 2000 Then ;2 seconds delay check If $Ping Then ; also possible: If @error = 0 Then ... ;ToolTip("Network Connection Active!", 0, 0) Sleep(2000) ; Sleep to give tooltip time to display If $connectionFailed = True Then Local $oElements = _IETagNameGetCollection($oIE, "div") For $oElement In $oElements If $oElement.classname == "appstate-tips" Then _IEAction($oElement, "click") EndIf ;ConsoleWrite ( $oElement.classname & @CRLF) _WriteErrorLog("Reconfigured map settings") $connectionFailed = False ; Reset back to default Next EndIf $i = $i + 1 _WriteErrorLog("Network Connection Active!") ;Used for testing.. Else ;ToolTip("Network Connection Failed", 0, 0) Sleep(2000) ; Sleep to give tooltip time to display $i = $i + 1 $connectionFailed = True _WriteErrorLog("Network Connection Failed") EndIf $Timer = TimerInit() EndIf Sleep(10) WEnd EndFunc ;==>checkConnection Func _Close() GUIDelete() Exit EndFunc ;==>_Close Func _WriteErrorLog($ErrorMessage) ; If the directory exists then don't continue. If FileExists($path) Then ;MsgBox($MB_SYSTEMMODAL, "", "An error occurred. The directory already exists.") Return False EndIf ; Create the directory. DirCreate($path) FileWriteLine($path & "\" & @ScriptName & ".log", _NowTime() & " " & $ErrorMessage) EndFunc ;==>_WriteErrorLog Link to comment Share on other sites More sharing options...
jdelaney Posted September 21, 2018 Share Posted September 21, 2018 (edited) You can loop until the url changes from the login page, and then do all the navigations on the other browsers. _iepropertyget Edited September 21, 2018 by jdelaney IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now