AutoHotkey Community

It is currently May 27th, 2012, 12:08 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: October 9th, 2009, 6:56 pm 
Offline

Joined: September 21st, 2006, 10:04 pm
Posts: 32
The following code just updates (to COM.ahk) Sean's (http://www.autohotkey.com/forum/topic20979.html) second example of attaching an event sink to a COM object:

Code:
#SingleInstance force
COM_Error(1)
; navTrustedForActiveX   =   0x0400
; (added per Tank's iWeb.ahk in some tests)

GoSub, GuiStart

Gui, +LastFound
Gui, Show, w800 h600 Center, WebBrowser
hGui := WinExist()

pwb1 := COM_AtlAxGetControl(COM_AtlAxCreateContainer(hGui,  10, 10, 380, 580, "Shell.Explorer"))
pwb2 := COM_AtlAxGetControl(COM_AtlAxCreateContainer(hGui, 410, 10, 380, 580, "Shell.Explorer"))

psink := COM_ConnectObject(pwb1, "Web_", "DWebBrowserEvents2")
MsgBox, psink is %psink%

COM_Invoke(pwb1, "Navigate", "http://www.autohotkey.com/")
; COM_Invoke(pwb1, "Navigate", "C:\Test.html", navTrustedForActiveX, "_self")
Sleep 5000
COM_Invoke(pwb1, "Navigate", "http://www.autohotkey.com/forum/")
; COM_Invoke(pwb1, "Navigate", "C:\Test2.html", navTrustedForActiveX, "_self")
Sleep 5000
COM_Invoke(pwb1, "GoBack")
Sleep 3000
COM_Invoke(pwb1, "GoForward")
Sleep 3000
Return

GuiStart:
COM_CoInitialize()
COM_AtlAxWinInit()
Return
GuiClose:
Gui, Destroy
COM_Release(psink)
COM_Release(pwb1)
COM_Release(pwb2)
COM_AtlAxWinTerm()
COM_Couninitialize()
ExitApp

Web_NavigateComplete2(prms, this)
{
   MsgBox, Got to Web_NavigateComplete2
}

Web_BeforeNavigate2(prms, this)
{
   Global   pwb2
   MsgBox, Got to Web_BeforeNavigate2
   COM_Invoke(pwb2, "Navigate", COM_DispGetParam(prms,1))
}


(I've added message boxes to indicate the event sink's creation pointer value, and to indicate whether the COM object DWebBrowserEvents2 events are successfully trapped.)

This code works with IE6, IE7 and IE8 on base (default) installations of Windows XP, XP Service Pack 1, and Vista.

But not on Windows Server 2008! Although psink seems to have been successfully assigned a pointer and pwb1 navigates, neither Web_NavigateComplete2 nor Web_BeforeNavigate2 are ever triggered; hence, the GUI window for pwb2 remains blank.

And this maddening behavior continues whether "Enhanced Security Configuration" is turned on or off, whether accessing local drive files or "Trusted Site" files, whether ActiveX is turned on or off in the security zone, or anything else that I've tried.

Have any of you had experiences similar to this, with Server 2008 or any other OS or with manipulating the webbrowser or IE, where COM_ConnectObject returns a valid value, but the connected object's events are not trapped? Any advice on what to do next would be greatly appreciated.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 9th, 2009, 7:18 pm 
Offline
User avatar

Joined: December 21st, 2007, 3:14 pm
Posts: 3826
Location: Louisville KY USA
WOW long time no see welcome back


I have never experienced this but do not have access to 2008 server

_________________
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: October 10th, 2009, 6:09 am 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
Have you tried it in other Server OS, e.g., Windows 2003? I'm not sure if it's an issue with Server OS, but looks like the events were never fired. You may try the following instead to see if works.
Code:
COM_ConnectObject(pwb1, "Web_")
; or
COM_ConnectObject(pwb1, "Web_", IID_DWebBrowserEvents2:="{34A715A0-6587-11D0-924A-0020AFC7AC4D}")

Or, although it should be irrelevant with WebBrowser control, you may add the following before ConnectObject.
Code:
COM_Invoke(pwb1, "Visible", True)
COM_Invoke(pwb2, "Visible", True)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 11th, 2009, 8:04 pm 
Offline

Joined: September 21st, 2006, 10:04 pm
Posts: 32
@Tank - thanks! :D

@Sean - thanks for the advice. I can confirm that this problem also exists with Windows Server 2003. I also tried all of your suggestions above - first separately, then together, with no result.

I also had the same results when attempting to use Lexikos's ShowHTMLDialog (http://www.autohotkey.com/forum/viewtopic.php?t=24429) to display the results from his DispatchObj function (see http://www.autohotkey.com/forum/topic27405.html). :(

I'm starting to think that IE security "hardening" is the problem (standard behavior on Windows Server 2003 and 2008). So perhaps AHK apps that attempt to hook to MSHTML object/subobject events first will have to implement a "custom security manager" (per http://msdn.microsoft.com/en-us/library/ms537182%28VS.85%29.aspx) before they'll run (if at all) on "hardened" IE platforms? :evil:


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 12th, 2009, 1:36 am 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
paulwarr wrote:
I'm starting to think that IE security "hardening" is the problem (standard behavior on Windows Server 2003 and 2008).
I don't know what else than Enhanced Security Configuration are applied to IE in Windows Server, I only had experience of Windows 2003 for about a month, long time ago. So I'd like to ask: have you tested it too after disabling/uninstalling Enhanced Security Configuration in Windows 2003?


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: BrandonHotkey, Google Feedfetcher, Leef_me, Pulover, rjgatito, XstatyK, Yahoo [Bot] and 13 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