AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

COM_ConnectObject and Windows Server 2008 problem

 
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
paulwarr



Joined: 21 Sep 2006
Posts: 32

PostPosted: Fri Oct 09, 2009 5:56 pm    Post subject: COM_ConnectObject and Windows Server 2008 problem Reply with quote

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.
Back to top
View user's profile Send private message
tank



Joined: 21 Dec 2007
Posts: 3700
Location: Louisville KY USA

PostPosted: Fri Oct 09, 2009 6:18 pm    Post subject: Reply with quote

WOW long time no see welcome back


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

We are troubled on every side‚ yet not distressed; we are perplexed‚
but not in despair; Persecuted‚ but not forsaken; cast down‚ but not destroyed;
Back to top
View user's profile Send private message
Sean



Joined: 12 Feb 2007
Posts: 2462

PostPosted: Sat Oct 10, 2009 5:09 am    Post subject: Reply with quote

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)
Back to top
View user's profile Send private message
paulwarr



Joined: 21 Sep 2006
Posts: 32

PostPosted: Sun Oct 11, 2009 7:04 pm    Post subject: Reply with quote

@Tank - thanks! Very Happy

@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). Sad

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 or Very Mad
Back to top
View user's profile Send private message
Sean



Joined: 12 Feb 2007
Posts: 2462

PostPosted: Mon Oct 12, 2009 12:36 am    Post subject: Reply with quote

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?
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group