Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate

How to load a page into existing IE window?


  • Please log in to reply
11 replies to this topic
  • Guests
  • Last active:
  • Joined: --
How to load a page into an laready existing IE window?

engunneer
  • Moderators
  • 9162 posts
  • Last active: Sep 12 2014 10:36 PM
  • Joined: 30 Aug 2005
that is an IE preference - Tools - Internet options - Advanced - Reuse Windows for launching shortcuts.

Alternately, Activate the window, Send !d, send the new address, send {enter}

  • Guests
  • Last active:
  • Joined: --
Thanks :)

The first method don't work for me, but the second one I am sure will work. I thought I would have to use that COM IEControl.ahk stuff for it. But I didn't understand how it worked, if I want to control an IE instance.

trik
  • Members
  • 1317 posts
  • Last active: Jun 11 2010 11:48 PM
  • Joined: 15 Jul 2007
Isn't there a run command for this? Something like:

Run, Internet Explorer, URL
:?: :?:

  • Guests
  • Last active:
  • Joined: --

Isn't there a run command for this? Something like:

Run, Internet Explorer, URL
:?: :?:


I didn't try it yet, but from the command line iexplore.exe url opens a new window always, and I am trying to write to the good old window.

engunneer
  • Moderators
  • 9162 posts
  • Last active: Sep 12 2014 10:36 PM
  • Joined: 30 Aug 2005
with the first method i gave, don't run iexplore.exe url, just run the URL directly.

  • Guests
  • Last active:
  • Joined: --
Only problem with
end !d
Send file:///t:/tmp/preview.htm
Send {Enter}

is that it is writting the address very slow, it looks animated.

engunneer
  • Moderators
  • 9162 posts
  • Last active: Sep 12 2014 10:36 PM
  • Joined: 30 Aug 2005
try a different sendmode, change SetKeyDelay, or put the address on the clipboard and paste it.

trik
  • Members
  • 1317 posts
  • Last active: Jun 11 2010 11:48 PM
  • Joined: 15 Jul 2007
Sendmode, Input?

  • Guests
  • Last active:
  • Joined: --
hi

Only clipboard did the trick :)

I guess I will have to save it and restore it too, forgot to do it...

Sean
  • Members
  • 2462 posts
  • Last active: Feb 07 2012 04:00 AM
  • Joined: 12 Feb 2007
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
}


  • Guests
  • Last active:
  • Joined: --
Thanks Sean, that works :)

I wrapped it like so

LoadURL( sURL, WinTitle )
{
COM_CoInitialize() 
If Not   pweb := GetWebBrowser(WinTitle) 
   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( WinTitle ) 
{ 
   ControlGet, hIESvr, hWnd, , Internet Explorer_Server1, %WinTitle% 
   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 
}