IE and IEload problems Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
DuctTaper
Posts: 5
Joined: 08 Sep 2017, 16:06

IE and IEload problems

16 Oct 2017, 01:51

Having a bit of trouble using ComObjCreate("InternetExplorer.Application") and IEload function:
1) Sometimes loading could stuck and that stops the script
2) Sometimes IEload waits for a loaded page forever which stops the script as well unless you reload the page
3) Sometimes IE starts to have memory leaks. Don't know is it a website/IE/AHK's fault though.
4) Sometimes IE freezes and that also that stops the script

So, is there way to
1) Implement timer into IEload to fix issue 1 and 2
2) Detect IE memory usage and status and in case it's using too much RAM/frozen - restart it?

That's IEload I'm using:

Code: Select all

IEload(wb)    ;You need to send the IE handle to the function unless you define it as global.
{
    If !wb    ;If wb is not a valid pointer then quit
        Return False
    Loop    ;Otherwise sleep for .1 seconds untill the page starts loading
        Sleep,100
    Until (wb.busy)
    Loop    ;Once it starts loading wait until completes
        Sleep,100
    Until (!wb.busy)
    Loop    ;optional check to wait for the page to completely load
        Sleep,100
    Until (wb.Document.Readystate = "Complete")
Return True
BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: IE and IEload problems

16 Oct 2017, 02:24

1) would guess that an additional count(er) condition to break the loop would make it
2) https://autohotkey.com/board/topic/1139 ... -usage-in/
DuctTaper
Posts: 5
Joined: 08 Sep 2017, 16:06

Re: IE and IEload problems

16 Oct 2017, 03:05

BoBo, thanks for reply!
1) What is the best way to do it? My tries weren't working correctly
2) Thank you for suggestion, could be also usable, but I meant more RAM problems, not CPU overuse
Last edited by DuctTaper on 16 Oct 2017, 03:33, edited 1 time in total.
BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: IE and IEload problem

16 Oct 2017, 03:23

Another option would be running a separate script to monitor the first one. So once the first is stalling the second comes for the kill. https://autohotkey.com/board/topic/3578 ... emory-ram/ :?:
DuctTaper
Posts: 5
Joined: 08 Sep 2017, 16:06

Re: IE and IEload problems

16 Oct 2017, 03:39

BoBo, I don't think this is a very ellegant decision :D And I meant checking RAM for specific process, not for the whole system.
BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: IE and IEload problems

16 Oct 2017, 04:00

DuctTaper wrote:BoBo, I don't think this is a very ellegant decision :D And I meant checking RAM for specific process, not for the whole system.
If it would be about elegance I'd link a picture of Beyonce :mrgreen:
Nevertheless, AFAIK a hanging script can't cure itself, well, bc it's hanging.
Just in case you want to identify the root cause of your 'hanging' problem ... :silent:
http://www.nirsoft.net/utils/what_is_hang.html
DuctTaper
Posts: 5
Joined: 08 Sep 2017, 16:06

Re: IE and IEload problems

16 Oct 2017, 05:10

BoBo, maybe I had put information in a wrong way - script is not hanging. It is waiting for IE while it is hanging or loading the page. So I'm sure there could be something which could I implement to fix it.
teadrinker
Posts: 4331
Joined: 29 Mar 2015, 09:41
Contact:

Re: IE and IEload problems  Topic is solved

16 Oct 2017, 06:08

Hi, DuctTaper,
So I'm sure there could be something which could I implement to fix it.
Consider:

Code: Select all

wb := ComObjCreate("InternetExplorer.Application")
OnExit( Func("Exit").Bind(wb) )
wb.Visible := true
wb.Navigate("https://msdn.microsoft.com/ru-ru/library/aa752084(v=vs.85).aspx")

if !WaitForLoad(wb, 3000)  ; 3 sec
   MsgBox, Time is up!
else
   MsgBox, Loaded on time!

WaitForLoad(ie, time)  {
   start := A_TickCount
   Loop
      Sleep, 200
   until !(ie.ReadyState != 4 || ie.Busy || ie.document.readyState != "Complete") || (A_TickCount - start > time && notLoad := 1)
   Return !notLoad
}

Exit(ie)  {
   try ie.Quit()
}
DuctTaper
Posts: 5
Joined: 08 Sep 2017, 16:06

Re: IE and IEload problems

17 Oct 2017, 10:12

teadrinker, splendid! Exactly what was needed, thanks a ton!

Now got to solve just the one question about the process RAM usage.
BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: IE and IEload problems

17 Oct 2017, 12:09

Last try to contribute something usefull in here :)
https://autohotkey.com/board/topic/4482 ... ory-usage/

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: No registered users and 390 guests