AutoHotkey Community

It is currently May 26th, 2012, 12:43 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 119 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6, 7, 8  Next
Author Message
 Post subject:
PostPosted: December 10th, 2007, 3:29 am 
Offline

Joined: June 26th, 2006, 6:14 pm
Posts: 1379
Location: USA
That still does not work for me.
The first loop never breaks.

_________________
Image
ʞɔпɟ əɥʇ ʇɐɥʍ


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 10th, 2007, 4:16 am 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
ahklerner wrote:
That still does not work for me.
The first loop never breaks.

This is what lexikos said, invoking "ReadyState" on wrong pie. Please run the script I linked how many pages/windows of IE are running after "Navigate".


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 10th, 2007, 4:29 am 
Offline

Joined: June 26th, 2006, 6:14 pm
Posts: 1379
Location: USA
I get this:
Quote:
---------------------------
IEJS.AHK
---------------------------
1180506 : "","","","Windows Internet Explorer","C:\Program Files\Internet Explorer\iexplore.exe"
: "","","","",""
: "","","","",""
: "","","","",""
: "","","","",""
: "","","","",""
: "","","","",""
5047356 : "","","","Windows Internet Explorer","C:\Program Files\Internet Explorer\iexplore.exe"
591834 : "","","Website found. Waiting for reply...","Windows Internet Explorer","C:\Program Files\Internet Explorer\iexplore.exe"

---------------------------
OK
---------------------------



With this:
Code:
^F1::
MsgBox, % "Pie " . LoadIEDone("http://www.google.com")
return



LoadIEDone(URL_TO_LOAD)
{
com_CoInitialize()
pie := com_ActiveXObject("InternetExplorer.Application")
com_Invoke(pie, "Visible=", True)
com_Invoke(pie, "Navigate", URL_TO_LOAD)
psh :=   COM_CreateObject("Shell.Application")
psw :=   COM_Invoke(psh, "Windows")
Loop, %   COM_Invoke(psw, "Count")
   pwb := COM_Invoke(psw, "Item", A_Index-1), sInfo .= COM_Invoke(pwb, "hWnd") . " : """ . COM_Invoke(pwb, "LocationURL") . """,""" . COM_Invoke(pwb, "LocationName") . """,""" . COM_Invoke(pwb, "StatusText") . """,""" . COM_Invoke(pwb, "Name") . """,""" . COM_Invoke(pwb, "FullName") . """`n", COM_Release(pwb)
COM_Release(psw)
COM_Release(psh)
;COM_Term()

MsgBox, % sInfo

Loop
   If   pdoc:=Com_Invoke(pie, "Document")
        Break
   Else Sleep 100
Loop
   If   Com_Invoke(pdoc, "readyState") = "complete"
        Break
   Else Sleep 500
Com_Release(pdoc)

com_Release(pie)
com_CoUninitialize()
return pie
}

_________________
Image
ʞɔпɟ əɥʇ ʇɐɥʍ


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 10th, 2007, 5:53 am 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
ahklerner wrote:
I get this:
Quote:
---------------------------
IEJS.AHK
---------------------------
1180506 : "","","","Windows Internet Explorer","C:\Program Files\Internet Explorer\iexplore.exe"
: "","","","",""
: "","","","",""
: "","","","",""
: "","","","",""
: "","","","",""
: "","","","",""
5047356 : "","","","Windows Internet Explorer","C:\Program Files\Internet Explorer\iexplore.exe"
591834 : "","","Website found. Waiting for reply...","Windows Internet Explorer","C:\Program Files\Internet Explorer\iexplore.exe"

---------------------------
OK
---------------------------

So, the linked script seemed to work, at least partially as there exist lots of blank ones too. I was worried it also might not work in Vista.

Which one the web page is actually loading in? Is it the same one as the original pie or not?
Code:
MsgBox, % pie . " | hWnd: " . COM_Invoke(pie, "hWnd")

Anyway, now it may be a matter of picking the corrected one where the wanted web page is loading that I can't do from here.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 10th, 2007, 11:31 am 
Offline

Joined: November 3rd, 2007, 12:41 am
Posts: 188
Quote:
591834 : "","","Website found. Waiting for reply...","Windows Internet Explorer","C:\Program Files\Internet Explorer\iexplore.exe"

I would think that the window/pie we want is this one. Could we loop through these windows and reliably pick out the wanted window by statusbar text containing something? Would that be a reliable way to go? It's silly how much harder this appears in Vista!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 10th, 2007, 1:04 pm 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
Erittaf wrote:
Quote:
591834 : "","","Website found. Waiting for reply...","Windows Internet Explorer","C:\Program Files\Internet Explorer\iexplore.exe"

I would think that the window/pie we want is this one.

Then, you may use this:
Code:
LoadIEDone(URL_TO_LOAD)
{
COM_Init()
pie := COM_ActiveXObject("InternetExplorer.Application")
COM_Invoke(pie, "Visible=", True)
COM_Invoke(pie, "Navigate", URL_TO_LOAD)
COM_Release(pie)
pie := 0

psh :=  COM_CreateObject("Shell.Application")
psw :=  COM_Invoke(psh, "Windows")
Loop, % COM_Invoke(psw, "Count")
{
        pwb :=  COM_Invoke(psw, "Item", A_Index-1)
        If      COM_Invoke(pwb, "Name") = "Windows Internet Explorer"
        &&      COM_Invoke(pwb, "StatusText") = "Website found. Waiting for reply..."
        {
                pie := pwb
                Break
        }
        Else    COM_Release(pwb)
}
COM_Release(psw)
COM_Release(psh)

If      pie
        Loop
                If      COM_Invoke(pie, "ReadyState") = 4
                        Break
                Else    Sleep 500
COM_Release(pie)
COM_Term()
Return  pie
}

One thing though. The StatusText may be varying, so may be needed some fine-tuning.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 11th, 2007, 4:15 am 
Offline

Joined: November 3rd, 2007, 12:41 am
Posts: 188
might there be a way to check for status text containing anything?? from the looks of it the window we want is the only one that has any status text.

Also, For what I need I know what website I am send the browser to. Is there a way to do something like (psuedocode)
Code:
COM_Invoke(pwb, "addressBar") = "SomeSiteWeAreGoingTo"


Pooisble??


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 11th, 2007, 5:02 am 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
Erittaf wrote:
Also, For what I need I know what website I am send the browser to. Is there a way to do something like (psuedocode)
Code:
COM_Invoke(pwb, "addressBar") = "SomeSiteWeAreGoingTo"

I don't really know about that, however, I'm a bit skeptical about it. Haven't you tried it? Anyway, there were two observations from the result of ahklerner. One is what you said: only the needed one has a status text. If it's consistently so, you may simply use
Code:
COM_Invoke(pwb, "StatusText")

instead of
Code:
COM_Invoke(pwb, "StatusText") = "Website found. Waiting for reply..."

The other one is: the result appeared somehow chronologically. If it always is, the first loop may not be needed, could simply replace it as
Code:
pie := COM_Invoke(psw, "Item", COM_Invoke(psw, "Count") - 1)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 11th, 2007, 6:46 am 
Offline

Joined: November 3rd, 2007, 12:41 am
Posts: 188
sorry, no I haven't tried it... No vista box :-(

Thanks for the info, will write some tests and try them at work or something. Thanks!


Report this post
Top
 Profile  
Reply with quote  
PostPosted: January 16th, 2008, 2:16 pm 
Thanks Sean for the code. :D

I wan to ask whether the code works equally well for AVANT browser
http://www.avantbrowser.com/

This browser uses Internet Explorer's engine.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: February 13th, 2008, 8:13 pm 
Offline

Joined: November 3rd, 2007, 12:41 am
Posts: 188
Well I have a Vista box now and after helping with another related thread Lexikos pointed me at the answer for the vista problem. After playing with it some more it seems that the difference is in how long it takes for vista to load. It never got there in time on my system. However if you modify one of the two lines noted in the code below you can tweak how long it takes before timing out and throwing the error. (I just set the first one to 500 since the loop breaks when the page actually finishes loading... it doesn't take up too much extra on the resources, at least not in vista terms.)

Happy coding!


Code:
IEReady(hIESvr = 0)
{
   If Not   hIESvr
   {
      Loop,   50                       ;<-------------modify this line!!
      {
         ControlGet, hIESvr, hWnd, , Internet Explorer_Server1, A ; ahk_class IEFrame
         If   hIESvr
            Break
         Else   Sleep 100            ;<-------------or modify this line!!
      }
      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
         If   COM_Invoke(pweb, "ReadyState") = 4
            Break
         Else   Sleep 500
   COM_Release(pdoc)
   COM_Release(pweb)
   COM_Term()
   Return   pweb ? "DONE!" : False
}


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 14th, 2008, 1:58 am 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7501
Location: Australia
If you change "Loop, 50" to "Loop", it will never time out. It isn't "the vista problem", but "the slow PC problem." :P


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 14th, 2008, 2:05 am 
Offline

Joined: November 3rd, 2007, 12:41 am
Posts: 188
lol, true enough. Maybe I need to increase my Precision-O-Meter :?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 5th, 2008, 6:17 am 
Thanks Sean.
This seems really great.
Is it possible to use Invoke() to change size of IE window ?


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: April 5th, 2008, 7:23 am 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7501
Location: Australia
Why not just use WinMove? I suppose you could invoke the Width and Height properties of the WebBrowser/IE object...


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 119 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6, 7, 8  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], JamixZol, JSLover, Yahoo [Bot] and 68 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