The following mixes your code with some previous COMate code and runs fine here with both the webgadget and an IE instance.
I think this confirms that it is indeed an 'access denied' problem that you are experiencing for some reason.
Code: Select all
;/////////////////////////////////////////////////////////////////////////////////
;***COMate*** COM automation through iDispatch.
;*===========
;*
;*Execute JavaScript in WebGadget demo by Timo Harter (Freak), Ricardo and Stephen Rodriguez.
;/////////////////////////////////////////////////////////////////////////////////
IncludePath "..\"
XIncludeFile "COMate.pbi"
Enumeration
#FormWeb
#WebGadget
#IEExplorer
EndEnumeration
Define.COMateObject WebObject
Global WebObjectWait.COMateObject
Global HTTPObject.COMateObject
Procedure.i ExecuteJavaScript(Command$)
Protected DocumentDispatch.COMateObject, Script.COMateObject
Protected Result
If HTTPObject
DocumentDispatch = HTTPObject\GetObjectProperty("Document")
If DocumentDispatch
Script = DocumentDispatch\GetObjectProperty("script")
If Script
Result = Script\Invoke("eval('" + command$ + "')")
Script\release()
EndIf
DocumentDispatch\Release()
EndIf
EndIf
ProcedureReturn Result
EndProcedure
Procedure LoopWait()
WebObjectWait = COMate_WrapCOMObject(GetWindowLong_(GadgetID(#WebGadget), #GWL_USERDATA))
Status = - 1
If WebObjectWait
While Status
While WindowEvent():Delay(1):Wend
Status = WebObjectWait\GetIntegerProperty("Busy")
Wend
WebObjectWait\Release()
EndIf
EndProcedure
Procedure OuvreClientWeb(Url.s, Client = #IEExplorer)
If Client = #WebGadget
If IsGadget(Client)
HTTPObject = COMate_WrapCOMObject(GetWindowLong_(GadgetID(Client), #GWL_USERDATA))
SetGadgetText(Client, Url)
LoopWait()
EndIf
ElseIf #IEExplorer
HTTPObject = COMate_CreateObject("InternetExplorer.Application")
If HTTPObject
HTTPObject\SetProperty("Visible= #True")
HTTPObject\invoke("Navigate('" + Url + "')")
While Status$ <> "Done"
Status$ = HTTPObject\GetStringProperty("StatusText")
Delay(10)
Wend
Delay(1000)
EndIf
EndIf
EndProcedure
OpenWindow(#FormWeb, 0, 0, 800, 600, "", #PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget|#PB_Window_SizeGadget|#PB_Window_ScreenCentered)
WebGadget(#WebGadget, 10, 10, WindowWidth(#FormWeb) - 20, WindowHeight(#FormWeb) - 60, "")
; First method with webgadget
;OuvreClientWeb("http://www.purebasic.fr/english/posting.php?mode=reply&t=33983", #WebGadget)
;xMessage$ = "Hello from PB :)"
;ExecuteJavaScript("document.all.message.value=" + Chr(34) + xMessage$ + Chr(34))
;ExecuteJavaScript("document.all.preview.click()")
; Second method with IE client
OuvreClientWeb("http://www.purebasic.fr/english/posting.php?mode=reply&t=33983", #IEExplorer)
xMessage$ = "Hello from PB :)"
ExecuteJavaScript("document.all.message.value=" + Chr(34) + xMessage$ + Chr(34))
ExecuteJavaScript("document.all.preview.click()")
Repeat
Evenement = WaitWindowEvent()
Until Evenement = #PB_Event_CloseWindow
HTTPObject\Release()
End