Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

IE and Gui Browser Com Tutorial


  • This topic is locked This topic is locked
47 replies to this topic
tank
  • Administrators
  • 4345 posts
  • AutoHotkey Foundation
  • Last active: May 02 2019 09:16 PM
  • Joined: 21 Dec 2007
I have asked this thread be locked because it is outdated and i no longer have the time to keep up with it in the future please refer to <!-- m -->http://www.autohotke...pic.php?t=51020<!-- m -->





AHK COM Internet Explorer and Gui Browser documentation
First if you have not done so an understanding of basic AHK is required
see the quick-start tutorial.
I will simply ignore basic syntax questions like when to or not to use %
Using Seans COM library to automate web tasks takes some learning how but
removes the need to use some other clumbsy tactics like sending javascript thru address bar or using image search etc.
Many will find this tutorial over there head and that is fine. take your time to learn the lessons in this tutorial and soon you will know some very usefull skills.
this tutorial will make use of HTML DOM
DHTML
as well as JavaScript

you can also check out this post some time ago by daononlyfreeze
<!-- m -->http://www.autohotke... ... 97&start=0<!-- m -->

I will not be giving a tutorial on these but the links included should adequetely cover these topics from a learining perspective
I also want to make it clear you will not find any nice wrapper functions. Nor did COM or am the origional conceiver of the subject matter.
What I have done is taken posts of questions and answers and tidbits from all over the forum and Created a tutorial from it.
If you want to thank someone thank the following
Chris Malet Autohotkey creator
Sean who created the COM functions
Lexikos whose in dept understanding and hand holding has given me the understanding necesary to do this
ahklerner whom Posted the first well written function to push javascritp to a webpage via ahk that I had foundFirst and foremost I am like you the benificiery of these Genious :D
Learning I beleive takes a real life example.
lets define our automation job
I like Logging into Gmail
our other progressively more robust learning will come in the version of
selecting an looking up a word on dictionary .com
recording data from a web result and reacting to those results


For the most part the COM library is based on actual C++ so i will include the relavent MSDN but will not go into to much detail as they are documented in the MSDN quite adequetly
it is not entirely necesary that you fully grasp these. I put the links here for those who want to broaden there depth of understanding. It is however necesary to have even the most highlevel understanding of there purpose
Goals
Basic understanding of COM Pointer
Understanding of COM_CreateObject MSDN
MSDN does a fine job explaining this i wont re hash it just remember creates a parent object for use with our invoke callsUnderstanding of COM_AtlAxGetControl MSDN
Understanding of COM_AtlAxCreateContainer MSDN
we will be using COM_AtlAxCreateContainer and COM_AtlAxGetControl in our examples just remember this is a way of getting a control pointer from a window control that we are in our case creatingUnderstanding of COM_Invoke MSDN
Sean gives us a Basic Example. Basically this is an execution function. if you need to get or set a value execute a method of move from a parent object to a member object you can do so from COM_Invoke Understanding of COM_Release MSDN
In the interest of trying to dumb this down here goes.
everytime you create a pointer to an object or interface you should release it for each time you create it you do not release strings just object and interface pointers. Its a way of freeing memory and its good for your program but well if you dont do it the worst that can happen on most beginner scripts is some semi slow performanceUnderstanding of COM_QueryService MSDN
In our examples we will use this function to get one object pointer from another using CLSID. there are instances when getting pwin can bypass some security zone settings which can cause scripts to fail at timesUnderstanding of COM_QueryInterface MSDN
Returns a pointer to a specified interface on an object to which a client currently holds an interface pointer.Understanding of COM_ConnectObject MSDN
Just remember this is how we can setup ahk access to events. Gonna be a much later before I cover events but be patient[/list]It is also imperitive that we have an understanding of the following

Basic Understanding of IE architecture MSDN
Basic understanding of the webrowser object for Gui MSDN MSDN
For our automation tasks we will be aquireing and interface pointer to iWebrowser2 through out my examples you will see this reflected as pwb
First I want to remind all please have COM in the standard libraries such as c:\program files\autohotkey\lib
Always initialize COM once per script
If you will not be using a GUI object
COM_Init()
With GUI
COM_AtlAxWinInit()
there is no need to do it more than once. Nor is there any need to do both when in dowbt use COM_AtlAxWinInit()
There are quite a few ways to create this interface pointer I will try cover the most common usefull ones
For our, or really any purpose we can use a GUI browser or an instance of IE
New instance of IE
pwb := COM_CreateObject("InternetExplorer.Application")
Now if you have at this point been paying attention and if you are a good student you have no doubt tried to Initialize COM and then create an instance of IE. If you havent yet do it now. .... Its ok i exxpect confusion seems like nothing happened. thats because an instance of IE is not by default visible and I strategically left something out MSDN
COM_Invoke(pwb , "Visible=", "True") ;"False" ;"True" ;
All together now
COM_Init()
pwb := COM_CreateObject("InternetExplorer.Application")
COM_Invoke(pwb , "Visible=", "True") ;"False" ;"True" ;
Dont get discouraged if you see there is no web page loaded no home page. There shouldnt be we have not triggered navigation yet we will do that next
Firstly the MSDN and then the code
url:="http://www.google.com"
COM_Invoke(pwb, "Navigate", url)
lets try this out
COM_Init()
pwb := COM_CreateObject("InternetExplorer.Application")
COM_Invoke(pwb , "Visible=", "True") ;"False" ;"True" ;
url:="http://www.google.com"
COM_Invoke(pwb, "Navigate", url)
url:="http://www.Yahoo.com"
COM_Invoke(pwb, "Navigate", url)
What is goin on here:?::evil: No its not some sort of Microsoft conspiricy to keep us from getting to Google we just didnt tell our script to wait for a page load in between navigations..... what can we do
Certainly we could
Sleep,10000 ; 10 second pause
What's this you want me to wait 10 seconds just because your crappy PC cant load a web page any faster than that.? so how do we make it so no matter how long or short we always halt the script till the exact second the page has loaded. We test the readystate property of PWB MSDN can you guess how we will retreive the readystate property..... :idea:
rdy:=COM_Invoke(pwb,"readyState")
you guessed right :D Now lets loop and test it
loop
      If (rdy:=COM_Invoke(pwb,"readyState") = 4)
         break
OK put it all together now
COM_Init()
pwb := COM_CreateObject("InternetExplorer.Application")
COM_Invoke(pwb , "Visible=", "True") ;"False" ;"True" ;
url:="http://www.google.com"
COM_Invoke(pwb, "Navigate", url)
loop
      If (rdy:=COM_Invoke(pwb,"readyState") = 4)
         break
url:="http://www.Yahoo.com"
COM_Invoke(pwb, "Navigate", url)
loop
      If (rdy:=COM_Invoke(pwb,"readyState") = 4)
         break
MsgBox, 262208, Done, Goodbye,5
COM_Invoke(pwb, "Quit")
COM_Term()
Must have slipped me a micky there did I slip some code in we hadnt discussed yet. Yes I did im not gonna explain any more simple Invoke concepts now your all grown up its time to move on. You can look up the Quit method in the MSDN pages you should already have open ill give you a hint there is a link to it in the Methods MSDNLets Focus on a GUI version of what we have done above First you guessed it we need to create a pwb.
Gui, +LastFound +Resize
;pwb := COM_AtlAxGetControl(COM_AtlAxCreateContainer(WinExist(),top,left,width,height, "Shell.Explorer") )  ;left these here just for reference of the parameters
pwb := COM_AtlAxGetControl(COM_AtlAxCreateContainer(WinExist(),0,0,510,600, "Shell.Explorer") )
and of course to be able to see it we need
gui,show, w510 h600 ,Gui Browser
Lets put this together with the navigation we had from the instance of IE dont forget we use the COM_AtlAxWinInit() to initialize com since we are using a GUI control COM_AtlAxWinInit()
COM_AtlAxWinInit()
Gui, +LastFound +Resize
;pwb := COM_AtlAxGetControl(COM_AtlAxCreateContainer(WinExist(),top,left,width,height, "Shell.Explorer") )  ;left these here just for reference of the parameters
pwb := COM_AtlAxGetControl(COM_AtlAxCreateContainer(WinExist(),0,0,510,600, "Shell.Explorer") )
gui,show, w510 h600 ,Gui Browser
;take from the IE example
url:="http://www.google.com"
COM_Invoke(pwb, "Navigate", url)
loop
      If (rdy:=COM_Invoke(pwb,"readyState") = 4)
         break
url:="http://www.Yahoo.com"
COM_Invoke(pwb, "Navigate", url)
loop
      If (rdy:=COM_Invoke(pwb,"readyState") = 4)
         break
MsgBox, 262208, Done, Goodbye,5
Gui, Destroy
COM_AtlAxWinTerm()
ExitApp
From here we see that that iWebrowser2 interface pointer is used exactly the same way once created. The only difference is the way we created it and the way we destroyed it
There are some differences in our Gui Browser
We cant do any of the follwoing
Keyboard navigation
use shortcut keys like ctrl + m to submit a form
send tab keystrokes
resize our browser with the windowFor all but the resize problem we use the following code
This will be our first exposure to the COM_QueryInterface MSDN
We use this to gain access to the IOleInPlaceActiveObject_Interface MSDN based on CLSID. which Enables a top-level container to manipulate an in-place object.(ie send keystrokes wehn normally only the gui control could receive them
;http://msdn.microsoft.com/en-us/library/microsoft.visualstudio.ole.interop.ioleinplaceactiveobject(VS.80).aspx
IOleInPlaceActiveObject_Interface:="{00000117-0000-0000-C000-000000000046}"
pipa := [color=red]COM_QueryInterface[/color](pwb, IOleInPlaceActiveObject_Interface)
OnMessage(WM_KEYDOWN:=0x0100, "WM_KEYDOWN") 
OnMessage(WM_KEYUP:=0x0101, "WM_KEYDOWN") 
WM_KEYDOWN(wParam, lParam, nMsg, hWnd) 
{ 
;  Critical 20 
;tooltip % wparam 
  If  (wParam = 0x09 || wParam = 0x0D || wParam = 0x2E || wParam = 0x26 || wParam = 0x28) ; tab enter delete up down 
  ;If  (wParam = 9 || wParam = 13 || wParam = 46 || wParam = 38 || wParam = 40) ; tab enter delete up down 
  { 
      WinGetClass, Class, ahk_id %hWnd% 
      ;tooltip % class 
      If  (Class = "Internet Explorer_Server") 
          { 
            [color=red] Global pipa [/color]
             VarSetCapacity(Msg, 28) 
             NumPut(hWnd,Msg), NumPut(nMsg,Msg,4), NumPut(wParam,Msg,8), NumPut(lParam,Msg,12) 
             NumPut(A_EventInfo,Msg,16), NumPut([color=blue]A_GuiX[/color],Msg,20), NumPut([color=blue]A_GuiY[/color],Msg,24) 
             DllCall(NumGet(NumGet(1*[color=red]pipa[/color])+20), "Uint", [color=red]pipa[/color], "Uint", &Msg) 
             Return 0 
          } 
  } 
}
and then for the sizing
GuiSize:
WinMove, % "ahk_id " . COM_AtlAxGetContainer(pwb), , 0,0, A_GuiWidth, A_GuiHeight
return
All together Now
COM_AtlAxWinInit()
Gui, +LastFound +Resize
;pwb := COM_AtlAxGetControl(COM_AtlAxCreateContainer(WinExist(),top,left,width,height, "Shell.Explorer") )  ;left these here just for reference of the parameters
pwb := COM_AtlAxGetControl(COM_AtlAxCreateContainer(WinExist(),0,0,510,600, "Shell.Explorer") )
;http://msdn.microsoft.com/en-us/library/microsoft.visualstudio.ole.interop.ioleinplaceactiveobject(VS.80).aspx
IOleInPlaceActiveObject_Interface:="{00000117-0000-0000-C000-000000000046}"
pipa := COM_QueryInterface(pwb, IOleInPlaceActiveObject_Interface)
OnMessage(WM_KEYDOWN:=0x0100, "WM_KEYDOWN") 
OnMessage(WM_KEYUP:=0x0101, "WM_KEYDOWN") 
gui,show, w510 h600 ,Gui Browser
;take from the IE example
url:="http://www.google.com"
COM_Invoke(pwb, "Navigate", url)
loop
      If (rdy:=COM_Invoke(pwb,"readyState") = 4)
         break
url:="http://www.Yahoo.com"
COM_Invoke(pwb, "Navigate", url)
loop
      If (rdy:=COM_Invoke(pwb,"readyState") = 4)
         break
return

GuiClose:
Gui, Destroy
COM_CoUninitialize()
COM_AtlAxWinTerm()
ExitApp

GuiSize:
WinMove, % "ahk_id " . COM_AtlAxGetContainer(pwb), , 0,0, A_GuiWidth, A_GuiHeight
return
WM_KEYDOWN(wParam, lParam, nMsg, hWnd) 
{ 
;  Critical 20 
;tooltip % wparam 
  If  (wParam = 0x09 || wParam = 0x0D || wParam = 0x2E || wParam = 0x26 || wParam = 0x28) ; tab enter delete up down 
  ;If  (wParam = 9 || wParam = 13 || wParam = 46 || wParam = 38 || wParam = 40) ; tab enter delete up down 
  { 
      WinGetClass, Class, ahk_id %hWnd% 
      ;tooltip % class 
      If  (Class = "Internet Explorer_Server") 
          { 
            [color=red] Global pipa [/color]
             VarSetCapacity(Msg, 28) 
             NumPut(hWnd,Msg), NumPut(nMsg,Msg,4), NumPut(wParam,Msg,8), NumPut(lParam,Msg,12) 
             NumPut(A_EventInfo,Msg,16), NumPut([color=blue]A_GuiX[/color],Msg,20), NumPut([color=blue]A_GuiY[/color],Msg,24) 
             DllCall(NumGet(NumGet(1*[color=red]pipa[/color])+20), "Uint", [color=red]pipa[/color], "Uint", &Msg) 
             Return 0 
          } 
  } 
}
Now tank thats alot more script to get the same results
Yes it is the choice of method is yours to make I am giving you tools but there are benifets to both you will have to discover these in your own time and based on projects you endeavor
We will endeavor some other GUI excersizes later for breivity im moving us back to IE
Before we go on there is one more method of getting a pwb
[/list] Re-using exisitng instances of IE
The Shell.Application has a collection of windows. Be warned this will include windows explorer and IE. But best of all each instance of IE or a tab within is a separate instance of iWebrowser2. So this approach is ideal for itenerating all of those tabs and windows
The windows collection like almost everything in Microsofts world is 0 based meaning first object is 0 second is 1 .... etc
psw := COM_Invoke(psh:=COM_CreateObject("Shell.Application"), "Windows"),
Microsoft cleverly exposes a count property we would get a total count with
COM_Invoke(psw := COM_Invoke(psh:=COM_CreateObject("Shell.Application"), "Windows"), "Count")
Then we loop thru windows we need to take into account that the first instance is 0 and a-index starts at 1
Much ias a despise using window titles to distinguish windows its still one of the best ways
pageSearched:="Google" 
Loop, %   COM_Invoke(psw := COM_Invoke(psh:=COM_CreateObject("Shell.Application"), "Windows"), "Count") 
   { 
      LocationName:=COM_Invoke(pwb:=COM_Invoke(psw, "Item", [color=red]A_Index-1[/color]), "LocationName") 
      IfInString,LocationName,%pageSearched% 
         Break 
      COM_Release(pwb) ;didnt break so release the one we didnt use 
   }
We break the loop on the first match but could instead creat an ahk array of matches and not break the loop
pageSearched:="google" 
Loop, %   COM_Invoke(psw := COM_Invoke(psh:=COM_CreateObject("Shell.Application"), "Windows"), "Count") 
   { 
      LocationName:=COM_Invoke([color=red]pwb%a_index%[/color]:=COM_Invoke(psw, "Item", A_Index-1), "LocationName") 
      IfNotInString,LocationName,%pageSearched% 
      [color=orange]COM_Release(pwb%a_index%),[/color]	[color=blue]VarSetCapacity(pwb%a_index%,	0)[/color] ;didnt break so release the one we didnt use 
   }
COM_Release(pwb%a_index%) we release the undused pointer here from memory
VarSetCapacity(pwb%a_index%, 0) here we make sure there is no value to the indexed pwb as release does not destroy the value just the memory reference
I am not going to spend alot of time on this because automating multiple instances of the same site is rare even in my world and i automate data jobs for a large corperation

Lets recap what we know how to do now
we know how to use pwb to create a pointer to iWebrowser2
Trigger Navigation
Wait for a page to load
Create a gui browser object
set it to autoresize if the gui resizes
accept keystrokes
Pushing Data to a website
By and large javascript has to be the most universally known way to get this job done bu non programmers. so if you know javascript your learning curve for AHK to push data to some site is nearly over
Remember the Navigate method for the pwb
Well in HTML it is common the set an href to something like
<a href="javascript:somejavascripthere">click here to execute some javascript</a>
back to using the Navigation method for this

The WebBrowser control or InternetExplorer object can browse to any location in the local file system, on the network, or on the World Wide Web.

In Microsoft Internet Explorer 6 or later, you can navigate through code only within the same domain as the application hosting the WebBrowser control. Otherwise, this method and Navigate2 are disabled.

In Internet Explorer 7, when you specify the navOpenInNewTab flag or the navOpenInBackgroundTab flag, do not combine them with other parameters (TargetFrameName, PostData, Headers) or with other BrowserNavConstants flags. If tabbed browsing is disabled, or if a tab cannot be created, the call will fail. If this happens, choose another navigation method, such as navOpenInNewWindow.

Note New tabs are opened asynchronously; this method returns as soon as the tab is created, which can be before navigation in the new tab has started. The IWebBrowser2 object for the destination tab is not available to the caller. Tab order is not guaranteed, especially if this method is called many times quickly in a row.
When navOpenInNewWindow or navOpenInNewTab is specified, the caller does not receive a reference to the WebBrowser object for the new window, so there is no immediate way to manipulate it.
6029565920
todd stebbing
602-840-2296
amsi

digest this and take your time what it is saying is that in the event there are frames or content with other domains content from other than the parent domain is not available
Next have a look at

navOpenInNewWindow = 0x1,
navNoHistory = 0x2,
navNoReadFromCache = 0x4,
navNoWriteToCache = 0x8,
navAllowAutosearch = 0x10,
navBrowserBar = 0x20,
navHyperlink = 0x40,
navEnforceRestricted = 0x80,
navNewWindowsManaged = 0x0100,
navUntrustedForDownload = 0x0200,
navTrustedForActiveX = 0x0400,
navOpenInNewTab = 0x0800,
navOpenInBackgroundTab = 0x1000,
navKeepWordWheelText = 0x2000,
navVirtualTab = 0x4000

We want to be sure that the browser isnt going to apply some security rules that will prevent the script from working such as Security zone local intranet not allowing active x. hav a look above and see if you can tell which flag you might use

Navigate( _
url As String, _
[Flags As Variant,] _
[TargetFrameName As Variant,] _
[PostData As Variant,] _
[Headers As Variant]

So far we only passed a url parameter
Lets do some real damage
jsAlert:="javascript:alert('js pased to navigation');"
COM_Invoke(pwb, "Navigate", jsAlert,0x0400)
COM_QueryService MSDN will now be used to get an html window object handle from the iWebrowser2 pointer pwb You will notice its used much the same way as COM_QueryInterface MSDN
jsAlert:="javascript:var x='10';"
COM_Invoke(pwb, "Navigate", jsAlert,0x0400)
IID_IHTMLWindow2   := "{332C4427-26CB-11D0-B483-00C04FD90119}" 
pwin := COM_QueryService(pacc,IID_IHTMLWindow2,IID_IHTMLWindow2) 
msgbox % COM_Invoke(pwin , "x")
As we can see here global bariables are available thru the window object
Thats all in this lesson our next lesson will tear into HTML DOM. While we can manipulate HTML DOM via javascript injects there is a nice plain COM way to do it
till next lessen go ahead an peruse below some other hints from our master of arms Sean
I'm really just putting all in one place


Try this, need the standard library COM.ahk.

sURL :=	"http://www.autohotkey.com/forum/"
COM_CoInitialize()
If Not	pweb := GetWebBrowser()
	ExitApp
COM_Invoke(pweb, "Navigate", sURL)
;COM_Invoke(pweb, "Navigate", sURL, 0x1)	; navOpenInNewWindow
/*	IE7 Only!
COM_Invoke(pweb, "Navigate", sURL, 0x800)	; navOpenInNewTab
COM_Invoke(pweb, "Navigate", sURL, 0x1000)	; navOpenInBackgroundTab
*/
COM_Release(pweb)
COM_CoUninitialize()
Return

GetWebBrowser()
{
	ControlGet, hIESvr, hWnd, , Internet Explorer_Server1, ahk_class IEFrame
	If Not	hIESvr
		Return
	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)
	IID_IWebBrowserApp := "{0002DF05-0000-0000-C000-000000000046}"
	pweb := COM_QueryService(pdoc,IID_IWebBrowserApp,IID_IWebBrowserApp)
	COM_Release(pdoc)
	Return	pweb
}

This script retrieves hWnd/URL/Title/StatusText of all running iexplore/explorer Windows, including Tabs.
The shell should be set to explorer.exe for the script to work.

NEED COM Standard Library.

COM_Init()
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

IE7 supports multi-tab windows, but the conventional WebBrowser control is lacking of a function to differentiate one among them, the HWND function in IWebBrowser2 object always returns the window handle of IEFrame, not the new window class TabWindowClass.

Here is a method to obtain the window handle of TabWindowClass from the IWebBrowser2 object pwb (:if applied to IE6 etc, I think it'll just return the window handle of IEFrame).

IETabWindow(pwb)
{
	psb  :=	COM_QueryService(pwb,IID_IShellBrowser:="{000214E2-0000-0000-C000-000000000046}")
	DllCall(NumGet(NumGet(1*psb)+12), "Uint", psb, "UintP", hwndTab)
	DllCall(NumGet(NumGet(1*psb)+ 8), "Uint", psb)
	Return	hwndTab
}


Never lose.
WIN or LEARN.

BoBo²
  • Guests
  • Last active:
  • Joined: --
:shock: :D :arrow: Thanks :!: :D
B8)B:wink: (the-greatest-tut-fan-on-planet-earth)

tank
  • Administrators
  • 4345 posts
  • AutoHotkey Foundation
  • Last active: May 02 2019 09:16 PM
  • Joined: 21 Dec 2007
So in COM for example lets make an example that opens google in a gui then searches for farts and then returns the number of results
Gui, +LastFound +Resize 
COM_AtlAxWinInit() 
;pwb := COM_AtlAxGetControl(COM_AtlAxCreateContainer(WinExist(),top,left,width,height, "Shell.Explorer") ) 
pwb := COM_AtlAxGetControl(COM_AtlAxCreateContainer(WinExist(),0,0,510,600, "Shell.Explorer") ) 
gui,show, w510 h600 ,Gui Browser
COM_Invoke(pwb, "Navigate","http://www.google.com")
load_complete(pwb)
COM_Invoke(itemq:=COM_Invoke(all1:=COM_Invoke(document:=COM_Invoke(pwb,"Document"),"All"),"Item","q"),"value","farts")
COM_Invoke(item62:=COM_Invoke(all2:=COM_Invoke(document:=COM_Invoke(pwb,"Document"),"All"),"Item",62),"click")
sleep 500
load_complete(pwb)
msgbox % results:=COM_Invoke(item79:=COM_Invoke(all3:=COM_Invoke(document,"All"),"Item",78),"innerHTML")

Return

GuiSize:
WinMove, % "ahk_id " . COM_AtlAxGetContainer(pweb), , 0,0, A_GuiWidth, A_GuiHeight
Return
GuiClose:
COM_Release(itemq),COM_Release(item62),COM_Release(item79),COM_Release(itemq),COM_Release(all1),COM_Release(all2),COM_Release(all3),COM_Release(document),COM_Release(pwb)
Gui, Destroy
COM_AtlAxWinTerm() 
ExitApp
load_complete(pwb)
{
	Loop
		if rdy:=COM_Invoke(pwb,"readyState") = 4
			Break
}
new instance of IE
COM_Init()
pwb := COM_CreateObject("InternetExplorer.Application")
COM_Invoke(pwb , "Visible=", "True") ;"False" ;"True" ;
COM_Invoke(pwb, "Navigate","http://www.google.com")
load_complete(pwb)
COM_Invoke(itemq:=COM_Invoke(all1:=COM_Invoke(document:=COM_Invoke(pwb,"Document"),"All"),"Item","q"),"value","farts")
COM_Invoke(item62:=COM_Invoke(all2:=COM_Invoke(document:=COM_Invoke(pwb,"Document"),"All"),"Item",62),"click")
sleep 500
load_complete(pwb)
msgbox % results:=COM_Invoke(item79:=COM_Invoke(all3:=COM_Invoke(document,"All"),"Item",78),"innerHTML")
COM_Release(itemq),COM_Release(item62),COM_Release(item79),COM_Release(itemq),COM_Release(all1),COM_Release(all2),COM_Release(all3),COM_Release(document),COM_Release(pwb)
COM_Term() 
ExitApp
load_complete(pwb)
{
	Loop
		if rdy:=COM_Invoke(pwb,"readyState") = 4
			Break
}
A very simple DOM Viewer using only COM and IE with JavaScript
COM_Init()
COM_Error(false)

mouseover=
(
function whichElement()
{
   tindex=event.srcElement.sourceIndex;
   tname=document.all(tindex).tagName;
   innerhtml=document.all(tindex).innerHTML;
   //window.status=event.srcElement..tagName;
   oAttrColl = event.srcElement.attributes;
   myLen=oAttrColl.length;
   xx="Dom=document.all(" + tindex + ")\n";
   xx=xx + "document.all(" + tindex + ").tagName=" + event.srcElement.tagName + "\n *** Attributes if any **** \n";
   if (event.srcElement.value != undefined)
   xx=xx + "document.all(" + tindex + ").value=" + event.srcElement.value + "\n";
   for (i = 0; i < oAttrColl.length; i++)
   {
      oAttr = oAttrColl.item(i);
      bSpecified = oAttr.specified;
      sName = oAttr.nodeName;
      vValue = oAttr.nodeValue;
      if (bSpecified)
      {
         xx=xx + sName + "=" + vValue + "\n";
      }
   }
   
}
document.body.onmouseover = whichElement;
)

Gui, Add, Button, x6 y0 w90 h20 gResume, Resume
Gui, Add, Edit, x6 y20 w590 h485 vDom,

Gui, Show, h500 w600, DOM Extractor Ctrl + / to freeze
SetTimer,dom,800
Return

GuiClose:


COM_Term()
ExitApp
Resume:
SetTimer,dom,800
Return
dom:
WinGetTitle,thispage,ahk_class IEFrame
StringReplace,thispage,thispage,% " - Microsoft Internet Explorer",,All ; ie6 postfix
StringReplace,thispage,thispage,% " - Windows Internet Explorer",,All  ; ie7 postfix
if thispage
{
   ControlGetText,URL,Edit1,% thispage . "ahk_class IEFrame"
COM_Init()
Loop, %   COM_Invoke(psw := COM_Invoke(psh:=COM_CreateObject("Shell.Application"), "Windows"), "Count")
   {
      LocationName:=COM_Invoke(pwb:=COM_Invoke(psw, "Item", A_Index-1), "LocationName")
      IfInString,LocationName,%thispage%
         Break
      COM_Release(pwb)
   }
item122:=COM_Invoke(all:=COM_Invoke(document:=COM_Invoke(pwb,"Document"),"All"),"Item",122)
pdoc:=COM_Invoke(pwb,"Document")
pwin:=COM_Invoke(pdoc,"parentWindow")
COM_Invoke(pwin, "execScript",mouseover)
tname:=COM_Invoke(pwin,"tname")
tindex:=COM_Invoke(pwin,"tindex")
myLen:=COM_Invoke(pwin,"myLen")
xx:=COM_Invoke(pwin,"xx")
framecount:=COM_Invoke(pwin,"framecount")
innerhtml:=COM_Invoke(pwin,"innerhtml")
comstring=
(
COM_Init()
COM_Error(0)
pageSearched:="%thispage%"
Loop, `%   COM_Invoke(psw := COM_Invoke(psh:=COM_CreateObject("Shell.Application"), "Windows"), "Count")
   {
      LocationName:=COM_Invoke(pwb:=COM_Invoke(psw, "Item", A_Index-1), "LocationName")
      IfInString,LocationName,`%pageSearched`%
         Break
      COM_Release(pwb)
   }
item%tindex%`:=COM_Invoke(all`:=COM_Invoke(document`:=COM_Invoke(pwb,"Document"),"All"),"Item",%tindex%)
MsgBox `% value:=COM_Invoke(item%tindex%,"value")
MsgBox `% innerHTML:=COM_Invoke(item%tindex%,"innerHTML")
COM_Release(item%tindex%),COM_Release(all),COM_Release(document),COM_Release(pwb)
COM_Term()
)
GuiControl,Text,Dom,% thispage . " `n" . URL . " `nDom accessable objects for document`.all collection `nElement type (" . tname . ")`nIndex (" . tindex . ")`n" . xx . "`nExample of how to ref in com`n****`n" . comstring . "`n******`nVisible text= " . innerhtml
COM_Release(pdoc),COM_Release(pwin),COM_Release(pwb)
comstring=
}
return
^/::
SetTimer,dom,Off
Return
Edit: this was updated to give you a larger text area and write a sample COM script for you
Never lose.
WIN or LEARN.

Masu2000
  • Guests
  • Last active:
  • Joined: --
Boredom is a sad, sad thing :roll:

tank
  • Administrators
  • 4345 posts
  • AutoHotkey Foundation
  • Last active: May 02 2019 09:16 PM
  • Joined: 21 Dec 2007
Access IE Dom
pdoc:=COM_Invoke(pwb,"Document")
http://msdn.microsoft.com/en-us/library/ms531073(VS.85).aspx
Commonly we might access the all collection
all:=COM_Invoke(document,"all")
http://msdn.microsoft.com/en-us/library/ms537434(VS.85).aspx
forms
forms:=COM_Invoke(document,"forms")
http://msdn.microsoft.com/en-us/library/ms537457(VS.85).aspx
getElementById
getElementById:=COM_Invoke(document,"getElementById")
http://msdn.microsoft.com/en-us/library/ms536437(VS.85).aspx
getElementsByName
getElementsByName:=COM_Invoke(document,"getElementsByName")
http://msdn.microsoft.com/en-us/library/ms536438(VS.85).aspx
getElementsByTagName
getElementsByTagName:=COM_Invoke(document,"getElementsByTagName")
http://msdn.microsoft.com/en-us/library/ms536439(VS.85).aspx
As with any collection item in dom we can even select items by 0 based index
item:=COM_Invoke(collection,"Item",0)
Or by name or ID
item:=COM_Invoke(collection,"Item","name_or_id")
http://msdn.microsoft.com/en-us/library/cc197011(VS.85).aspx
Once we have an item we can get or set properties For Instance set a form value
COM_Invoke(item,"value","newvalue")
Get the current value
value:=COM_Invoke(item,"value")
http://msdn.microsoft.com/en-us/library/ms535129(VS.85).aspx
or even work with the very text in a p tag
COM_Invoke(item,"innerHTML","New innerhtml text")
Or Retreive it
innerHTML:=COM_Invoke(item,"innerHTML")
http://msdn.microsoft.com/en-us/library/ms533897(VS.85).aspx
The possibilities seem endless
or methods that over write
writeln
COM_Invoke(document,"writeln","some text")
http://msdn.microsoft.com/en-us/library/ms536783(VS.85).aspx
Or ... we might need to access the window object
with a window object in adition to the many methods and properties found here i might point out that we can use execScript which allows us to inject JS or VBS
frames
frames:=COM_Invoke(document,"frames")
http://msdn.microsoft.com/en-us/library/ms537459(VS.85).aspx
of course this is a collection so use an item reference
item:=COM_Invoke(collection,"Item",0)
item:=COM_Invoke(collection,"Item","name_or_id")
parentWindow
parentWindow:=COM_Invoke(document,"parentWindow")
http://msdn.microsoft.com/en-us/library/ms534331(VS.85).aspx

<!-- m -->http://msdn.microsof.../ms535873(VS.85<!-- m -->).aspx
Now that we have a DOM Window object
COM_Invoke(windowObj,"execScript",javaScript)
http://msdn.microsoft.com/en-us/library/ms536420(VS.85).aspx
and retreive a global variable value
jsvar:=COM_Invoke(windowObj,jsvar)
Edit 8-31
another helpfull trick to getting information to quickly log into a site
For those needing to learn more about HTML DHTML
Javascript and more
<!-- m -->http://w3schools.com<!-- m -->

for ie a dom inspector
and an easier way to disect a web page
<!-- m -->http://www.microsoft... ... structions<!-- m -->

very cool and free for now
one more thing
in your address bar try going to said log in page and filling it but not clicking your button
not all forms are visible fortuantely log in screens are usually pretty straght forward
use this in the address bar

javascript:var x=document.forms.length; for (i=0;i < x;++i){document.forms(i).method='get'};void(0)
much easier way to setting all the forms on the page to use get instead
easy to get a query string now
Never lose.
WIN or LEARN.

tank
  • Administrators
  • 4345 posts
  • AutoHotkey Foundation
  • Last active: May 02 2019 09:16 PM
  • Joined: 21 Dec 2007
Silently get something off the internet
hopefully this snipet will spur some ideas
I would also point out that you can also use
<!-- m -->http://www.autohotke...pic.php?t=33561<!-- m -->
<!-- m -->http://www.autohotke...pic.php?t=33506<!-- m -->
but some may find these complex
this too could also bee seen that way but i hope not
COM_Init() 
pwb := COM_CreateObject("InternetExplorer.Application") 
;no need to make the window visible
COM_Invoke(pwb, "Navigate", "http://whatismyip.com/") ; Ill navigate like we do in the first post this time to a usefull url that displays external ip address
loop ; lets wait for the page to load
      If (rdy:=COM_Invoke(pwb,"readyState") = 4) 
         break 
innerHTML:=COM_Invoke(item37:=COM_Invoke(all:=COM_Invoke(document:=COM_Invoke(pwb,"Document"),"All"),"Item",37),"innerHTML") ; the section of the page i need is found here
/*
the above code is equive to the following DOM string
document.all(37).innerHTML
the above innerhtml is a reference to an html element and everything that exists between the opening and closing tag
for instance
<p>sometext <b>here</b></p>
<p> is an opening tag
</p> is a closing tag
innerHTML would be sometext <b>here</b>
*/
;strip out the pre-text
StringReplace,innerHTML,innerHTML,Your IP Address Is ,,all 
;strip out any html tags
innerHTML:=Strip_HTML(innerHTML)

COM_Invoke(pwb,"Quit") ; no need to release these objects since they die with the application

COM_Term() 
;display the result
msgbox % innerHTML 
ExitApp
Strip_HTML(html) ; i got this from someone a long while back. but since i didnt post in it i cant find out where if this is yours thanks feel free to take credit for this function
{
Loop Parse, html, <>
   If (A_Index & 1) 
      y = %y%%A_LoopField% 
StringReplace,y,y, /select,,All
html=%y%
return html
}

Never lose.
WIN or LEARN.

tank
  • Administrators
  • 4345 posts
  • AutoHotkey Foundation
  • Last active: May 02 2019 09:16 PM
  • Joined: 21 Dec 2007
So it gets asked alot how do i fill out some form or submit some information on the web with ahk
first it is extremly important before going further to understand DOM HTML and Javascript tho for javascript not as much
for our examples today im going to show you different ways to log into GMAIL
my examples will not work for you till you substitute for your actual information
gUser:="myName"
gPass="myPass"
which will be in each of the examples
We could log in from this page
https://www.google.com/accounts/Login?continue=http://www.google.com/&hl=en
But We AHK'ers like to automate to much
for all of our examples we will create a new IE window
COM_Init()
pwb := COM_CreateObject("InternetExplorer.Application")
COM_Invoke(pwb , "Visible=", "True") ;"False" ;"True" ;
I first need to get a query string this works in most cases
Just copy this and drop it in the address bar and hit enter and then sign in
javascript:var x=document.forms.length; for (i=0;i < x;++i){document.forms(i).method='get'};void(0)
Great googly moogly what is that
https://www.google.com/accounts/ServiceLoginAuth?ltmpl=default<mplcache=2&continue=http%3A%2F%2Fmail.google.com%2Fmail%2F%3F&service=mail&rm=false<mpl=default<mpl=default&Email=username&Passwd=pass&rmShown=1&signIn=Sign+in
Oh goodnes what is this
Its a URL and a query string
query strings can contain all of the form elements submitted when you submit
What we are looking for here is this
Email=username&Passwd=p
Lets separate this a bit and set out username and pass in a variable
gUser:="myName"
gPass:="myPass"
The URL
url:="https://www.google.com/accounts/ServiceLoginAuth"
Query String
GETdata := "?Email=" gUser "&Passwd=" gPass "<mpl=default<mplcache=2&continue=http%3A%2F%2Fmail.google.com%2Fmail%2F%3F&service=mail&rm=false<mpl=default<mpl=default&rmShown=1&signIn=Sign+in"
See how we set the user entered data from variables We are well on our way now
we can now log in the following ways
Browser non specific which will work the default browser
Run,url GETdata
Wait but tank this is a COM tutorial
Yes right you areand here we go
In this one we will submit the log information in the URL
gUser:="myName"
gPass:="myPass"
COM_Init()
pwb := COM_CreateObject("InternetExplorer.Application")
COM_Invoke(pwb , "Visible=", "True") ;"False" ;"True" ;
GETdata := "?Email=" gUser "&Passwd=" gPass "<mpl=default<mplcache=2&continue=http%3A%2F%2Fmail.google.com%2Fmail%2F%3F&service=mail&rm=false<mpl=default<mpl=default&rmShown=1&signIn=Sign+in"
url:="https://www.google.com/accounts/ServiceLoginAuth"
COM_Invoke(pwb, "Navigate", url GETdata)
COM_Release(pwb)
COM_Term()
The point is sometimes we dont need to over complicate things
Like this we could also do this in this one we will load the log in form and Submit the data as tho ghte user actually did it this technique also has the Least likely hood that it will fail due to some sort of javascript form submission built into the form
It is also the slowest way
gUser:="myName"
gPass:="myPass"
COM_Init()
pwb := COM_CreateObject("InternetExplorer.Application")
COM_Invoke(pwb , "Visible=", "True") ;"False" ;"True" ;
url:="https://www.google.com/accounts/Login?continue=http://www.google.com/&hl=en"
COM_Invoke(pwb, "Navigate", url GETdata)
loop
      If (rdy:=COM_Invoke(pwb,"readyState") = 4)
         break
; but tank how did you get the form element names
; remember the query string?
; the part before the = sign is the feild name :)
;i only care about the ones the user will interact with not the hidden ones
COM_Invoke(Email:=COM_Invoke(all:=COM_Invoke(doc:=COM_Invoke(pwb,"Document"),"All"),"Item","Email"),"value",gUser)
; Now i already declared a document and an all collection no need to repeat that process now
COM_Invoke(Passwd:=COM_Invoke(all,"Item","Passwd"),"value",gPass)
COM_Invoke(signIn:=COM_Invoke(all,"Item","signIn"),"Click")
sleep 500
loop
      If (rdy:=COM_Invoke(pwb,"readyState") = 4)
         break
COM_Invoke(pwb, "Navigate", "http://mail.google.com/")
COM_Release(signIn),COM_Release(Passwd),COM_Release(Email),COM_Release(all),COM_Release(doc),COM_Release(pwb)
COM_Term()
There are of course other ways to get form feild information such as name or ID
One is with my dom viewer that mixes COM Javascript in to AHK
COM_Init()
COM_Error(false)

mouseover=
(
function whichElement()
{
   tindex=event.srcElement.sourceIndex;
   tname=document.all(tindex).tagName;
   innerhtml=document.all(tindex).innerHTML;
   //window.status=event.srcElement..tagName;
   oAttrColl = event.srcElement.attributes;
   myLen=oAttrColl.length;
   xx="Dom=document.all(" + tindex + ")\n";
   xx=xx + "document.all(" + tindex + ").tagName=" + event.srcElement.tagName + "\n *** Attributes if any **** \n";
   if (event.srcElement.value != undefined)
   xx=xx + "document.all(" + tindex + ").value=" + event.srcElement.value + "\n";
   for (i = 0; i < oAttrColl.length; i++)
   {
      oAttr = oAttrColl.item(i);
      bSpecified = oAttr.specified;
      sName = oAttr.nodeName;
      vValue = oAttr.nodeValue;
      if (bSpecified)
      {
         xx=xx + sName + "=" + vValue + "\n";
      }
   }
   
}
document.body.onmouseover = whichElement;
)

Gui, Add, Button, x6 y0 w90 h20 gResume, Resume
Gui, Add, Edit, x6 y20 w590 h485 vDom,

Gui, Show, h500 w600, DOM Extractor Ctrl + / to freeze
SetTimer,dom,800
Return

GuiClose:


COM_Term()
ExitApp
Resume:
SetTimer,dom,800
Return
dom:
WinGetTitle,thispage,ahk_class IEFrame
StringReplace,thispage,thispage,% " - Microsoft Internet Explorer",,All ; ie6 postfix
StringReplace,thispage,thispage,% " - Windows Internet Explorer",,All  ; ie7 postfix
if thispage
{
   ControlGetText,URL,Edit1,% thispage . "ahk_class IEFrame"
COM_Init()
Loop, %   COM_Invoke(psw := COM_Invoke(psh:=COM_CreateObject("Shell.Application"), "Windows"), "Count")
   {
      LocationName:=COM_Invoke(pwb:=COM_Invoke(psw, "Item", A_Index-1), "LocationName")
      IfInString,LocationName,%thispage%
         Break
      COM_Release(pwb)
   }
item122:=COM_Invoke(all:=COM_Invoke(document:=COM_Invoke(pwb,"Document"),"All"),"Item",122)
pdoc:=COM_Invoke(pwb,"Document")
pwin:=COM_Invoke(pdoc,"parentWindow")
COM_Invoke(pwin, "execScript",mouseover)
tname:=COM_Invoke(pwin,"tname")
tindex:=COM_Invoke(pwin,"tindex")
myLen:=COM_Invoke(pwin,"myLen")
xx:=COM_Invoke(pwin,"xx")
framecount:=COM_Invoke(pwin,"framecount")
innerhtml:=COM_Invoke(pwin,"innerhtml")
comstring=
(
COM_Init()
COM_Error(0)
pageSearched:="%thispage%"
Loop, `%   COM_Invoke(psw := COM_Invoke(psh:=COM_CreateObject("Shell.Application"), "Windows"), "Count")
   {
      LocationName:=COM_Invoke(pwb:=COM_Invoke(psw, "Item", A_Index-1), "LocationName")
      IfInString,LocationName,`%pageSearched`%
         Break
      COM_Release(pwb)
   }
item%tindex%`:=COM_Invoke(all`:=COM_Invoke(document`:=COM_Invoke(pwb,"Document"),"All"),"Item",%tindex%)
MsgBox `% value:=COM_Invoke(item%tindex%,"value")
MsgBox `% innerHTML:=COM_Invoke(item%tindex%,"innerHTML")
COM_Release(item%tindex%),COM_Release(all),COM_Release(document),COM_Release(pwb)
COM_Term()
)
GuiControl,Text,Dom,% thispage . " `n" . URL . " `nDom accessable objects for document`.all collection `nElement type (" . tname . ")`nIndex (" . tindex . ")`n" . xx . "`nExample of how to ref in com`n****`n" . comstring . "`n******`nVisible text= " . innerhtml
COM_Release(pdoc),COM_Release(pwin),COM_Release(pwb)
comstring=
}
return
^/::
SetTimer,dom,Off
Return
For a IE DOM inspector
and an easier way to disect a web page
<!-- m -->http://www.microsoft... ... structions<!-- m -->
For those needing to learn more about HTML DHTML
Javascript and more
<!-- m -->http://w3schools.com<!-- m -->
Never lose.
WIN or LEARN.

tank
  • Administrators
  • 4345 posts
  • AutoHotkey Foundation
  • Last active: May 02 2019 09:16 PM
  • Joined: 21 Dec 2007
Still not documented and the part that executes inserted COM is still not enabled but otherwise this should pretty much work as intended
I will be adding some additional functionality but for now it may prove to be a good learning tool
#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
Gui, +LastFound +Resize
COM_AtlAxWinInit()
COM_Error(0)

Gui, Add, Button, x2 y2 w30 h20 gGoBack, <<
Gui, Add, Button, x32 y2 w30 h20 gGoForward, >>
Gui, Add, Button, x62 y2 w40 h20 gGoHome, Home
Gui, Add, Button, x102 y2 w50 h20 gRefresh2, Refresh
Gui, Add, Button, x152 y2 w35 h20 gStop, Stop
Gui, Add, Text, x187 y8 w70 h20 , LocationURL
Gui, Add, ComboBox, x257 y2 w340 h20 vurl, ComboBox
Gui, Add, Button, x597 y2 w30 h20 Default gGo, Go
Gui, Add, Progress, x627 y2 w73 h20 Range0-4 vLoad, 0
Gui, Add, Text, x700 y8 w70 h20 vRState, Interactive
Gui, Add, GroupBox, x0 y32 w1000 h20 , pwb
Gui, Add, Text, x0 y655 w0 h0 vStatBar, Interactive
;~ Gui, Add, Text,x840 y2 h40 w160 vTag, Info for Tag `n `ncom
Gui, Add, Edit,x0 y650 h20 w550 vCOMItems,
Gui, Add, ListView,x0 y670 r6 w300 vMyListView Sort, Atribute|Value
Gui, Add, Text,x300 y670 h20 w80 vtext1, Ctrl + / to freeze
Gui, Add, Button, x380 y670 w70 h20 gResume, Resume
Gui, Add, Button, x450 y670 w100 h20 vSource gSource, View Source
Gui, Add, Text,x300 y690 h40 w250 vInner, Mouse Over Source InnerHTML
Gui, Add, Edit,x300 y730 h70 w250 vvisText,
Gui, Add, Text,x550 y650 h40 w270 vcr, COM Reference
Gui, Add, Edit,x550 y670 h80 w270 vCOMInnerHTML,
Gui, Add, Text,x820 y650 h40 w80 vex, Execute COM
Gui, Add, Button, x900 y650 w100 h20 vexc, Execute..
Gui, Add, Edit,x820 y670 h80 w270 vexecom,
pwb := COM_AtlAxGetControl(COM_AtlAxCreateContainer(WinExist(),  0, 50, 1000, 600, "Shell.Explorer"))
; Generated using SmartGUI Creator 4.0
Gui, Show,h800 w1000,  - Powered by Tank
psink := COM_ConnectObject(pwb, "Web_")
COM_Invoke(pwb, "GoHome")
Return
GuiSize: 
if A_GuiWidth < 1000
   Gui, Show,w1000  
GuiControl, Move, COMItems,% "Y"  A_GuiHeight -  150
GuiControl, Move, MyListView,% "Y"  A_GuiHeight -  130
GuiControl, Move, text1,% "Y"  A_GuiHeight -  130
GuiControl, Move, Resume,% "Y"  A_GuiHeight -  130
GuiControl, Move, Source,% "Y"  A_GuiHeight -  130
GuiControl, Move, Inner,% "Y"  A_GuiHeight -  110
GuiControl, Move, visText,% "Y"  A_GuiHeight -  70
GuiControl, Move, cr,% "Y"  A_GuiHeight -  150
GuiControl, Move, COMInnerHTML,% "Y"  A_GuiHeight -  130
GuiControl, Move, ex,% "Y"  A_GuiHeight -  150
GuiControl, Move, exc,% "Y"  A_GuiHeight -  150
GuiControl, Move, execom,% "Y"  A_GuiHeight -  130
WinMove, % "ahk_id " . COM_AtlAxGetContainer(pwb), , 0,50, A_GuiWidth < 1000 ? "1000" : A_GuiWidth, A_GuiHeight - 200 
;~ GuiControl, Move, Inner,% "Y"  A_GuiHeight -  110
;~ GuiControl, Move, COMItems,% "Y"  A_GuiHeight -  150
Return 

Source:
pdoc:=COM_Invoke(pwb,"Document") 
CGID_MSHTML(pdoc, 2139)
COM_Release(pdoc)
Return
Resume:
pdoc:=COM_Invoke(pwb, "Document")
pwin:=COM_Invoke(pdoc, "parentWindow")
COM_Invoke(pwin, "execScript",mouseover)
SetTimer,statbar,1500
Return
^/::
SetTimer,statbar,Off
COM_Release(pwin)
COM_Release(pdoc)
Return
statbar:
Gui,Submit,NoHide
LV_Delete()
ThisLen:=COM_Invoke(pwin,"ThisLen")
GuiControl,text,StatBar,% ThisLen ;"'" COM_Invoke(pwin, "tindex")
GuiControl,text,Inner,% " Mouse Over Source InnerHTML `nDocument.All(" tindex ").innerHTML" ;"'" COM_Invoke(pwin, "tindex")
GuiControl,text,COMItems,% "Item" tindex ":=COM_Invoke(all:=COM_Invoke(pdoc:=COM_Invoke(pwb,""Document""),""All""),""Item""," tindex ")"
GuiControl,text,COMInnerHTML,% "pdoc:=COM_Invoke(pwb,""Document"") `n"
. "all:=COM_Invoke(pdoc,""All"") `n"
. "Item" tindex ":=COM_Invoke(all,""Item""," tindex ") `n"
. "InnerHTML:=COM_Invoke(Item" tindex ",""InnerHTML"")"
tname:=COM_Invoke(pwin,"tname")
tindex:=COM_Invoke(pwin,"tindex")
xx:=COM_Invoke(pwin,"xx")
framecount:=COM_Invoke(pwin,"framecount")
thistype:=COM_Invoke(pwin,"thistype")
innerhtml:=COM_Invoke(pwin,"innerhtml")
thisval:=COM_Invoke(pwin,"thisval")
sname:=COM_Invoke(pwin,"sName")
StringSplit,snames,sname,`|
vValue:=COM_Invoke(pwin,"vValue")
StringSplit,vValues,vValue,`|
;~ GuiControl,text,Tag,% "Info for Tag " COM_Invoke(pwin,"tname") " `nDocument.All(" tindex ") `ncom "
GuiControl,text,visText,% innerhtml
loop % ThisLen
LV_Add("",snames%a_index%, vValues%a_index%)
if thisval
LV_Add("","Value", thisval) 
;~ if thistype
;~ LV_Add("","type", thistype)
Return
Go:
Gui,Submit,NoHide
COM_Invoke(pwb, "Navigate", url)
Return
GoHome:
Gui,Submit,NoHide
COM_Invoke(pwb, "GoHome")
Return
GoBack:
Gui,Submit,NoHide
COM_Invoke(pwb, "GoBack")
Return
GoForward:
Gui,Submit,NoHide
COM_Invoke(pwb, "GoForward")
Return
Stop:
Gui,Submit,NoHide
COM_Invoke(pwb, "Stop")
Return
Refresh2:
Gui,Submit,NoHide
COM_Invoke(pwb, "Refresh2")
Return
GuiClose:
Gui, Destroy
      COM_CoUninitialize()
      COM_AtlAxWinTerm()
      ExitApp

ExitApp
;~ ProgressChange
Strip_HTML(html) ; i got this from someone a long while back. but since i didnt post in it i cant find out where if this is yours thanks feel free to take credit for this function
{
Loop Parse, html, <>
   If (A_Index & 1)
      y = %y%%A_LoopField%
StringReplace,y,y, /select,,All
html=%y%
return html
}
Web_ProgressChange(prms, this)
{
   Global
     r:=COM_Invoke(pwb,"readyState")
      GuiControl,text,url,% COM_Invoke(pwb, "LocationUrl")
     Gui, Show,,% COM_Invoke(pwb, "LocationName") " - Powered by Tank"
;~       READYSTATE_UNINITIALIZED = 0
;~     READYSTATE_LOADING = 1
;~     READYSTATE_LOADED = 2
;~     READYSTATE_INTERACTIVE = 3
;~     READYSTATE_COMPLETE = 4

     GuiControl,text,RState,% r = 0 ? "UNINITIALIZED " : r = 1 ? "LOADING" : r = 2 ? "LOADED" : r = 3 ? "INTERACTIVE" : "COMPLETE"
     if r =  4
     {
;~       
      mouseover=
      (
      function whichElement()
      {
         tindex=event.srcElement.sourceIndex;
         tname=document.all(tindex).tagName;
         innerhtml=document.all(tindex).innerHTML;
         thistype=document.all(tindex).type;
         //window.status=event.srcElement..tagName;
         oAttrColl = event.srcElement.attributes;
         myLen=oAttrColl.length;
         xx="Dom=document.all(" + tindex + ")\n";
         xx=xx + "document.all(" + tindex + ").tagName=" + event.srcElement.tagName + "\n *** Attributes if any **** \n";
         thisval=event.srcElement.value
         if (event.srcElement.value != undefined)
         xx=xx + "document.all(" + tindex + ").value=" + event.srcElement.value + "\n";
         ThisLen = 0;
         sName = "";
         vValue = "";
         for (i = 0; i < oAttrColl.length; i++)
         {
           oAttr = oAttrColl.item(i);
           bSpecified = oAttr.specified;
           if (bSpecified)
           {
             ThisLen=ThisLen + 1
              sName = sName + oAttr.nodeName + "|";
              vValue = vValue +  oAttr.nodeValue + "|";
           }
         }
      }
      document.body.onmouseover = whichElement;
      document.body.onchange = whichElement;
      )
      pdoc:=COM_Invoke(pwb, "Document")
      pwin:=COM_Invoke(pdoc, "parentWindow")
      COM_Invoke(pwin, "execScript",mouseover)
;~       COM_Invoke(pwin, "execScript","alert('hi')")
      GuiControl,,Load,0
      SetTimer,statbar,1500
     }
     Else
     {
      GuiControl,,Load,% r
      if pwin is integer
      {
         SetTimer,statbar,off
         COM_Release(pwin)
         COM_Release(pdoc)
         pdoc=
         pwin=
      }
     }

}
CGID_MSHTML(pobj, nCmd, nOpt = 0) 
{ 
   pct := COM_QueryInterface(pobj,IID_IOleCommandTarget:="{B722BCCB-4E68-101B-A2BC-00AA00404770}") 
   Return  DllCall(NumGet(NumGet(1*pct)+16), "Uint", pct, "Uint", COM_GUID4String(CGID_MSHTML,"{DE4BA900-59CA-11CF-9592-444553540000}"), "Uint", nCmd, "Uint", nOpt, "Uint", 0, "Uint", 0), COM_Release(pct) 
}

Never lose.
WIN or LEARN.

tank
  • Administrators
  • 4345 posts
  • AutoHotkey Foundation
  • Last active: May 02 2019 09:16 PM
  • Joined: 21 Dec 2007
Best Newb Learning Path
Read this
Com
Automate IE7 with Tabs
COM IE Tutorial
Embed an Internet Explorer control in your AHK Gui via COM (thanks Sean :D )

[SOLVED]Insert JS into IE browser not owned by AHK using COM (special thanks to ahklerner here as this thread started me on my quest to understand these things :D :D )

UrlDownloadToVar (thanks olfen :D )

COM alternative UrlDownloadToVar (thanks ... you guessed it Sean again :D )


[function] httpQuery GET and POST requests - update 0.3.4(thanks DerRaphael :D )

[StdLib] WININET Functions & UrlGetContents(thanks ahklerner :D )

working with DOM from a var no browser (thanks Lexikos :D :D )

even more advanced

MD5, SHA1, CRC32 of the File(thanks ... you guessed it Sean again :D )


DDE Server (for single-instance file association) [std-lib] (thanks to Lexikos and Sean and all other contributors on this post :D )


[url=http://www.autohotkey.com/forum/viewtopic.php?t=21910&highlight=]AHK DDE FUNCTIONS. (Including a/sync,batch,multi-channel) (thanks to Joy2DWorld :D )
Never lose.
WIN or LEARN.

tank
  • Administrators
  • 4345 posts
  • AutoHotkey Foundation
  • Last active: May 02 2019 09:16 PM
  • Joined: 21 Dec 2007
reserved
Never lose.
WIN or LEARN.

  • Guests
  • Last active:
  • Joined: --
Hey, how to close/delete it?
Like I make my Browser, and I want only close website, not AHK.

  • Guests
  • Last active:
  • Joined: --

Hey, how to close/delete it?
Like I make my Browser, and I want only close website, not AHK.


Solved.

How to get site source or the site where u are?

tank
  • Administrators
  • 4345 posts
  • AutoHotkey Foundation
  • Last active: May 02 2019 09:16 PM
  • Joined: 21 Dec 2007
share your answer i was posting details when you posted solved
Never lose.
WIN or LEARN.

tank
  • Administrators
  • 4345 posts
  • AutoHotkey Foundation
  • Last active: May 02 2019 09:16 PM
  • Joined: 21 Dec 2007
COM_Invoke(pwb, "Quit")
Closes the Tab/Window referenced by pwb.
as far as view source I can only answer that right now in IE6 ill beg you to wait as im seeking some aid converting some code from another language to COM.ahk
EDIT: thanks Sean
VIEW PAGE Source
pdoc:=COM_Invoke(pwb,"Document")
CGID_MSHTML(pdoc, 2139) ; this is the ocmmand that does it
CGID_MSHTML(pobj, nCmd, nOpt = 0)
{
;http://source.winehq.org/source/dlls/mshtml/resource.h?v=wine-0.9.2#L83
   pct := COM_QueryInterface(pobj,IID_IOleCommandTarget:="{B722BCCB-4E68-101B-A2BC-00AA00404770}")
   Return  DllCall(NumGet(NumGet(1*pct)+16), "Uint", pct, "Uint", COM_GUID4String(CGID_MSHTML,"{DE4BA900-59CA-11CF-9592-444553540000}"), "Uint", nCmd, "Uint", nOpt, "Uint", 0, "Uint", 0), COM_Release(pct)
}
this is the rewrite of the CGID_MSHTML function from Sean and can be executed on pdoc now
Never lose.
WIN or LEARN.

fongmark
  • Guests
  • Last active:
  • Joined: --
I put together a little web browser which can be controlled by autohotkey, using various postings by 'tank', Sean, Nicolas Bourbaki and several others.

I had two reasons for writing this:
1. scripts recorded by the script recorder that comes with autohotkey cannot tell when a page is busy - and usually fails when the page title does not change.
2. autohotkey running on other browsers cannot scan for text on the page.

I use this autohotkey browser to do regression testing on my web pages. It is a work in progress as I can't get it to realiably read text on a page as yet.

Several include files are needed and can be found on google:
iecontrol.ahk
cohelper.ahk
anchor.ahk
control_anigif.ahk
anigif.dll
systemcursorchange3.ahk (included below)
; Fong
; Change mouse cursor to resize cursor


CursorChange(ToResize)
{
	static normal_cursor
	OCR_NORMAL := 32512
	OCR_SIZEWE := 32644
	
	if (ToResize)
	{
		; Make a copy of the original mouse cursor
		normal_cursor := DllCall( "LoadCursor", "uint", 0, "uint", OCR_NORMAL )
		normal_cursor := DllCall( "CopyImage", "uint", normal_cursor, "uint", 2, "int", 0, "int", 0, "uint", 0 )

		; Make a copy of the resize cursor
		resize_cursor := DllCall( "LoadCursor", "uint", 0, "uint", OCR_SIZEWE )
		resize_cursor := DllCall( "CopyImage", "uint", resize_cursor, "uint", 2, "int", 0, "int", 0, "uint", 0 )

		; Set Normal cursor to the resize image
		;msgbox, Changing to RESIZE
		result := DllCall( "SetSystemCursor", "uint", resize_cursor, "uint", OCR_NORMAL )
	} else 
	{
		; Restore the original cursor
		;msgbox, Changing to NORMAL
		result := DllCall( "SetSystemCursor", "uint", normal_cursor, "uint", OCR_NORMAL )
	}
	
	Return
}

These two can be found at http://picasaweb.goo...gmark/Mypublic#
Google displays them way bigger than they actually are when saved:
bar.gif
Cdrom_spins_2B.gif

To use this browser, start it up, run the autohotkey recorder and navigate your web pages. Save your recording, then use this script to modify it - it puts in checks to make sure the web page is not busy. Then include your recording in the browser script at F12:: label.
/* FixRecording.ahk
   By Mark Fong
   Meant to be used for fixing a recording on my
   internet explorer emulator (found in D:\hotkey\IE).
   The raw recording does not wait for IE to be ready
   before sending the next mouse clicks.
*/

Gui, Add, Edit, x-2 y-4 w370 h270 vMyEdit, Drop .ahk file here
Gui, Add, Button, x366 y26 w70 h30 , Save
Gui, Add, Button, x366 y76 w70 h30 , Exit
; Generated using SmartGUI Creator 4.0
Gui, Show, x131 y91 h265 w443, Fix AHK Recordings
Return


; Get the file name that was dragged onto this window.
GuiDropFiles:
  Loop, parse, A_GuiEvent, `n
  {
     FirstFile = %A_LoopField%
     Break
  }
  ; MsgBox, The file name is %FirstFile%
  Gosub, MakeChanges
Return


MakeChanges:
  ; Read the file off the disk into my editor.
  FileRead, FileContents, %FirstFile%
  GuiControl,, MyEdit, %FileContents%
  
  ; Make my changes.
  NewStr := RegExReplace(FileContents, "MouseClick.*", "$0`r`nLoop {`r`n  Sleep, 250`r`n  if IE_Busy(pwb) = 0`r`n    Break`r`n}") 
  GuiControl,, MyEdit, %NewStr%
Return

ButtonSave:
  FileDelete, %FirstFile%
  FileAppend, %NewStr%, %FirstFile%
  GoSub, GuiClose
Return

ButtonExit:
GuiClose:
ExitApp


Here is the browser code:
/* Add sliding bar to expand URL text box.
   Add menu item to View Source code of html.
*/

#Include IEControl.ahk			; internet explorer control
#SingleInstance force
#Include Anchor.ahk				; for autoresize of controls
#include Control_AniGif.ahk		; display animated .gif files
;#include URLtoVariable2.ahk	; for reading the web page contents
;#include GetWebPageContents.ahk
  
GoSub, GuiStart

Gui, +LastFound +Resize

Menu, FileMenu, Add, &View Source, MenuViewSource  
Menu, FileMenu, Add, E&xit, GuiClose
Menu, HelpMenu, Add, &About, MenuHandler
Menu, MyMenuBar, Add, &File, :FileMenu  ; Attach the two sub-menus that were created above.
Menu, MyMenuBar, Add, &Help, :HelpMenu
Gui, Menu, MyMenuBar

; Add the busy icon.
;------------------------------------------------
guiID := WinExist()
hAniGif1 := AniGif_CreateControl(guiID, 3, 1, 19, 20)
If hAniGif1 is not integer
	MsgBox %hAniGif1%
;------------------------------------------------

  ; Add URL address text box
  Gui, 1:Add, Edit, R1 vMyURL gUserURL xp+14
  GuiControl, 1:Move, MyURL, w400	; make it wide

  ; Set the FONT size for the URL box.
  Gui, 1:Font, s9 cRed Bold, Verdana  ; If desired, set a new default font for the window.
  GuiControl, 1:Font, MyURL  ; Put the above font into effect for a control.

  ; Set the color of the text 'bar'
  ; Gui, Color, , Green
  ; Add a bar to allow slide expand of URL box.
  Gui, Add, Picture, xp+405 yp w5 h20 gBarClick, Bar.GIF	; Receives the control name Static1

  Gui, 1:Add, Button, xp+11 yp h22, Go
  


; Create a TextBox to hold the IE control.
Gui, Add, Text, vMyIE r80 xm HwndmyhWnd
GuiControl, Move, MyIE, w480 h400	; make it wide


Gui, Show, AutoSize, WebBrowser

hWnd := myhWnd	; handle of the textbox that holds the IE control.

CLSID_WebBrowser := "{8856F961-340A-11D0-A96B-00C04FD705A2}"
IID_IWebBrowser2 := "{D30C1661-CDAF-11D0-8A3E-00C04FC9E26E}"
pwb := CreateObject(CLSID_WebBrowser, IID_IWebBrowser2)

; This is for capturing and sending Enter, Delete, Tab to IE control.
PIPAVAR := "{00000117-0000-0000-C000-000000000046}"
pipa := QueryInterface(pwb, PIPAVAR)

AtlAxAttachControl(pwb, hWnd)		; attach web browser control to textbox control

IE_LoadURL(pwb, "www.google.com")

Sleep 2000
;Gui, Maximize


;GoSub, OSDStart

; For the title
prevtitle := ""
prevbusy := 0
SetTimer, UpdateTitle, 300




;SetTimer, UpdateOSD, Off	; Turn off the OSD updates. This allows popup windows like Search to have focus.
;Gui, 2:Destroy			; Remove the OSD

  
  ; Change the mouse cursor when it moves over the bar.gif
  BarActive := false
  initpos := 0
  BarPos := 0
  #Include SystemCursorChange3.ahk
  SetTimer, WatchCursor, 100
Return


; Change the mouse pointer to Resize when over the Bar (next to Go button).
WatchCursor:
	MouseGetPos, mouseX, mouseY, id, controlBar
	/*
	WinGetTitle, title, ahk_id %id%
	WinGetClass, class, ahk_id %id%
	ToolTip, ahk_id %id%`nahk_class %class%`n%title%`nControl: %controlBar%
	*/
	if (controlBar == "Static1" and BarActive == false)
	{
		;MsgBox, Mouse is over BAR
		BarActive := true
		CursorChange(BarActive)
	} else if (controlBar <> "Static1" and BarActive)
	{
		; Restore the regular mouse cursor
		BarActive := false
		CursorChange(BarActive)
	}
Return

BarClick:
   ;MsgBox, The BAR was clicked
   if (BarActive)
   {
		Loop
		{
			GetKeyState, LButtonState, LButton, P
			if LButtonState = D		; While Left mouse button is Down, drag Bar.
			{
				GuiControl, MoveDraw, Static1, % "x" mouseX-6		; % move the Bar
				GuiControl, MoveDraw, Button1, % "x" mouseX-6+11	; % move the GO button
				GuiControl, Move, MyURL, % "w" mouseX-35	; % change the width of URL text box 
				Sleep, 100
			} else 
				break
		}
   }
Return

; ------------------------------
; This section puts the IE Busy state on the screen.
OSDStart:
  ; Example: On-screen display (OSD) via transparent window:

  CustomColor = EEAA99  ; Can be any RGB color (it will be made transparent below).
  ;Gui 2:+LastFound +AlwaysOnTop -Caption +ToolWindow  ; +ToolWindow avoids a taskbar button and an alt-tab menu item.
  Gui, 2:+owner1  ; Make #2 window owned by script's main window to prevent display of a taskbar button.
  ;Gui 2:+LastFound  -Caption +ToolWindow  ; +ToolWindow avoids a taskbar button and an alt-tab menu item.
  

  ; Add URL address text box
  Gui, 2:Add, Edit, R1 vMyURL gUserURL section
  GuiControl, 2:Move, MyURL, w400	; make it wide

  ; Set the FONT size for the URL box.
  Gui, 2:Font, s9 cRed Bold, Verdana  ; If desired, set a new default font for the window.
  GuiControl, 2:Font, MyURL  ; Put the above font into effect for a control.

  ; Gui, 2:Add, Button, ys, Go	;doesn't work with making the edit wide above.
  Gui, 2:Add, Button, x420 ys, Go
  
  Gui, 2:Color, %CustomColor%
  Gui, 2:Font, s32  ; Set a large font size (32-point).
  
  ; Gui, 2:Add, Text, vMyText cLime, XXXXX YYYYY  ; XX & YY serve to auto-size the window.
  ; Make all pixels of this color transparent and make the text itself translucent (150):
  WinSet, TransColor, %CustomColor% 150
  
  ;SetTimer, UpdateOSD, 1000		
  ;Gosub, UpdateOSD  ; Make the first update immediate rather than waiting for the timer.

  Gui, 2:Show, x80 y23 Autosize NoActivate  ; NoActivate avoids deactivating the currently active window.
Return

UpdateOSD:
  ; Interesting note these mouse coords are relative to the IE Gui 1: window. (which is good).
  ;MouseGetPos, MouseX, MouseY
  ;GuiControl, 2:, MyText, X%MouseX%, Y%MouseY%

  ; Show IE status
  ;/*
  ;   READYSTATE_UNINITIALIZED = 0      ; Default initialization state.
  ;   READYSTATE_LOADING       = 1      ; Object is currently loading its properties.
  ;   READYSTATE_LOADED        = 2      ; Object has been initialized.
  ;   READYSTATE_INTERACTIVE   = 3      ; Object is interactive, but not all of its data is available.
  ;   READYSTATE_COMPLETE      = 4      ; Object has received all of its data.
  ;*/
  ;readystate := IE_ReadyState(pwb)

  readystate := IE_Busy(pwb)
  GuiControl, 2:, MyText, IE Busy = %readystate%
Return



; Change the Title of the web browser window, so that recorder will key off of it.
; Only want to execute the Show when the title changes, to minimize impact of side effects documented below.
UpdateTitle:
  mytitle := IE_GetTitle(pwb)
  if(prevtitle <> mytitle)
  {
    Gui, 1:Show,,%mytitle%		;Keeps window on TOP (if the title changes).

    prevtitle := mytitle

    ; Update the URL box.
    curURL := IE_GetUrl(pwb)
    ;GuiControl, 2:, MyURL, %curURL%
	GuiControl, , MyURL, %curURL%
  }
  
  ; Display the Busy icon
  busystate := IE_Busy(pwb)
  if(prevbusy <> busystate)
  {
	  if(busystate == true)
	  {
	    ; http://picasaweb.google.com/fongmark/Mypublic#
		AniGif_LoadGifFromFile(hAniGif1, "Cdrom_spins_2B.gif")
	  } else 
	  {
		AniGif_UnloadGif(hAniGif1)
		;Sleep 2000
		/* Page has finished loading */

		;;Gosub, GetWebPageContents
		;;webpagecontents1 := GetWebPageContents()
		sUrl := IE_GetUrl(pwb)
		;msgbox, New URL = %sUrl%
		UrlDownloadToFile, %sUrl%, myTemp1.txt
		;UrlDownloadToFile, %curUrl%, myTemp1.txt

		/* Now the temp file contains the web content that is currently on the screen.
		 Read it into a variable.
		*/
		FileRead, webpagecontents, myTemp1.txt
		;msgbox, web5 = %webpagecontents%

		;Needle := "Password:</TH>"
		;Needle = Password:</TH>
		;Needle = Password:
		Needle = Password
		;IfInString, webpagecontents, %Needle%
		;pos := InStr(webpagecontents, %Needle%)
		pos := InStr(webpagecontents, "Password:</TH>") 		; this does not work
		;if (InStr(webpagecontents, %Needle%))
		if (pos > 0)
		{
			MsgBox, Password box found.
		}
	  }
	  prevbusy := busystate
  }
Return



UserURL:
  ; User or program has changed the URL
  ; MsgBox URL has changed.
  ; MyURLt := MyURL
Return



ButtonGO:
  ; GO button was pressed, get the URL from the Edit box.
  GuiControlGet, MyURLt, 1:, MyURL
  IE_LoadURL(pwb, MyURLt)
Return


MenuViewSource:
	IE_ViewSource(pwb)
Return

MenuHandler:
Return


; By Nicolas Bourbaki
; Send Tab, Enter, Delete keys to Internet Explorer control.
WM_KEYDOWN(wParam, lParam, nMsg, hWnd)
{
  ;  Critical 20
  If  (wParam = 0x09 || wParam = 0x0D || wParam = 0x2E || wParam = 0x26 || wParam = 0x28) ; tab enter delete up down
  {
      WinGetClass, Class, ahk_id %hWnd%
	  ;msgbox, % Class
      If  (Class == "Internet Explorer_Server")
	  {
		 Global pipa
		 VarSetCapacity(Msg, 28)
		 NumPut(hWnd,Msg), NumPut(nMsg,Msg,4), NumPut(wParam,Msg,8), NumPut(lParam,Msg,12)
		 NumPut(A_EventInfo,Msg,16), NumPut(A_GuiX,Msg,20), NumPut(A_GuiY,Msg,24)
		 DllCall(NumGet(NumGet(1*pipa)+20), "Uint", pipa, "Uint", &Msg)
		 Return 0
	  } else if (Class == "Edit")
	  {
		Gosub, ButtonGO		; Enter key in URL box should click the GO button.
	  }
  }
} 


F12::
; #include mytest1.ahk
Return

GuiSize:
  Anchor("MyIE", "wh")		; This makes the IE window resize to the Main window size
Return


GuiStart:
  OnMessage(WM_KEYDOWN:=0x0100, "WM_KEYDOWN")
  OnMessage(WM_KEYUP:=0x0101, "WM_KEYDOWN")

  AtlAxWinInit()
  CoInitialize()
Return

GuiClose:
  Gui, 1:Destroy
  Release(pwb)
  CoUninitialize()
  AtlAxWinTerm()
ExitApp 

[/code]