AutoHotkey Community

It is currently May 27th, 2012, 1:12 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: May 25th, 2008, 2:42 am 
Offline

Joined: December 16th, 2007, 12:55 pm
Posts: 48
So I've been reading and reading and reading and learning and learning and learning, but I still have very little clue what I'm doing. I manage to get some things to work, but I'm not entirely sure why.

A few months ago, ahklerner made this post, where he illustrated an example of using a browser control with tabs.

The next post in the thread is Jero3n translating ahklerner's script to be used with IE.ahk (as opposed to IEcontrol.ahk). However Jero3n's script didn't work.

As I'm trying to use a browser control in a tab with IE.ahk, I started poking around the two scripts. The big difference seemed to be the magic gethostwindow() function ahklerner was using.

I looked at IE.ahk and IEcontrol.ahk (the latter has the gethostwindow() function), and found that IE.ahk was using COM_AtlAxGetContainer(pwb) in a directly analagous way to how IEcontrol.ahk was using gethostwindow(). Ok, I thought, let me try it.

So I did. And it worked! (Working script below) But I still have no idea what it's doing. For example, I use it all the time, but I don't know what "pwb" means in these scripts. I have a general for what window handles are and how they work, but "pwb"s baffle me. I'm getting kind of tired of not understanding why my scripts work.

I'm just frustrated, because thought I'm good at seeing patterns and putting together high-level implementations of stuff, I would like to understand what's really happening rather than my trial and error method of creating scripts that utilize these really interesting bits of lower-level code that, to me, for all intents and purposes, are effectively magic.

Anyway, here's my working code (really, a cleaned up version of ahklerner+Jero3n's code, using the COM_AtlAxGetContainer function), in case anybody else would like to see a way to use browser controls in tabs with IE.ahk:

Code:
; needs IE.ahk in standard library
; http://www.autohotkey.com/forum/topic19225.html

OnExit, WebTerminate
SetTitleMatchMode, 2

W := 640
H := 480
 
Gui +0x2000000 +Lastfound
Gui Margin, 0, 0
Gui, Add, Tab, h25 w%W% gMyTab vSelTab, IE1|IE2
Gui, Show, h%H% w%W%, IE.ahk tabtest
GoSub, WebInit

Return
   
WebInit:
   IE_Init()
   pwb1 := IE_Add(WinExist(), 0, 25, w, h - 25)
   pwb2 := IE_Add(WinExist(), 0, 25, w, h - 25)
   IE_LoadURL(pwb1, "http://www.google.com")
   IE_LoadURL(pwb2, "http://www.yahoo.com")
   OldhWnd := IE1 := COM_AtlAxGetContainer(pwb1)
   IE2 := COM_AtlAxGetContainer(pwb2)
Return

MyTab:
   Gui, Submit, NoHide
   WinHide, % "ahk_id " .  OldhWnd
   WinShow, % "ahk_id " .  %SelTab%
   OldhWnd := %SelTab%
return
   
GuiClose:
WebTerminate:
   Gui, Destroy
   COM_Release(pwb)
   IE_Term()
ExitApp


Report this post
Top
 Profile  
Reply with quote  
PostPosted: May 25th, 2008, 5:12 am 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
pokercurious wrote:
The next post in the thread is Jero3n translating ahklerner's script to be used with IE.ahk (as opposed to IEcontrol.ahk).
Both IE.ahk and IEControl.ahk became obsolete, that's why AtlAx... functions were moved to COM.ahk from them (:I was informed from a friend of mine that some funny guy was talking about this and me and COM related stuffs in a local AHK site).

Quote:
I have a general for what window handles are and how they work, but "pwb"s baffle me.
pwb is a IWebBrowser2 object, and almost always you have to consult MSDN for these kind of COM objects:
http://msdn.microsoft.com/en-us/library/aa752127.aspx

Code:
WebInit:
   COM_AtlAxWinInit()
   hAx1 := COM_AtlAxCreateContainer(WinExist(), 0, 25, w, h - 25, "Shell.Explorer")
   hAx2 := COM_AtlAxCreateContainer(WinExist(), 0, 25, w, h - 25, "Shell.Explorer")
   pwb1 := COM_AtlAxGetControl(hAx1)
   pwb2 := COM_AtlAxGetControl(hAx2)
   COM_Invoke(pwb1, "Navigate2", "http://www.google.com")
   COM_Invoke(pwb2, "Navigate2", "http://www.yahoo.com")
Return

Code:
GuiClose:
WebTerminate:
   Gui, Destroy
   COM_Release(pwb1)
   COM_Release(pwb2)
   COM_AtlAxWinTerm()
ExitApp


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 26th, 2008, 3:13 am 
Offline

Joined: February 17th, 2008, 12:30 am
Posts: 14
So where is the latest version of COM.ahk? Is it this thread? http://www.autohotkey.com/forum/topic19225.html


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 26th, 2008, 4:43 am 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
maoserr wrote:
So where is the latest version of COM.ahk? Is it this thread? http://www.autohotkey.com/forum/topic19225.html

Yes. As far as I can tell, all links of COM.ahk in the forum points to the same/one file.


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: Amandaville, Bing [Bot], BrandonHotkey, chaosad, Google [Bot] and 22 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