Here is my entire code, this code causes Out of Memory error and virtual memory is low with Winxp. With Vista I don't get the error but IE becomes unresponsive and I look at IE's memory usage and it has taken up all available memory, as high at 800 mb.
Vista IE memory 27mb start
Vista IE memory 264mb stop in about 10 minutes
Winxp IE memory 57mb start
WinXP IE memory 339mb stop in about 10 minutes
This is only a sample code that demonstrates the issue.
I realize my approach at finding IE links is primitive so I am attempting to learn com functions using your IE and Browser Com Tutorial, but it is going to take me quite awhile. So in the mean time I would like to fix this issue.
Code:
COM_CoInitialize()
SetTitleMatchMode,2
OnExit,ReleaseAll
MsgBox This script will move the cursor across the screen looking for two links. news.google.com and maps.google.com`nWhen it finds the link, it will click on it, display a traytip, fileappend links.txt then start over again until the program is paused or exited.`n`nPress`nF6 to Start`nF7 to ExitApp`nF8 to Pause`nF9 to Reload`nF10 to view Links.txt`n`nHow to Use-->`n1. Open Google.com`n2. Check how much memory IE is using, then press F6.`n3. Watch the cursor find links. Wait a minute or two, pause the script with F8 and check how much memory IE is using. For me the memory doubles in less then 5 mintues.`nThe longer I let the program run the more memory IE uses until IE becomes unresponsive due to low memory.`n`n`nNOTE: You may need to adjust StartingXpos, StartingYpos, EndingXpos and EndingYpos so the cursor can find the links.
EndingXpos = 400
EndingYpos = 150
StartingXpos = 10
StartingYpos = 120
MyGoogleUserID = UserID@gmail.com
F6::
Loop
{
WinWaitActive,Google
MouseMove,%StartingXpos%,%StartingYpos%
Startingxpos := Startingxpos+15
ControlGetText,var,msctls_statusbar321, a
if Startingxpos > %EndingXpos%
{
StartingXpos = 10
StartingYpos := Startingypos+7
}
if Startingypos > %EndingYpos%
{
Send {F5}
GoSub StatusBarDone
}
IfInString,Var,http://news.google.com ;example of link found by gettings the text from the statusbar
{ ;as the cursor hovers over the link
TrayTip,Found Google News,%A_Space%,5,17
sleep 2000
click
Gosub StatusBarDone
}
IfInString,Var,http://maps.google.com ;example of link found by gettings the text from the statusbar
{ ;as the cursor hovers over the link
TrayTip,Found Google Maps,%A_Space%,5,17
sleep 2000
click
Gosub StatusBarDone
}
}
F7::
ExitApp
F8::
Pause
Return
F9::
Reload
F10::
run notepad.exe Links.txt
Return
StatusBarDone:
StartingXpos = 10
StartingYpos = 120
TrayTip,Waiting for page to load,%a_space%,30,17
TrayTip, % IEReady(),%a_space%,5,17
WinGetText,text,A
IfInString,text,news.google.com ;StatusBarDone gets the window text
FileAppend,Found news.google.com`n,Links.txt
IfInString,text,maps.google.com
FileAppend,Found maps.google.com`n,Links.txt
Gosub GetHtmlSourceCode
IfInString,HtmlCode,%MyGoogleUserID% ;StatusBarDone gets the html source code
FileAppend,I am signed in to Google`n`n,Links.txt
Else
FileAppend, I am NOT signed in to Google`n`n,Links.txt
Return
IEReady(hIESvr = 0)
{
If Not hIESvr
{
Loop, 50
{
ControlGet, hIESvr, hWnd, , Internet Explorer_Server1, A ; ahk_class IEFrame
If hIESvr
Break
Else Sleep 100
}
If Not hIESvr
Return """Internet Explorer_Server"" Not Found."
}
Else
{
WinGetClass, sClass, ahk_id %hIESvr%
If Not sClass == "Internet Explorer_Server"
Return "The specified control is not ""Internet Explorer_Server""."
}
If DllCall("SendMessageTimeout", "Uint", hIESvr, "Uint", DllCall("RegisterWindowMessage", "str", "WM_HTML_GETOBJECT"), "Uint", 0, "Uint", 0, "Uint", 2, "Uint", 1000, "UintP", lResult)
&& DllCall("oleacc\ObjectFromLresult", "Uint", lResult, "Uint", COM_GUID4String(IID_IHTMLDocument2,"{332C4425-26CB-11D0-B483-00C04FD90119}"), "int", 0, "UintP", pdoc)=0
&& pdoc && pweb:=COM_QueryService(pdoc,IID_IWebBrowserApp:="{0002DF05-0000-0000-C000-000000000046}")
Loop,20
If COM_Invoke(pweb, "ReadyState") <> 4
Break
Else Sleep 500
Loop
{
If COM_Invoke(pweb, "ReadyState") = 4
Break
Else
{
CountNumberOfSleeps++
Sleep 500
If CountNumberOfSleeps > 360 ;360 x 500 = 180 seconds
{
TrayTip,Taking to long to load webpage,Will abort waiting,5,17
CountNumberOfSleeps = 0
Break
}
}
}
COM_Release(pdoc)
COM_Release(pweb)
Return pweb ? "DONE!" : False
}
GetHtmlSourceCode:
ControlGet, hIESvr, Hwnd,, Internet Explorer_Server1,ahk_class IEFrame
WinGetClass, class, ahk_id %hIESvr%
if (!hIESvr or class != "Internet Explorer_Server")
return
COM_Error(0)
WM_HTML_GETOBJECT := DllCall("RegisterWindowMessage", "str", "WM_HTML_GETOBJECT")
SendMessage, WM_HTML_GETOBJECT,,,, ahk_id %hIESvr%
lResult := ErrorLevel
DllCall("oleacc\ObjectFromLresult", "uint", lResult, "uint", COM_GUID4String(IID_IHTMLDocument2,"{332C4425-26CB-11D0-B483-00C04FD90119}"), "int", 0, "uint*", pDoc)
DocEle:=COM_Invoke(pDoc, "documentElement")
htmlcode:=COM_Invoke(DocEle,"innerHTML")
COM_Release(DocEle)
COM_Release(pDoc)
return
ReleaseAll:
com_couninitialize()
exitapp
thanks alot
DataLife