AutoHotkey Community

It is currently May 26th, 2012, 5:46 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 119 posts ]  Go to page Previous  1 ... 4, 5, 6, 7, 8  Next
Author Message
PostPosted: April 18th, 2009, 5:02 pm 
Offline

Joined: April 27th, 2008, 5:28 pm
Posts: 489
Sean wrote:
Code:
; Run, iexplore.exe http://www.google.com/
MsgBox, % IEReady()
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
         If   COM_Invoke(pweb, "ReadyState") = 4
            Break
         Else   Sleep 500
   COM_Release(pdoc)
   COM_Release(pweb)
   COM_Term()
   Return   pweb ? "DONE!" : False
}
Sean, instead if using the run command I want to be able to click on a link and wait for that next page to load. I modified your script a little but it does not work.
Can you help please.
DataLife
Code:
F6::
; Run, iexplore.exe http://www.google.com/
MouseMove,300,690
Click   

MsgBox, % IEReady()
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
         If   COM_Invoke(pweb, "ReadyState") = 4
            Break
         Else   Sleep 500
   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 26th, 2009, 7:35 am 
Offline

Joined: April 27th, 2008, 5:28 pm
Posts: 489
I want to refresh a webpage and then use the code below to wait for the webpage to be fully loaded.

I replaced the webpage below with my webpage but it opens a new iexplore window.

I just want to refresh and monitor the current webpage.

How can I modify the code below to do that?


Code:
#Include CoHelper.ahk
F12::
send {F5}
gosub WebPageFullyLoaded
msgbox Web page is fully loaded
return

WebPageFullyLoaded:
CoInitialize()
pie := ActiveXObject("InternetExplorer.Application")
Invoke(pie, "Visible=", "True")
Invoke(pie, "Navigate", "http://foxnews.com")
Loop
{
   If   Invoke(pie, "ReadyState") = 4
      Break
   Sleep,   500
}
Release(pie)
CoUninitialize()
Return
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: April 26th, 2009, 8:39 am 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
DataLife wrote:
I just want to refresh and monitor the current webpage.
You already knew/obtained pweb, so just use it.


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

Joined: April 27th, 2008, 5:28 pm
Posts: 489
The script works very well using pweb to wait for the current page to refresh and finish loading.

I also would like to click on a link and the script tell me when it is finished loading.

Here is my code. It says done instantly after the script clicks on the Google news link.
Code:
SetTitleMatchMode, 2
F6::
WinWaitActive,Google
Click 175,130
MsgBox % IEReady()
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
         If   COM_Invoke(pweb, "ReadyState") = 4
            Break
         Else   Sleep 500
   COM_Release(pdoc)
   COM_Release(pweb)
   COM_Term()
   Return   pweb ? "DONE!" : False
}
Any help would be appreciated.
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 26th, 2009, 8:44 pm 
Offline
User avatar

Joined: December 21st, 2007, 3:14 pm
Posts: 3826
Location: Louisville KY USA
You must first ensure navigation has begun
see below this is true when you send clicks there is a lag between the click and the point where navigation actually begins
Code:
SetTitleMatchMode, 2
F6::
WinWaitActive,Google
Click 175,130
MsgBox % IEReady()
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   Sleep 500
   COM_Release(pdoc)
   COM_Release(pweb)
   COM_Term()
   Return   pweb ? "DONE!" : False
}

_________________
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 26th, 2009, 9:07 pm 
Offline

Joined: April 27th, 2008, 5:28 pm
Posts: 489
Perfect, works great.

Many 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: June 11th, 2009, 2:22 am 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
I rewrote the script using DocumentComplete event. I suggest to test it against sites the original script used to report falsely.

Code:
#Persistent
sUrl :=   "http://www.autohotkey.com/forum/"

COM_Init()
pweb :=   COM_CreateObject("InternetExplorer.Application")
sink :=   COM_ConnectObject(pweb, "IE_")
COM_Invoke(pweb, "Visible", True)
COM_Invoke(pweb, "Navigate2", sUrl)
Return

OnComplete:
MsgBox,   DONE
COM_DisconnectObject(sink)
COM_Release(pweb)
COM_Term()
ExitApp

IE_DocumentComplete(prms, sink)
{
   If   NumGet(NumGet(prms+0)+24) = NumGet(sink+12)
      SetTimer, OnComplete, -10
/* more rigorous way
   COM_Release(punk1:=COM_QueryInterface(NumGet(NumGet(prms+0)+24),0))
   COM_Release(punk2:=COM_QueryInterface(NumGet(sink+12),0))
   If   (punk1 = punk2)
      SetTimer, OnComplete, -10
*/
}


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 2nd, 2009, 5:07 am 
Offline
User avatar

Joined: May 24th, 2009, 5:35 am
Posts: 2099
Location: Iowa, USA
Sean wrote:
I rewrote the script using DocumentComplete event
Thank you for this example. I haven't found any issues with your script, but I'm trying to create a function version of this concept to work with inactive IE tabs. I found a possible issue, which is if the DocumentComplete event occurs before COM_ConnectObject connects (I think). However, the only webpage I've been able to create this issue with is Yahoo.com. Here's an example of what I mean (perhaps oversimplified):
Code:
; requires already existing IE navigated to www.google.com

#Persistent
COM_Init()
If !pwb := IEGetTab("Google")
   Return
; LoadURL(pwb, "www.yahoo.com") ; Edit - could use this line instead of next 2 lines
COM_Invoke(pwb, "Navigate", "www.yahoo.com")
PageLoaded(pwb)

MsgBox DONE!

COM_Release(pwb)
COM_Term()
Return

;-------------------------------------------------------------------------------------------------
IEGetTab(name) {
   oShell := COM_CreateObject("Shell.Application")
   Loop % COM_Invoke(oShell, "Windows.Count")
      If (COM_Invoke(oShell, "Windows.item[" A_Index - 1 "].LocationName") = name
      && COM_Invoke(oShell, "Windows.item[" A_Index - 1 "].Name") = "Windows Internet Explorer")
      {   pweb := COM_Invoke(oShell, "Windows.item[" A_Index - 1 "]")
         Break
      }
   COM_Release(oShell)
   Return pweb
}

PageLoaded(pweb) {
   global webpage_loading = 1
   sink := COM_ConnectObject(pweb, "IE_")
   While webpage_loading
      Sleep 1
   COM_DisconnectObject(sink)
   Return
}


IE_DocumentComplete() {
   SetTimer, OnComplete, -10
}

OnComplete:
webpage_loading = 0
Return


; Added based off Sean's recommendation in the next post
LoadURL(pweb, URL) {
   global webpage_loading = 1
   sink := COM_ConnectObject(pweb, "IE_")
   COM_Invoke(pweb, "Navigate", URL)
   While webpage_loading
      Sleep 1
   COM_DisconnectObject(sink)
   Return
}


Edit - updated script to include the Name property, as Sean suggests in the next post. Also, added LoadURL().

_________________
Image
Recommended: AutoHotkey_L
Basic Webpage Controls


Last edited by jethrow on August 2nd, 2009, 7:33 pm, edited 4 times in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 2nd, 2009, 12:28 pm 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
Time Travel has not been realized yet. There is nothing you can do about events before connected to an object. Connect first, then navigate. That's how it's supposed to work.
jethrow wrote:
This would verify the ShellWindow item is an IE window, and not a Windows Explorer window.
You may use Name or FullName property instead.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 2nd, 2009, 5:56 pm 
Offline
User avatar

Joined: December 21st, 2007, 3:14 pm
Posts: 3826
Location: Louisville KY USA
heya good lookin work one thing
Code:
;-------------------------------------------------------------------------------------------------
IEGetTab(name) {
   oShell := COM_CreateObject("Shell.Application")
   Loop % COM_Invoke(oShell, "Windows.Count")
      If (COM_Invoke(oShell, "Windows.item[" A_Index - 1 "].LocationName") = name
      && COM_Invoke(oShell, "Windows.item[" A_Index - 1 "].Name") = "Windows Internet Explorer")
      {   pweb := COM_Invoke(oShell, "Windows.item[" A_Index - 1 "]")
         Break
      }
   COM_Release(oShell)
   Return pweb
}
I am sure you already knew and just overlooked this but the Windows Internet Explorer and Microsoft Internet Explorer suffixes do not actually come thru the LocationName property of the iWebBrowser2 object

here is my suggestion
Code:
IEGetTab(name) {
   If   oShell := COM_CreateObject("Shell.Application") {
      If   oWindows:=COM_Invoke(oShell, "Windows")   {
;~          to filter out the suffixes automatically
         StringSplit,name,name,- ; takes care of either suffix
         name=%name1% ; trim trailing spaces
         Loop,% COM_Invoke(oWindows, "Count")
            If   pweb:=InStr(COM_Invoke(oWindows, "item[" A_Index - 1 "].LocationName"),name) ? COM_Invoke(oWindows, "item", A_Index - 1) :
               break
      }
      COM_Release(oShell)
   }
   Return pweb
}

EDIT I incorrectly accused jethrow of using LocationName instead of Name. but as the result could be Windows... in IE7 or 8 it would be Microsoft .... in previous versions. This tactic would also be un necesary since the ShellWindows collection only returns WebBrowser objects
Edit Corrected a typo in my own example used name instead of LocationName

_________________
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: September 22nd, 2009, 2:58 pm 
Offline

Joined: July 4th, 2009, 6:53 pm
Posts: 36
tank wrote:
You must first ensure navigation has begun
see below this is true when you send clicks there is a lag between the click and the point where navigation actually begins
Code:
SetTitleMatchMode, 2
F6::
WinWaitActive,Google
Click 175,130
MsgBox % IEReady()
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   Sleep 500
   COM_Release(pdoc)
   COM_Release(pweb)
   COM_Term()
   Return   pweb ? "DONE!" : False
}


I'm having issues running the code. The line that initialized pweb is not included, which does not allow the code to compile. How can we remedy this?

The big picture question is, how can we reuse this code without creating a new IE process, and just have the code find an existing IE process via searching the IE's title bar?

By the way, I've added this script to the wiki. You can find it here:
http://www.autohotkey.com/wiki/index.ph ... IE_via_COM


Last edited by ghee22 on September 22nd, 2009, 3:02 pm, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 22nd, 2009, 3:02 pm 
Offline
User avatar

Joined: December 21st, 2007, 3:14 pm
Posts: 3826
Location: Louisville KY USA
huh ???????? :? it is included
below is cute from the code you just quoted

Code:
......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}").......

_________________
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: September 22nd, 2009, 3:56 pm 
Offline

Joined: July 4th, 2009, 6:53 pm
Posts: 36
tank wrote:
huh ???????? :? it is included
below is cute from the code you just quoted

Code:
......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}").......


Thank you! Mistaken post, was using old code. Now I am now using Sean's latest post code and it also works with existing IE processes. It just takes the active window and works with that. Thank you.


Report this post
Top
 Profile  
Reply with quote  
PostPosted: October 10th, 2009, 11:39 pm 
Sean wrote:
It'll navigate and wait until a webpage is completely loaded in an Internet Explorer.

NEED the latest COM Standard Library.

Code:
#Persistent
sUrl :=   "http://www.autohotkey.com/forum/"

COM_Init()
pweb :=   COM_CreateObject("InternetExplorer.Application")
sink :=   COM_ConnectObject(pweb, "IE_")
COM_Invoke(pweb, "Visible", True)

bComplete := False
COM_Invoke(pweb, "Navigate2", sUrl)
While !bComplete
      Sleep, 500

COM_DisconnectObject(sink)
COM_Release(pweb)
COM_Term()
Return

OnComplete:
bComplete := True
Return

IE_DocumentComplete(prms, sink)
{
   If   NumGet(NumGet(prms+0)+24) = NumGet(sink+12)
      SetTimer, OnComplete, -10
/* more rigorous way
   COM_Release(punk1:=COM_QueryInterface(NumGet(NumGet(prms+0)+24),0))
   COM_Release(punk2:=COM_QueryInterface(NumGet(sink+12),0))
   If   (punk1 = punk2)
      SetTimer, OnComplete, -10
*/
}

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}")
   {
      While,   COM_Invoke(pweb, "ReadyState") <> 4
      Sleep,   500
      While,   COM_Invoke(pweb, "document.readyState") <> "complete"
      Sleep,   500
      COM_Release(pweb)
   }
   COM_Release(pdoc)
   COM_Term()
   Return   pweb ? "DONE!" : False
}


hello....
above is Seans code.....

below is my code....

i use @ work....
can someone tell me how to include SEANs code..


Quote:
WinWait, Newtop Inc. - Windows Internet Explorer,
IfWinNotActive, Newtop Inc. - Windows Internet Explorer, , WinActivate, Newtop Inc. - Windows Internet Explorer,
WinWaitActive, Newtop Inc. - Windows Internet Explorer, (( also note that at the time the script is running i have 3 windows with the same name ))

#0::
Sleep, 100
Send, {CTRLDOWN}f{CTRLUP}
WinWait, Find,
IfWinNotActive, Find, , WinActivate, Find,
WinWaitActive, Find,
Send, copyright{ENTER}
sleep, 300
send, {ESC}
sleep, 1000
Send, {SHIFTDOWN}{TAB}
sleep, 300
send, {SHIFTDOWN}{TAB}
sleep, 300
send, {SPACE}
Sleep, 6800 <-- this is where i have the problem some windows could
take about 7 seconds to load others 10 or others
3 seconds... i need the code above to maybe
automatically know when the window finished loading
then continue on with the macro

MouseClick, left, 938, 93
MouseClick, left, 938, 93 ((this is the 3rd window with the same name))
Sleep, 1000
Send, {CTRLDOWN}c{CTRLUP} (( it copies a number from this window ))

sleep, 200
send, {ALTDOWN}{F4}{ALTUP} (( close the third window ))
Sleep, 3400
Send, {ALTDOWN}{F4}{ALTUP} (( close the second window ))

Sleep, 2400
WinWait, Newtop Inc. - Windows Internet Explorer,
IfWinNotActive, Newtop Inc. - Windows Internet Explorer, , WinActivate, Newtop Inc. - Windows Internet Explorer,
WinWaitActive, Newtop Inc. - Windows Internet Explorer,
#5::
MouseClick, left, 1256, 635
Send, c{TAB}{TAB}{SPACE}{SHIFTDOWN}{TAB}{SHIFTUP}{SPACE}
Sleep, 2000
MouseClick, left, 1255, 635
Sleep, 200
Send, p{TAB}{TAB}{SPACE}{SHIFTDOWN}{TAB}{SHIFTUP}{SPACE}
sleep, 200
MouseClick, left, 93, 206
Sleep, 200
#6::
MouseClick, left, 427, 1044
Sleep, 1000
WinWait, OrderTracking - Windows Internet Explorer,
IfWinNotActive, OrderTracking - Windows Internet Explorer, , WinActivate, OrderTracking - Windows Internet Explorer,
WinWaitActive, OrderTracking - Windows Internet Explorer,
Sleep, 1500
MouseClick, left, 1117, 744
Sleep, 1000
Send, {PGDN}{PGDN}{PGDN}{PGDN}
sleep, 800
send, {SHIFTDOWN}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{SHIFTUP}{SPACE}
sleep, 1500
send, {CTRLDOWN}v{CTRLUP}{LEFT}{LEFT}{left}{left}{left}{LEFT}{LEFT}{LEFT}{LEFT}{BACKSPACE}{BACKSPACE}{BACKSPACE}
sleep, 1500
send, {TAB}sa{TAB}{TAB}{SPACE}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{SPACE}
sleep, 100
return



thank you very very much for looking into it
and modyfing my code so it does
what i want it to do...


Report this post
Top
  
Reply with quote  
PostPosted: October 11th, 2009, 3:05 pm 
Offline

Joined: July 4th, 2009, 6:53 pm
Posts: 36
SammE wrote:
Sean wrote:
It'll navigate and wait until a webpage is completely loaded in an Internet Explorer.

NEED the latest COM Standard Library.

Code:
#Persistent
sUrl :=   "http://www.autohotkey.com/forum/"

COM_Init()
pweb :=   COM_CreateObject("InternetExplorer.Application")
sink :=   COM_ConnectObject(pweb, "IE_")
COM_Invoke(pweb, "Visible", True)

bComplete := False
COM_Invoke(pweb, "Navigate2", sUrl)
While !bComplete
      Sleep, 500

COM_DisconnectObject(sink)
COM_Release(pweb)
COM_Term()
Return

OnComplete:
bComplete := True
Return

IE_DocumentComplete(prms, sink)
{
   If   NumGet(NumGet(prms+0)+24) = NumGet(sink+12)
      SetTimer, OnComplete, -10
/* more rigorous way
   COM_Release(punk1:=COM_QueryInterface(NumGet(NumGet(prms+0)+24),0))
   COM_Release(punk2:=COM_QueryInterface(NumGet(sink+12),0))
   If   (punk1 = punk2)
      SetTimer, OnComplete, -10
*/
}

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}")
   {
      While,   COM_Invoke(pweb, "ReadyState") <> 4
      Sleep,   500
      While,   COM_Invoke(pweb, "document.readyState") <> "complete"
      Sleep,   500
      COM_Release(pweb)
   }
   COM_Release(pdoc)
   COM_Term()
   Return   pweb ? "DONE!" : False
}


hello....
above is Seans code.....

below is my code....

i use @ work....
can someone tell me how to include SEANs code..


Code:
WinWait, Newtop Inc. - Windows Internet Explorer,
IfWinNotActive, Newtop Inc. - Windows Internet Explorer, , WinActivate, Newtop Inc. - Windows Internet Explorer,
WinWaitActive, Newtop Inc. - Windows Internet Explorer, (( also note that at the time the script is running i have 3 windows with the same name ))

#0::
Sleep, 100
Send, {CTRLDOWN}f{CTRLUP}
WinWait, Find,
IfWinNotActive, Find, , WinActivate, Find,
WinWaitActive, Find,
Send, copyright{ENTER}
sleep, 300
send, {ESC}
sleep, 1000
Send, {SHIFTDOWN}{TAB}
sleep, 300
send, {SHIFTDOWN}{TAB}
sleep, 300
send, {SPACE}
Sleep, 6800    <-- this is where i have the problem some     windows could
                       take about 7 seconds to load others 10 or others 
                          3 seconds... i need the code above to maybe
                          automatically know when the window finished loading
                          then continue on with the macro

MouseClick, left,  938,  93
MouseClick, left,  938,  93  ((this is the 3rd window with the same name))
Sleep, 1000
Send, {CTRLDOWN}c{CTRLUP}  (( it copies a number from this window ))

sleep, 200
send, {ALTDOWN}{F4}{ALTUP}  (( close the third window ))
Sleep, 3400
Send, {ALTDOWN}{F4}{ALTUP}    (( close the second window ))

Sleep, 2400
WinWait, Newtop Inc. - Windows Internet Explorer,
IfWinNotActive, Newtop Inc. - Windows Internet Explorer, , WinActivate, Newtop Inc. - Windows Internet Explorer,
WinWaitActive, Newtop Inc. - Windows Internet Explorer,
#5::
MouseClick, left,  1256,  635
Send, c{TAB}{TAB}{SPACE}{SHIFTDOWN}{TAB}{SHIFTUP}{SPACE}
Sleep, 2000
MouseClick, left,  1255,  635
Sleep, 200
Send, p{TAB}{TAB}{SPACE}{SHIFTDOWN}{TAB}{SHIFTUP}{SPACE}
sleep, 200
MouseClick, left,  93,  206
Sleep, 200
#6::
MouseClick, left,  427,  1044
Sleep, 1000
WinWait, OrderTracking - Windows Internet Explorer,
IfWinNotActive, OrderTracking - Windows Internet Explorer, , WinActivate, OrderTracking - Windows Internet Explorer,
WinWaitActive, OrderTracking - Windows Internet Explorer,
Sleep, 1500
MouseClick, left,  1117,  744
Sleep, 1000
Send, {PGDN}{PGDN}{PGDN}{PGDN}
sleep, 800
send, {SHIFTDOWN}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{SHIFTUP}{SPACE}
sleep, 1500
send, {CTRLDOWN}v{CTRLUP}{LEFT}{LEFT}{left}{left}{left}{LEFT}{LEFT}{LEFT}{LEFT}{BACKSPACE}{BACKSPACE}{BACKSPACE}
sleep, 1500
send, {TAB}sa{TAB}{TAB}{SPACE}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{SPACE}
sleep, 100
return



thank you very very much for looking into it
and modyfing my code so it does
what i want it to do...


I removed everything except IE_Ready() and added a function, Wait_for_IE(). Here's my version of Sean's modified code:
Code:
Wait_for_IE(IE_title) {
SetTitleMatchMode, 2
WinWaitActive,%IE_title%
IEReady()
SetTitleMatchMode, RegEx
}

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}")
   {
      While,   COM_Invoke(pweb, "ReadyState") <> 4
      Sleep,   500
      While,   COM_Invoke(pweb, "document.readyState") <> "complete"
      Sleep,   500
      COM_Release(pweb)
   }
   COM_Release(pdoc)
   COM_Term()
   Return   pweb ? "DONE!" : False
}


To wait for a certain window to load, I call the function I added like so:
Code:
Wait_for_IE("Title of IE window to wait for")


Hence, with my modified version, I would replace your code:
Code:
WinWait, OrderTracking - Windows Internet Explorer,
IfWinNotActive, OrderTracking - Windows Internet Explorer, , WinActivate, OrderTracking - Windows Internet Explorer,
WinWaitActive, OrderTracking - Windows Internet Explorer,

with this code:
Code:
Wait_for_IE(" OrderTracking - Windows Internet Explorer")


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 ... 4, 5, 6, 7, 8  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: Apollo, Bing [Bot], XX0, Yahoo [Bot] and 11 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