i have made changes to you code
Let me knwo how it works out for you
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 !pweb:=iWeb2_GetIE(hIESvr)
return false
Loop,20
If COM_Invoke(pweb, "ReadyState") <> 4
Break
Else Sleep 500
Loop
{
If COM_Invoke(pweb, "ReadyState") = 4
Break
Sleep 500
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(pweb)
Return "DONE!"
}
GetHtmlSourceCode:
htmlcode:=pweb:=iWeb2_GetIE() ? COM_Invoke(pweb, "document.documentElement.outerHTML") :
COM_Release(pweb)
return
ReleaseAll:
com_couninitialize()
exitapp
;: Title: iWebBrowser2 working with IE
;
; Function: iWeb2_GetIE
; Description: Gets the iWebBrowser2 interface from the passed parameter
; Syntax: pweb:=iWeb2_GetIE("google.com")
; Parameters: hIESvr - this can be anny of the following items
; IEFrame
; Internet Explorer_Server
; all or partial LocationURL
; all or partial LocationName
; blank in which case the last active IE window is selected
; Return Value: iWebBrowser2 interface
; Remarks:
; Related: Related, functions
; Example:
;
iWeb2_GetIE(IE="",Method="LocationName")
{
IE:=(!IE && Method="HWND") ? WinExist("ahk_class IEFrame") : (!IE && Method="LocationName") ? ActiveTitle() : (!IE && Method="LocationURL") ? ActiveURL() ? !IE ? Exit : IE ; its blank use the active window
psh := COM_CreateObject("Shell.Application"), psw := COM_Invoke(psh, "Windows"), COM_Release(psh)
Loop, % COM_Invoke(psw, "Count")
ErrorLevel:=(pweb:=InStr(COM_Invoke(psw,"Item[" A_Index-1 "]." Method),IE) ? COM_Invoke(psw,"Item",A_Index-1) : 0) ? break : "iWeb2_GetIE(%IE%,%Method%) could not return a iWebBrowser2 interface"
COM_Release(psw)
Return pweb
}
ActiveURL()
{
ControlGetText, URL,Edit1,ahk_class IEFrame
Return URL
}
ActiveTitle()
{
WinGetTitle,title,ahk_class IEFrame
StringSplit,t,title,- ; strip off the browser suffix
t1=%t1% ;strip trailing and leading spaces
Return t1
}