AutoHotkey Community

It is currently May 26th, 2012, 7:35 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 22 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: April 29th, 2009, 1:54 pm 
Offline

Joined: April 27th, 2008, 5:28 pm
Posts: 489
When running my script iexplore.exe continually increases the amount of memory it is using. It appears not to be releasing any memory.

Eventually IE becomes unresponsive. I have seen iexlore.exe use as much as 780 MB with only one tab open.

I suspect the issue is with one of the sections of code below.

My script waits for the web page to load, gets the html source code, looks for strings in the code, does something based on what strings it finds then does it all over again many times.

Also, I have tried it on Vista, Winxp and Windows 2000 with different versions of IE.

Can someone take a look?

thanks
DataLife
Code:
;Gets html source code of current web page
ControlGet, hIESvr, Hwnd,, Internet Explorer_Server1,ahk_class    IEFrame
WinGetClass, class, ahk_id %hIESvr%
if (!hIESvr or class != "Internet Explorer_Server")
 return
COM_CoInitialize()
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)
com_couninitialize()
return


or

Code:
;Waits for the web page to completely load
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""."
   }

   COM_Init()
   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)
   COM_Term()
   Return   pweb ? "DONE!" : False
}


_________________
Check out my scripts.
(MyIpChanger) (XPSnap) (SavePictureAs)

All my scripts are tested on Windows 7, AutoHotkey_L 32 bit Ansi unless otherwise stated.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 29th, 2009, 2:47 pm 
Offline
User avatar

Joined: December 21st, 2007, 3:14 pm
Posts: 3826
Location: Louisville KY USA
firstly if i recall correctly from your other post your loading a web page first then using this to get the content
why you are doing this I wont pretend to understand it simply makes no sense
but a couple things seem to come to mind
first you dont need to use run and then aquire the page
there is no need to quite your ie window is there?
i recommend you go with one of the following
OBVIOUSLY you will need to change the feild i have as URL
Code:
COM_CoInitialize()
OnExit,unInit
Loop{
   pweb := COM_CreateObject("InternetExplorer.Application") )
   COM_Invoke(pweb,Visible=1)
   COM_Invoke(pweb,   "Navigate",   URL)
   loop
         If (rdy:=COM_Invoke(pweb,"readyState") = 4)
            break
   MsgBox  % COM_Invoke(pweb,"document.documentElement.outerHTML")
   COM_Invoke(pweb,"quite")
}
unInit:
COM_CoUninitialize()
ExitApp
Return
Code:
COM_CoInitialize()
OnExit,unInit
pweb := COM_CreateObject("InternetExplorer.Application") )
COM_Invoke(pweb,Visible=1)
Loop{
   COM_Invoke(pweb,   "Navigate",   URL)
   loop
         If (rdy:=COM_Invoke(pweb,"readyState") = 4)
            break
   MsgBox  % COM_Invoke(pweb,"document.documentElement.outerHTML")
}
unInit:
COM_CoUninitialize()
ExitApp
Return

_________________
No matter what your oppinion Please join this discussion
Formal request to Polyethene
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 29th, 2009, 3:07 pm 
Offline

Joined: April 27th, 2008, 5:28 pm
Posts: 489
Okay, I will explain how my script works.

My actions
1. I open a webpage, example google news
2. I start my script

My script actions
1. It gets the html source code
2. It looks for strings in the source code
3. If it finds a match it does 1 of 2 things. It clicks on a link or if the link is not there then it refreshes the page. Either way it goes to step 4.
4. Waits for the status bar to say done
5. Starts all over again with step 1 via a loop

It is possible for my script to do those 5 steps 60 times an hour. It appears that something is not releasing the memory.

I don't want my script to exit. Your example has exitapp.
I will continually have different URL's,
I do not want a new tab or IE window to open the web pages.

So in a nut shell here is what is happening.
I let my program get the html source code, base on what is in the source code I let my program click on links, I let my program wait for the statusbar to say done. I let my program do it all over again.

thanks for your help Tank.
DataLife

_________________
Check out my scripts.
(MyIpChanger) (XPSnap) (SavePictureAs)

All my scripts are tested on Windows 7, AutoHotkey_L 32 bit Ansi unless otherwise stated.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 29th, 2009, 5:14 pm 
Offline

Joined: April 23rd, 2009, 12:24 am
Posts: 19
I'm still pretty new and haven't had much experience programming is most anything.. but.. just thinking of different things..
When it calls the dll, is there any sort of injection into the iexplore.exe?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 29th, 2009, 5:42 pm 
Offline
User avatar

Joined: December 21st, 2007, 3:14 pm
Posts: 3826
Location: Louisville KY USA
post the entirety of your existing code
or pm it to me

_________________
No matter what your oppinion Please join this discussion
Formal request to Polyethene
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 29th, 2009, 8:07 pm 
Offline

Joined: April 27th, 2008, 5:28 pm
Posts: 489
Here is a very good example.

I run this code and within 5 minutes the memory usage of IE is doubled.

It will find the first link, display a traytip, fileappend something and start over.

The introduction msgbox explains more.

thanks alot

Code:
SetTitleMatchMode,2

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""."
   }

   COM_Init()
   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)
   COM_Term()
   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_CoInitialize()
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)
com_couninitialize()
return




_________________
Check out my scripts.
(MyIpChanger) (XPSnap) (SavePictureAs)

All my scripts are tested on Windows 7, AutoHotkey_L 32 bit Ansi unless otherwise stated.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 29th, 2009, 9:50 pm 
Woah! You have duplicate code all over the place, and init/uninit like a madman, no wonder the memory use :roll: .


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: April 29th, 2009, 10:42 pm 
Offline

Joined: April 27th, 2008, 5:28 pm
Posts: 489
n-l-i-d wrote:
Woah! You have duplicate code all over the place, and init/uninit like a madman, no wonder the memory use :roll: .
Not sure what your talking about. If you are talking about the functions, I have two functions, one for determining when the web page has finished loading and one to retrieve the Html source code.

Are the functions the duplicate code you are talking about? ?

I pulled these two functions from this forum. I do not know how to combine them to initialize and uninitialize only once.

Can I initialize at the top of my script and uninitialize when the script exits?

DataLife

_________________
Check out my scripts.
(MyIpChanger) (XPSnap) (SavePictureAs)

All my scripts are tested on Windows 7, AutoHotkey_L 32 bit Ansi unless otherwise stated.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 29th, 2009, 10:55 pm 
You are mixing COM with a very primitive way of detecting links (hover over the browser and read the statusbar?). You already are taking control over the webpage with COM, so all you need to do is use the links collection in COM to get the links of the page and scan for those you are looking for. Clicking on the found links can be done with, you guessed it: click(), or you could simply navigate to the url. Please, please, please take a closer look at the IE and COM tutorials by tank, you can access all elements of the webpage that way.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: May 8th, 2009, 5:43 am 
Offline

Joined: April 27th, 2008, 5:28 pm
Posts: 489
n-l-i-d wrote:
so all you need to do is use the links collection in COM to get the links of the page and scan for those you are looking for. Clicking on the found links can be done with, you guessed it: click(), or you could simply navigate to the url. Please, please, please take a closer look at the IE and COM tutorials by tank, you can access all elements of the webpage that way.


I have been studying Tanks IE and Com tutorials since your reply. It looks like it is going to take me awhile to figure it out. Obviously, I will have to rewrite most of my script which is much larger then the one I posted here.

In the mean time is there a way to fix the "Out of Memory" error?

I did a google search on IE not releasing memory and came up with tons of results.

Here is one article talking about Java, Dom and releasing dom elements.
http://www.dotvoid.com/2004/09/internet-explorer-eating-memory/
Here is a section from that page
"As I started investigating how IE handles memory when manipulating the DOM using javascript I found out that IE has a garbage collector which does not release memory just because you say so. So what looks like a memory leak might not be one. However, there are other memory problems using DOM in IE."

Here is another section
"What you can do as programmer is to keep track of all your dom references and before leaving for another page, catching the unload event, release all references to dom elements on the page as IE does not release dom nodes referenced by javascript variables when loading another page."

I realize that article is 4 years old, but here is another URL with tons of people with the same problem starting 2007 to May 1, 2009.

Can this be the problem? I know that I am releasing objects right away but do not know if they are Dom elements.

I know nothing about DOM, Com, Java but an trying to learn starting with Tanks tutorial on IE and Com functions.

thanks
DataLife

_________________
Check out my scripts.
(MyIpChanger) (XPSnap) (SavePictureAs)

All my scripts are tested on Windows 7, AutoHotkey_L 32 bit Ansi unless otherwise stated.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 8th, 2009, 10:47 am 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7502
Location: Australia
DataLife wrote:
Can I initialize at the top of my script and uninitialize when the script exits?
Not only can you do so, it is recommended.
Code:
COM_Init()
OnExit, Exiting
return

Exiting:
COM_Term()
ExitApp
It may or may not be necessary to explicitly call COM_Term() when exiting the program, but better safe than sorry.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 8th, 2009, 2:24 pm 
Offline
User avatar

Joined: December 21st, 2007, 3:14 pm
Posts: 3826
Location: Louisville KY USA
DataLife wrote:
http://www.dotvoid.com/2004/09/internet-explorer-eating-memory/
Here is a section from that page
"As I started investigating how IE handles memory when manipulating the DOM using javascript I found out that IE has a garbage collector which does not release memory just because you say so. So what looks like a memory leak might not be one. However, there are other memory problems using DOM in IE."
One really important point here. Please if you get nothing else i say get this
JAVA is a full featured programing language by Sun Microsystems that can be embeded in a html document
Javascript is a scripting language used in html documents and has absolutely no similarity in how it works with JAVA except for its name
this article has nothing to do with JAVA applets and while it seems mostly accurate about javascript nothing in it talks about JAVA which objects created in a java applet are managed by the JRE(Java Runtime Environment) not IE

Please make sure you know the difference before doing more reserch or you are likely to end up in a black hole of misinformation



EDIT: Sorry its early i had this post confused with another user who is having trouble with a JAVA Applet. your link is perfectly relavent to your post.

Code:
links:=com_invoke(pwb,"document.links")
returns an integer a memory reference that returns a collection and for purposes of working with it is functionally equivilent to the following javascript
Code:
var links=document.links;
both of these return objects
you would call
Code:
com_release(links)
in ahk to clean up the memory for each time you call it
Code:
links:=com_invoke(pwb,"document.links")
however something that returns a property value such as value or inner html does not get released as it is not an object pointer

_________________
No matter what your oppinion Please join this discussion
Formal request to Polyethene
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 9th, 2009, 12:40 am 
Offline

Joined: April 27th, 2008, 5:28 pm
Posts: 489
tank wrote:
both of these return objects
you would call
Code:
com_release(links)
in ahk to clean up the memory for each time you call it
Code:
links:=com_invoke(pwb,"document.links")
however something that returns a property value such as value or inner html does not get released as it is not an object pointer


Here is the section of code I am dealing with
Code:
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


I am calling COM_Invoke two times.

Code:
DocEle:=COM_Invoke(pDoc, "documentElement")
htmlcode:=COM_Invoke(DocEle,"innerHTML")


If I understood your reply then I do not need to release the second one because it is "innerHTML"
I have 2 COM_Release
COM_Release(DocEle)
and
COM_Release(pDoc)

I have 2 questions.
1. Which release is releasing which one?
2. Am I releasing what I am supposed to be releasing?

thanks sooo much.
I am really trying hard to understand this.

DataLife

_________________
Check out my scripts.
(MyIpChanger) (XPSnap) (SavePictureAs)

All my scripts are tested on Windows 7, AutoHotkey_L 32 bit Ansi unless otherwise stated.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 9th, 2009, 3:00 pm 
Offline
User avatar

Joined: December 21st, 2007, 3:14 pm
Posts: 3826
Location: Louisville KY USA
DataLife wrote:
If I understood your reply then I do not need to release the second one because it is "innerHTML"
Yes exactly
At this point showing your entire code is about the only way we can drill down further on your issue

_________________
No matter what your oppinion Please join this discussion
Formal request to Polyethene
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 9th, 2009, 5:44 pm 
Offline

Joined: April 27th, 2008, 5:28 pm
Posts: 489
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

_________________
Check out my scripts.
(MyIpChanger) (XPSnap) (SavePictureAs)

All my scripts are tested on Windows 7, AutoHotkey_L 32 bit Ansi unless otherwise stated.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 22 posts ]  Go to page 1, 2  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: dmg, krajan, over21, RaptorX and 63 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group