AutoHotkey Community

It is currently May 26th, 2012, 11:49 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 12 posts ] 
Author Message
PostPosted: November 9th, 2009, 6:02 pm 
Hi there

I have tried the solution offered at www.autohotkey.com/forum/topic19256.html

The thing is that the webpage is opened in a new explorer window and not in a new tab as I want. is there anyway to change this?

thanks


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: November 9th, 2009, 6:26 pm 
most likely - do you have an example?


Report this post
Top
  
Reply with quote  
 Post subject: well...
PostPosted: November 9th, 2009, 11:04 pm 
Sorry if I am not clear , but I want to open a webpage (lets say Gmail) , and wait for it to load in order to continue and enter username&password. in order to do that I 've read the suggestion at www.autohotkey.com/forum/topic19256.html. I am trying to put the suggested lines in my script. The thing is that the explorer window is open in a new window, and not in a new tab (like pressing ctrl+t in explorer) which is what I want...

what should be my script stracture?, 1.gmail, 2.put the suggested script which makes it wait to load, and then 3. continue with another lines (enter username&password)?


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: November 9th, 2009, 11:32 pm 
Offline
User avatar

Joined: May 24th, 2009, 5:35 am
Posts: 2099
Location: Iowa, USA
I'm seeing 2 different questions, the first being how to open the webpage in a new tab rather than a new window. How are you opening this webpage? Clicking a link? Using th Run command? Are you using Internet Explorer & COM, as Sean's thread shows? What do you have so far for code?

_________________
Image
Recommended: AutoHotkey_L
Basic Webpage Controls


Report this post
Top
 Profile  
Reply with quote  
 Post subject: ok
PostPosted: November 10th, 2009, 4:59 pm 
well , I guess the confusion arrise mostly because I am not used to run this script. I have understand that in order to run a webpage and wait for it to load I have to run sean script ( just change the webpage adress in sUrl line at the begining of the script)...

so far I have loaded a webpage (google for example) by the simple command : run www.google.com. then a new tab in internet explorer (in an explorer window which was already opened) is loaded.

when I am running sean script , a webpage is loaded in a new explorer window... all i do is running this: (maybe I need to do something else?)

#Persistent
sUrl := "http://www.gmail.com"

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
}


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: November 10th, 2009, 6:58 pm 
Offline
User avatar

Joined: May 24th, 2009, 5:35 am
Posts: 2099
Location: Iowa, USA
I'm gonna take a shot in the dark and say you're not experienced with COM, right? :wink:

Sean's example uses the DocumentComplete event; however, for simplicity, I'm going to use the ReadyState (or Busy - noted in comments) property. (if the previous sentence doesn't make sense right now, don't worry, it doesn't matter) Here is an example:
Code:
sUrl := "http://www.gmail.com" ; first webpage to load
sUrl2 := "www.google.com" ; second webpage to load
Name := "UserName"
PW := "Password"

COM_Init() ; initializes COM environment
pweb := COM_CreateObject("InternetExplorer.Application") ; creates IE
COM_Invoke(pweb, "Visible", True) ; makes IE visible
COM_Invoke(pweb, "Navigate2", sUrl) ; navigates to the URL

; the next 2 lines wait for the webpage to be loaded. (NOTE - you could also use Sean's IEReady() function instead of the next 2 lines)
While, COM_Invoke(pweb, "ReadyState") <> 4 ; While, COM_Invoke(pweb, "Busy")
   Sleep, 10
   
; the next two lines fill in the UserName & Password, but they also prove the WebPage is loaded (otherwise they would cause a COM ERROR)
COM_Invoke(pweb, "document.all.Email.Value", Name) ; NOTE - the red items are specific to the webpage
COM_Invoke(pweb, "document.all.Passwd.Value", PW)
; COM_Invoke(pweb, "document.all.signIn.click") ; this line would click the "Sign In" button
MsgBox, Webpage Loaded

COM_Invoke(pweb, "Navigate2", sUrl2, 0x0800) ; 0x0800 parameter causes this webpage to be opened in a new tab

COM_Release(pweb) ; releases "pweb" - COM Object
COM_Term() ; terminates COM environment
Return


If this looks like a bunch of jibberish to you, I wouldn't be surprised (it would have to me :wink:). However, IMO this is the best way to answer your question in one post. I would recommend studying Sean's thread, this example, & other COM examples in the forum.

_________________
Image
Recommended: AutoHotkey_L
Basic Webpage Controls


Last edited by jethrow on November 12th, 2009, 4:14 am, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 11th, 2009, 2:23 am 
Offline

Joined: March 27th, 2009, 1:00 am
Posts: 26
For some reason the above code doesn't work for me in IE7.

Code:
COM_Invoke(pweb, "Visible", True) ; creates a blank IE7 window
COM_Invoke(pweb, "Navigate2", sUrl) ; creates a new IE7 window for sUrl and with a different pweb value.


So I basically have to find the the new "pweb" and then the ReadyState/Value functions will work.. It's odd because the first Navigate2 function is sent to the first pweb, but opens a new window. However, the second Navigate2 function is sent to the 2nd pweb and it doesn't open a new window as the first does. The same happens with plain old Navigate.

Not sure if that makes sense, nor why it's happening.

Edit: I'm using Vista on this machine, however I know I've had similar code working on XP on other machines. So it might be either my IE7 settings (I reset them to default, same problem) or my OS (likely?).


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 11th, 2009, 4:50 pm 
Offline

Joined: April 8th, 2009, 8:23 pm
Posts: 3036
Location: Rio de Janeiro - RJ - Brasil
Tested, works for me.
(IE8, WinXP)

_________________
"Read the manual. Read it again. Search the forum.
Try something before asking. Show what you've tried.
"
Image
Antonio França
My stuff: Google Profile


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 12th, 2009, 12:08 am 
Offline

Joined: March 27th, 2009, 1:00 am
Posts: 26
I'm simply wondering why it wouldn't work on my machine/setup. Visible creates a blank IE. Navigate2/Navigate (for that 'identity') opens a 2nd window with a different object 'identity.' I can make it work, regardless. I was wondering why this doesn't work. It seems like it ought to.


Report this post
Top
 Profile  
Reply with quote  
PostPosted: November 13th, 2009, 4:12 pm 
I have to cope with the same problem in vista, as I tried this... How do you get over this?


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: November 16th, 2009, 1:36 am 
Offline
User avatar

Joined: May 24th, 2009, 5:35 am
Posts: 2099
Location: Iowa, USA
See if this thread answers your question: running COM commands on vista

_________________
Image
Recommended: AutoHotkey_L
Basic Webpage Controls


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 16th, 2009, 5:28 am 
Offline

Joined: January 7th, 2007, 1:43 pm
Posts: 107
jethrow wrote:
I'm gonna take a shot in the dark and say you're not experienced with COM, right? :wink:

Sean's example uses the DocumentComplete event; however, for simplicity, I'm going to use the ReadyState (or Busy - noted in comments) property. (if the previous sentence doesn't make sense right now, don't worry, it doesn't matter) Here is an example:
Code:
sUrl := "http://www.gmail.com" ; first webpage to load
sUrl2 := "www.google.com" ; second webpage to load
Name := "UserName"
PW := "Password"

COM_Init() ; initializes COM environment
pweb := COM_CreateObject("InternetExplorer.Application") ; creates IE
COM_Invoke(pweb, "Visible", True) ; makes IE visible
COM_Invoke(pweb, "Navigate2", sUrl) ; navigates to the URL

; the next 2 lines wait for the webpage to be loaded. (NOTE - you could also use Sean's IEReady() function instead of the next 2 lines)
While, COM_Invoke(pweb, "ReadyState") <> 4 ; While, COM_Invoke(pweb, "Busy")
   Sleep, 10
   
; the next two lines fill in the UserName & Password, but they also prove the WebPage is loaded (otherwise they would cause a COM ERROR)
COM_Invoke(pweb, "document.all.Email.Value", Name) ; NOTE - the red items are specific to the webpage
COM_Invoke(pweb, "document.all.Passwd.Value", PW)
; COM_Invoke(pweb, "document.all.signIn.click") ; this line would click the "Sign In" button
MsgBox, Webpage Loaded

COM_Invoke(pweb, "Navigate2", sUrl2, 0x0800) ; 0x0800 parameter causes this webpage to be opened in a new tab

COM_Release(pweb) ; releases "pweb" - COM Object
COM_Term() ; terminates COM environment
Return


If this looks like a bunch of jibberish to you, I wouldn't be surprised (it would have to me :wink:). However, IMO this is the best way to answer your question in one post. I would recommend studying Sean's thread, this example, & other COM examples in the forum.

ERROR to click the button.
Image[/img]


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 12 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: hyper_, Leef_me, patgenn123, Pulover, rbrtryn, XstatyK and 21 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