Jump to content

MichaelHB

Active Members
  • Posts

    192
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

MichaelHB's Achievements

Prodigy

Prodigy (4/7)

30

Reputation

  1. Hi tuffgong, I like to split the actions in functions, your while loop for example: _CheckServer("server") ; PING server in a loop. Will not proceed until successfull PING or will exit if timeout _CreateIE() GUIDelete() Exit Func _CreateIE($hTimeout = 120000) ;2 min default timeout Local $hTimer = TimerInit() While TimerDiff($hTimer) < $hTimeout Global $oIE = _IECreate("http://server/app", 1, 0) ; open an invisible instance of IE If @error Or Not IsObj($oIE) Then While ProcessExists("iexplore.exe") And TimerDiff($hTimer) < $hTimeout ProcessClose("iexplore.exe") WEnd Sleep(5000) ContinueLoop EndIf With $oIE ; set properties for page - makes page visible .Left = 0 .Top = 0 .MenuBar = True .Resizable = False .StatusBar = False .TheaterMode = False .Toolbar = True .Fullscreen = False .Visible = True EndWith Local $hWnd = _IEPropertyGet($oIE, "hwnd") If Not @error And IsHWnd($hWnd) Then Do WinSetState($hWnd, "", @SW_MAXIMIZE) ; maximize web page If TimerDiff($hTimer) > $hTimeout Then ExitLoop 2 Until Sleep(1000) And BitAND(WinGetState($hWnd), 32) Else Do WinSetState("Quality Control - Internet Explorer", "", @SW_MAXIMIZE) ; maximize web page If TimerDiff($hTimer) > $hTimeout Then ExitLoop 2 Until Sleep(1000) And BitAND(WinGetState("Quality Control - Internet Explorer"), 32) EndIf Return WEnd Exit MsgBox(0,"Timeout","Could not create IE object.") EndFunc ;==>_CreateIE Func _CheckServer($sAddress, $hTimeout = 300000) ;5 min default timeout Local $hTimer = TimerInit() Do If TimerDiff($hTimer) > $hTimeout Then Exit MsgBox(0,"Timeout","Server not responding.") Until Sleep(3000) And Ping($sAddress) EndFunc ;==>_CheckServer
  2. @orbs, what kind of automation in IE download you are looking for (start/stop/resume)? Also, did you try my example in #9? If you really want to click and use the build in download manager in IE, you can easily use UI Automation to "open" / "save" / "saveas" / "cancel" etc, then you can open the download manager (ctrl+j) and get some limited information. Now if you are talking about COM access you can build your own IE Custom Download Manager, i found these example (never tested myself).
  3. @MattHiggs, try this example: #include <InetConstants.au3> #include <IE.au3> Global $bDownloadFinished = False ExampleStart() Exit Func ExampleStart() Local $oIE = _IECreate("www.ninite.com") Local $oIEEvents = ObjEvent($oIE, "_IEEvent_", "DWebBrowserEvents2") If Not IsObj($oIEEvents) Then Exit ConsoleWrite("Error in $oIEEvents" & @CRLF) $aInputElements = _IEquerySelectorAll($oIE, 'ul[class ="list-unstyled center-block js-masonry"] input, body > div > form', -1) If @error Or Not IsArray($aInputElements) Then Exit ConsoleWrite("Error in $aInputElements" & @CRLF) For $i = 1 To UBound($aInputElements)-1 ConsoleWrite($aInputElements[$i].value & @CRLF) $aInputElements[$i].checked = True Next _IEFormSubmit($aInputElements[0]) If @error Then Exit ConsoleWrite("Error in _IEFormSubmit. Error code: " & @error & @CRLF) While Not $bDownloadFinished Sleep(100) WEnd MsgBox(0,0,"Done!") EndFunc ;==>ExampleStart Func _IEquerySelectorAll(ByRef $oObject, $sQuery, $iIndex = 0) If Not __IEIsObjType($oObject, "browserdom") Then __IEConsoleWriteError("Error", "_IEquerySelectorAll", "$_IESTATUS_InvalidObjectType", ObjName($oObject)) Return SetError($_IESTATUS_InvalidObjectType, 0, 0) ElseIf Not IsInt($iIndex) Or Not ($iIndex > -2) Then __IEConsoleWriteError("Error", "_IEquerySelectorAll", "$_IEStatus_InvalidValue", "Invalid Index") Return SetError($_IEStatus_InvalidValue, 0, 0) EndIf Local $oCol = __IEIsObjType($oObject, "documentcontainer") ? $oObject.document.querySelectorAll($sQuery) : $oObject.querySelectorAll($sQuery) If @error Then __IEConsoleWriteError("Error", "_IEquerySelectorAll", "$_IESTATUS_COMError", @error) Return SetError($_IESTATUS_COMError, 0, 0) ElseIf Not IsObj($oCol) Then __IEConsoleWriteError("Error", "_IEquerySelectorAll", "$_IESTATUS_InvalidObjectType", "Invalid Object") Return SetError($_IESTATUS_InvalidObjectType, 0, 0) ElseIf $oCol = Null Or $oCol.length = 0 Then __IEConsoleWriteError("Error", "_IEquerySelectorAll", "$_IEStatus_NoMatch") Return SetError($_IEStatus_NoMatch, 0, 0) ElseIf $iIndex >= $oCol.length Then __IEConsoleWriteError("Error", "_IEquerySelectorAll", "$_IEStatus_InvalidValue", "$iIndex > Nº of elements found") Return SetError($_IEStatus_InvalidValue, 0, 0) EndIf If $iIndex = -1 Then Local $aColReturn[$oCol.length] For $i = 0 To $oCol.length - 1 $aColReturn[$i] = $oCol.Item($i) Next Return SetError($_IEStatus_Success, $oCol.length, $aColReturn) Else Return SetError($_IEStatus_Success, $oCol.length, $oCol.Item($iIndex)) EndIf EndFunc ;==>_IEquerySelectorAll Func _IEEvent_BeforeNavigate2($oIEpDisp, $sIEURL, $iIEFlags, $sIETargetFrameName, $sIEPostData, $iIEHeaders, $bIECancel) ConsoleWrite(@CRLF & "!!!!--BeforeNavigate2 fired--!!! --> " & "$sIEURL = " & $sIEURL) If StringInStr($sIEURL, "ninite.exe") Then ConsoleWrite(@CRLF & @CRLF & "--> Download STARTED --> " & $sIEURL & @CRLF) Local $sFilePath = @TempDir & "\niniteTEST.exe" ; Download the file in the background with the selected option of 'force a reload from the remote site.' Local $hDownload = InetGet($sIEURL, $sFilePath, $INET_FORCERELOAD, $INET_DOWNLOADBACKGROUND) ; Wait for the download to complete by monitoring when the 2nd index value of InetGetInfo returns True. Do Sleep(250) Until InetGetInfo($hDownload, $INET_DOWNLOADCOMPLETE) ; Retrieve the number of total bytes received and the filesize. Local $iBytesSize = InetGetInfo($hDownload, $INET_DOWNLOADREAD) Local $iFileSize = FileGetSize($sFilePath) ; Close the handle returned by InetGet. InetClose($hDownload) ; Display details about the total number of bytes read and the filesize. ConsoleWrite("Donwload path: " & $sFilePath & @CRLF) ConsoleWrite("The total download size: " & $iBytesSize & " | The total filesize: " & $iFileSize & @CRLF) ConsoleWrite("--> Download FINISHED -->" & $sIEURL & @CRLF & @CRLF) $bDownloadFinished = True EndIf EndFunc ;==>_IEEvent_BeforeNavigate2 Exit @mLipok, i dont know any options to disable the save dialog in IE 11. Some interesting references, thanks, i'll play with them later.
  4. As i can see the urls are build like this: https://ninite.com/7zip-peazip-winrar/ninite.exe [3 applications] https://ninite.com/7zip-evernote-googleearth-peazip-winrar/ninite.exe [5 applications] Did you try to build them (urls) and download with the native autoit functions? Your issue is not that complicated, as i told you in #2 you can listen to the browser events and take proper action, the download "popup" can also be automated (you can grab the control info in the autoit window info).
  5. Hi MattHiggs, I do not know if I got right your intent (not a native english), but you can monitor the "BeforeNavigate" event then read urls (take any action if you want to) and use the "DownloadBegin" and "DownloadComplete" events to make a proper check. There is an exemple in the helpfile under the "ObjEvent" function that shows how to use the "BeforeNavigate2" event.
  6. ildary, The problem is that the function _IEAttach is failing, so $oIE is not an object. See if this is what you want: #include <IE.au3> For $iOpenNew = 0 To 1 If $iOpenNew = 0 Then Local $oIE1 = _IECreate("www.google.com", 0, 1, 0) Else Local $oIE2 = _IENavigate2($oIE1, "www.google.com", 1, 2048) MsgBox(0,0,"Check if there is another google tab.") _IENavigate2($oIE2, "www.autoitscript.com") EndIf Next MsgBox(0,0,"Done!") Exit Func _IENavigate2(ByRef $oObject, $sUrl, $iWait = 1, $BrowserNavFlag = 0) #cs $BrowserNavFlags: Default is 0, navigate in the same window. navOpenInNewWindow = 1 navNoHistory = 2 navNoReadFromCache = 4 navNoWriteToCache = 8 navAllowAutosearch = 16 navBrowserBar = 32 navHyperlink = 64 navEnforceRestricted = 128 navNewWindowsManaged = 256 navUntrustedForDownload = 512 navTrustedForActiveX = 1024 navOpenInNewTab = 2048 navOpenInBackgroundTab = 4096 navKeepWordWheelText = 8192 navVirtualTab = 16384 navBlockRedirectsXDomain = 32768 navOpenNewForegroundTab = 65536 #ce If Not __IEIsObjType($oObject, "documentContainer") Then If @error = $_IESTATUS_InvalidDataType Then __IEConsoleWriteError("Error", "_IENavigate", "$_IESTATUS_InvalidDataType") Return SetError($_IESTATUS_InvalidDataType, 1, 0) Else __IEConsoleWriteError("Error", "_IENavigate", "$_IESTATUS_InvalidObjectType") Return SetError($_IESTATUS_InvalidObjectType, 1, 0) EndIf EndIf ; If $BrowserNavFlag Then Local $iRandom = Random(10001, 99999, 1), $oIE, $iNotifyStatus, $hTimer = TimerInit() $oObject.Navigate2("about:blank-" & $iRandom, $BrowserNavFlag) If @error Then ; Trap COM error, report and return __IEConsoleWriteError("Error", "_IENavigate", "$_IESTATUS_COMError", @error) Return SetError($_IESTATUS_ComError, @error, 0) EndIf $iNotifyStatus = _IEErrorNotify() _IEErrorNotify(False) While Not IsObj($oIE) Sleep(500) $oIE = _IEAttach("about:blank-" & $iRandom, "URL") If TimerDiff($hTimer) > 30000 Then _IEErrorNotify($iNotifyStatus) __IEConsoleWriteError("Error", "_IENavigate", "", "Time out. TimerDiff > 30000ms") Return SetError(1, 0, 0) EndIf WEnd _IEErrorNotify($iNotifyStatus) $oIE.Navigate2($sUrl) If @error Then ; Trap COM error, report and return __IEConsoleWriteError("Error", "_IENavigate", "$_IESTATUS_COMError", @error) Return SetError($_IESTATUS_ComError, @error, 0) EndIf If $iWait Then _IELoadWait($oIE) Return SetError(@error, 0, $oIE) EndIf Return SetError($_IESTATUS_Success, 0, $oIE) EndIf ; $oObject.Navigate2($sUrl) If @error Then ; Trap COM error, report and return __IEConsoleWriteError("Error", "_IENavigate", "$_IESTATUS_COMError", @error) Return SetError($_IESTATUS_ComError, @error, 0) EndIf ; If $iWait Then _IELoadWait($oObject) Return SetError(@error, 0, -1) EndIf Return SetError($_IESTATUS_Success, 0, -1) EndFunc ;==>_IENavigate
  7. Would not be better to download a already done free app? Threre are free options that could serve your needs, just google "free remote connection for mobile devices" or something like this, no need to build a script to do that. This could also interest you: As you need a really fast solution to monitor your puppies, just download one of the free software that you can easly find.
  8. Why not a remote connection (there is some UDFs and free apps online) to lauch the the script with the function to turn the lights on.
  9. Sure. I asked because i was making some modifications for a friend and they can be implemented in the IE. Like: IECreate with command-line options (‑noframemerging for example, use regread to find the ie installation and PID for the IEAttach method). IENavigate with NavFlags like: navOpenInBackgroundTab I have a querySelectorAll function that is already working fine (with the same standard of other IE functions). very useful func if i may add. There is some redundancies, for example IsObj is checked twice in most functions (the other time is in __IEIsObjType). All the objects colletions should return an array with the objects. For nodecolletion is not recommended the For-In-Next loop, so using an array is 5x times faster than element.item($i), and its at least 2x faster for HtmlElementCollection. This is what i remember right know, i believe that there is more. The tests that i made is in the initals steps and i have not had the opportunity to test on multiple systems.
  10. @mLipok, if i may ask an off topic question, do you think that would be interesting to improve some IE UDF functions (even add a new one)? Is there any restrictions to change or suggest modifications in this UDF?
  11. You can also change the way that you populate the groups. Making it in a way you dont need to worry about the item order in the array, then no matter order, you will always bel able to set the right group order with different numbers of elements.
  12. I'm no expert, but maybe in this way you dont need to worry if the groups have the same number of items. #include <Date.au3> #include <Array.au3> #include <GuiListView.au3> #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> Opt("GUIOnEventMode", 1) Local $array[21][2] $array[0][0] = "lemon" $array[0][1] = "Group 1" $array[1][0] = "03/2/201111" $array[1][1] = "Group 1" $array[2][0] = "candy" $array[2][1] = "Group 1" $array[3][0] = "ship" $array[3][1] = "Group 2" $array[4][0] = "2013/05/12 03:12:22" $array[4][1] = "Group 2" $array[5][0] = "ants" $array[5][1] = "Group 2" $array[6][0] = "2011/04/09 11:34:02" $array[6][1] = "Group 3" $array[7][0] = "34/23" $array[7][1] = "Group 3" $array[8][0] = "pasta" $array[8][1] = "Group 3" $array[9][0] = "chilli" $array[9][1] = "Group 4" $array[10][0] = "12/12" $array[10][1] = "Group 4" $array[11][0] = "1999/03/14 09:19:34" $array[11][1] = "Group 4" $array[12][0] = "1989/01/20 01:01:56" $array[12][1] = "Group 5" $array[13][0] = "melon" $array[13][1] = "Group 5" $array[14][0] = "1989/01/20 01:01:56" $array[14][1] = "Group 5" $array[15][0] = "water" $array[15][1] = "Group 6" $array[16][0] = "staple" $array[16][1] = "Group 6" $array[17][0] = "brocolli" $array[17][1] = "Group 6" $array[18][0] = "corn" $array[18][1] = "Group 7" $array[19][0] = "1989/12/01 02:21:19" $array[19][1] = "Group 7" $array[20][0] = "1989/12" $array[20][1] = "Group 7" $iExWindowStyle = BitOR($WS_EX_DLGMODALFRAME, $WS_EX_CLIENTEDGE) $iExListViewStyle = BitOR($LVS_REPORT, $LVS_EX_SUBITEMIMAGES, $LVS_EX_DOUBLEBUFFER, $LVS_EX_CHECKBOXES) GUICreate("EXAMPLE") $idListview = GUICtrlCreateListView("Item", 2, 2, 398, 398, -1, $iExWindowStyle) _GUICtrlListView_SetColumnWidth($idListview, 0, 250) _GUICtrlListView_SetExtendedListViewStyle($idListview, $iExListViewStyle) ; Add items & Build groups _GUICtrlListView_EnableGroupView($idListview) Local $iCurrentGroup, $iLastCreatedGroup For $i = 0 To UBound($array)-1 _GUICtrlListView_AddItem($idListview, $array[$i][0]) $iCurrentGroup = Number(StringReplace($array[$i][1], "Group ", "")) If $iCurrentGroup <> $iLastCreatedGroup Then _GUICtrlListView_InsertGroup($idListview, -1, $iCurrentGroup, $array[$i][1]) $iLastCreatedGroup = $iCurrentGroup EndIf _GUICtrlListView_SetItemGroupID($idListview, $i, $iCurrentGroup) Next Local $iGroupCount = _GUICtrlListView_GetGroupCount($idListview) Local $bFirstDateIsValidFound, $aGroupIndex, $sItemText For $i = 1 To $iGroupCount $bFirstDateIsValidFound = False $aGroupIndex = _ArrayFindAll($array, "Group " & $i, Default, Default, Default, Default, 2) If Not @error And IsArray($aGroupIndex) Then For $j = 0 To UBound($aGroupIndex) - 1 $sItemText = $array[$aGroupIndex[$j]][0] If (_DateIsValid($sItemText) And Not $bFirstDateIsValidFound) Or (($j = (UBound($aGroupIndex) - 1)) And Not $bFirstDateIsValidFound) Then $bFirstDateIsValidFound = True ContinueLoop EndIf _GUICtrlListView_SetItemChecked($idListview, $aGroupIndex[$j]) Next EndIf Next GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit1") GUISetState() While 1 Sleep(100) WEnd Func _Exit1() Exit EndFunc Exit
  13. Try this: _UIA_getObjectByFindAll($oOBJ,"controltype:=" & $UIA_TableControlTypeId & ";indexrelative:=2", $treescope_subtree)
  14. pranaynanda, Here the example: #include <IE.au3> Local $oIE = _IECreate("https://www.facebook.com") _IELoadWait($oIE) If @error Then $oIE = _IEAttach("facebook.com", "url") If @error Then Exit ConsoleWrite("Error in _IEAttach" & @CRLF & "@error: " & @error) EndIf Local $oEmail = _IEGetObjById($oIE, "email") If @error Then Exit ConsoleWrite("Error in $oEmail" & @CRLF & "@error: " & @error) _IEFormElementSetValue($oEmail, "email@email.com") If @error Then Exit ConsoleWrite("Error in _IEFormElementSetValue($oEmail)" & @CRLF & "@error: " & @error) Local $oPassword = _IEGetObjById($oIE, "pass") If @error Then Exit ConsoleWrite("Error in $oPassword" & @CRLF & "@error: " & @error) _IEFormElementSetValue($oPassword, "password") If @error Then Exit ConsoleWrite("Error in _IEFormElementSetValue($oPassword)" & @CRLF & "@error: " & @error) Local $oSubmit = _IEGetObjById($oIE, "u_0_m") If @error Then Exit ConsoleWrite("Error in $oSubmit" & @CRLF & "@error: " & @error) MsgBox(0, "", "Before click on submit button.") _IEAction($oSubmit, "click") If @error Then Exit ConsoleWrite('Error in _IEAction($oSubmit, "click")' & @CRLF & "@error: " & @error) MsgBox(0, "", "Done!") Exit As state by Danp2, _IECreate automatically performs an _IELoadWait by default but as you are getting an error (-2147417848) probably because your browser is internally "jumping" to a different security zone, so because i dont know if you are using a COM error handler, the _IELoadWait will error out (i believe this way will be easier for you to understand) and try to _IEAttach. You can easily adapt this example to fit your needs.
×
×
  • Create New...