New Edge WebGadget and old IE Functions

Just starting out? Need help? Post your questions and find answers here.
dige
Addict
Addict
Posts: 1417
Joined: Wed Apr 30, 2003 8:15 am
Location: Germany
Contact:

New Edge WebGadget and old IE Functions

Post by dige »

Hi guys, I am very happy about the new web gadget! :D

I need help now, to restore the previous features.
How to realise the following with the new gadget?

Suppress Javascript messages:

Code: Select all

myBrowser.IWebBrowser2 = GetWindowLong_(GadgetID(#Gadget_Web), #GWL_USERDATA) 
myBrowser\put_Silent(#True) 
Get SnapShot from Browser:

Code: Select all

Procedure.l GetImageFromBrowser (*m_pWebBrowser.IWebBrowser2, Width, Height)
  
  Define.RECT rcBounds, merke
  Define.IViewObject2 pViewObject
  ;{ Gerendertes Bild aus Browser holen
  ; hr = m_pWebBrowser->QueryInterface(IID_IViewObject2, (void**)&pViewObject);
  hr = *m_pWebBrowser\QueryInterface(?IID_IViewObject2, @pViewObject)
  If hr = #S_OK
    If pViewObject
      
      Define.l hdcMain
      
      hdcMain = GetDC_(0)
      If hdcMain
        
        Define.l HdcMem
        
        HdcMem = CreateCompatibleDC_(hdcMain)
        If HdcMem
          
          Define.l hBitmap
          
          hBitmap = CreateCompatibleBitmap_(hdcMain, Width, Height)
          If hBitmap
            
            Define.l oldImage
            
            oldImage = SelectObject_(HdcMem, hBitmap)
            
            rcBounds\top = 0
            rcBounds\left = 0
            rcBounds\right = Width
            rcBounds\bottom = Height
            
            pViewObject\Draw(#DVASPECT_CONTENT, -1, 0, 0, hdcMain, HdcMem, rcBounds, 0, 0, 0)
            
            Define.l Image
            
            Image = CreateImage(#PB_Any, Width, Height)
            If Image
              Define.l img_hDC
              img_hDC = StartDrawing(ImageOutput(Image))
                If img_hDC
                  BitBlt_(img_hDC, 0, 0, Width, Height, HdcMem, 0, 0, #SRCCOPY)
                StopDrawing()
              EndIf
            EndIf ; Image
            SelectObject_(HdcMem, oldImage)
            
          EndIf ; hBitmap
          DeleteDC_(HdcMem) ; DeleteDC_() bei CreateCompatibleDC_()
        EndIf ; hdcMem
        ReleaseDC_(0, hdcMain) ; ReleaseDC_() bei GetDC_()
      EndIf ; hdcMain
      
      pViewObject\Release()
    EndIf ; pViewObject
  EndIf; HR
  ;}
  
  ProcedureReturn Image
EndProcedure
Hope, its still possible :-)
"Daddy, I'll run faster, then it is not so far..."
Fred
Administrator
Administrator
Posts: 18351
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: New Edge WebGadget and old IE Functions

Post by Fred »

I will add a way to get back the ICoreWebView2 interface so you could act on it easily.
dige
Addict
Addict
Posts: 1417
Joined: Wed Apr 30, 2003 8:15 am
Location: Germany
Contact:

Re: New Edge WebGadget and old IE Functions

Post by dige »

That sounds great. Thank you very much Fred!
"Daddy, I'll run faster, then it is not so far..."
dige
Addict
Addict
Posts: 1417
Joined: Wed Apr 30, 2003 8:15 am
Location: Germany
Contact:

Re: New Edge WebGadget and old IE Functions

Post by dige »

For planning my next project: @Fred: are you still planning this for version 6.10 or possibly later?
Many thanks for your feedback.

Kind regards

Dige
"Daddy, I'll run faster, then it is not so far..."
dige
Addict
Addict
Posts: 1417
Joined: Wed Apr 30, 2003 8:15 am
Location: Germany
Contact:

Re: New Edge WebGadget and old IE Functions

Post by dige »

Fred has posted an example of the new access options for the Edge WebGadget(). This seems to be a completely different way and is not compatible with the previous one.

Does anyone have any idea how to use it to put_silent (suppress javascript errors) or take a web page snapshot?

Code: Select all

OpenWindow(0, 100, 100, 400, 400, "Hello", #PB_Window_SystemMenu)

WebViewGadget(0, 0, 0, 400, 400, #PB_WebView_Debug)

; Get the ICoreController interface 
;
Controller.ICoreWebView2Controller = GetGadgetAttribute(0, #PB_WebView_ICoreController)

; Get the ICoreWebView2 interface 
;
Controller\get_CoreWebView2(@Core.ICoreWebView2)
Core\Navigate("https://www.purebasic.com")

DataSection
	IID_ICoreWebView2Controller2:
	Data.l $C979903E
	Data.w $D4CA, $4228
	Data.b $92, $EB, $47, $EE, $3F, $A9, $6E, $AB
EndDataSection

If Controller\QueryInterface(?IID_ICoreWebView2Controller2, @Controller2.ICoreWebView2Controller2) = #S_OK
  Debug "ICoreWebView2Controller2 found: " + Controller2
  
Else
  Debug "Can't query ICoreWebView2Controller2"
EndIf

Repeat 
  Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
"Daddy, I'll run faster, then it is not so far..."
infratec
Always Here
Always Here
Posts: 7662
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: New Edge WebGadget and old IE Functions

Post by infratec »

I'm not sure ,,,

Code: Select all

Prototype wv2_EventHandler_Invoke(this.i, sender.i, args.i)
Prototype wv2_EventHandler_Finalize(this.i)

;-
;- WV2_EVENT_HANDLER_CLASS
Structure WV2_EVENT_HANDLER_CLASS
	*parent.WV2_EVENT_HANDLER_CLASS
	finalize.wv2_EventHandler_Finalize
EndStructure

;- WV2_EVENT_HANDLER
Structure WV2_EVENT_HANDLER
	vt.i
	*class.WV2_EVENT_HANDLER_CLASS
	refCount.l
	mutex.i
	context.i
	invokeHandler.wv2_EventHandler_Invoke
EndStructure


Structure IUnknownVtbl
	QueryInterface.i
	AddRef.i
	Release.i
EndStructure


Structure WV2_EVENT_HANDLER_VTBL Extends IUnknownVtbl
	Invoke.i
	GetContext.i
	SetContext.i
	LockMutex.i
	UnlockMutex.i
EndStructure

Structure WV2_EVENT_HANDLER_WAITABLE_CLASS Extends WV2_EVENT_HANDLER_CLASS
EndStructure

Structure WV2_EVENT_HANDLER_WAITABLE Extends WV2_EVENT_HANDLER
	_event.i	;api event
	args.i 
EndStructure


DataSection
	IID_IUnknown:
	Data.l $00000000
	Data.w $0000, $0000
	Data.b $C0, $00, $00, $00, $00, $00, $00, $46
EndDataSection






Procedure wv2_EventHandler_AddRef(*this.WV2_EVENT_HANDLER)
	*this\refCount = *this\refCount + 1
EndProcedure

Procedure wv2_EventHandler_Release(*this.WV2_EVENT_HANDLER)
	*this\refCount = *this\refCount - 1

	If *this\refCount = 0
		*this\class\finalize(*this)
	EndIf 
	
	ProcedureReturn *this\refCount
EndProcedure

Procedure wv2_EventHandler_Invoke(*this.WV2_EVENT_HANDLER, sender.i, args.i)
	If *this\invokeHandler : *this\invokeHandler(*this, sender, args) : EndIf 
EndProcedure

Procedure wv2_EventHandler_GetContext(*this.WV2_EVENT_HANDLER)
	ProcedureReturn *this\context
EndProcedure

Procedure wv2_EventHandler_SetContext(*this.WV2_EVENT_HANDLER, context.i)
	*this\context = context
EndProcedure

Procedure wv2_EventHandler_LockMutex(*this.WV2_EVENT_HANDLER)
	LockMutex(*this\mutex)
EndProcedure

Procedure wv2_EventHandler_UnlockMutex(*this.WV2_EVENT_HANDLER)
	UnlockMutex(*this\mutex)
EndProcedure


Procedure  wv2_EventHandler_Finalize(*this.WV2_EVENT_HANDLER)
	FreeMutex(*this\mutex)
	FreeMemory(*this)
EndProcedure



Procedure wv2_EventHandler_Class()
	Static.WV2_EVENT_HANDLER_CLASS *class
	
	If *class = #Null
		*class = AllocateMemory(SizeOf(WV2_EVENT_HANDLER_CLASS))
		*class\parent = #Null
		*class\finalize = @wv2_EventHandler_Finalize()
	EndIf
	
	ProcedureReturn *class
EndProcedure


Procedure wv2_EventHandlerWaitable_Finalize(*this.WV2_EVENT_HANDLER_WAITABLE)
	CloseHandle_(*this\_event)
	
	If *this\class\parent
		*this\class\parent\finalize(*this)
	EndIf 
EndProcedure



Procedure wv2_EventHandlerWaitable_Class()
	Static.WV2_EVENT_HANDLER_WAITABLE_CLASS *class
	
	If *class = #Null
		*class = AllocateMemory(SizeOf(WV2_EVENT_HANDLER_WAITABLE_CLASS))
		*class\parent = wv2_EventHandler_Class()
		*class\finalize = @wv2_EventHandlerWaitable_Finalize()
	EndIf
	
	ProcedureReturn *class
EndProcedure




Procedure wv2_EventHandler_QueryInterface(*this.WV2_EVENT_HANDLER, *iid.IID, *obj.INTEGER)
	If CompareMemory(*iid, ?IID_IUnknown, SizeOf(IID))
		*obj\i = *this
		wv2_EventHandler_AddRef(*this)
		
		ProcedureReturn #S_OK
		
	Else
		*obj\i = #Null
		ProcedureReturn #E_NOINTERFACE
	EndIf 
EndProcedure



Procedure wv2_EventHandler_VTable()
	Static.WV2_EVENT_HANDLER_VTBL *vt
	
	If *vt = #Null
		*vt = AllocateMemory(SizeOf(WV2_EVENT_HANDLER_VTBL))
		*vt\QueryInterface = @wv2_EventHandler_QueryInterface()
		*vt\AddRef = @wv2_EventHandler_AddRef()
		*vt\Release = @wv2_EventHandler_Release()
		*vt\Invoke = @wv2_EventHandler_Invoke()
		*vt\GetContext = @wv2_EventHandler_GetContext()
		*vt\SetContext = @wv2_EventHandler_SetContext()
		*vt\LockMutex = @wv2_EventHandler_LockMutex()
		*vt\UnlockMutex = @wv2_EventHandler_UnlockMutex()
	EndIf
	
	ProcedureReturn *vt
EndProcedure


Procedure wv2_EventHandler_Init(*this.WV2_EVENT_HANDLER, invokeHandler.wv2_EventHandler_Invoke, context.i)
	*this\invokeHandler = invokeHandler
	*this\context = context
	
	*this\mutex = CreateMutex()
	*this\refCount = 1
EndProcedure



Procedure wv2_EventHandler_New(invokeHandler.wv2_EventHandler_Invoke, context.i)
	Protected.WV2_EVENT_HANDLER *this
	
	*this = AllocateMemory(SizeOf(WV2_EVENT_HANDLER))
	*this\vt = wv2_EventHandler_VTable()
	*this\class = wv2_EventHandler_Class()

	wv2_EventHandler_Init(*this, invokeHandler, context)
		
	ProcedureReturn *this
EndProcedure



Procedure ScriptDialogOpening(sender, args)
  Debug 1
EndProcedure

Define *eventScriptDialogOpening.WV2_EVENT_HANDLER


OpenWindow(0, 100, 100, 400, 400, "Hello", #PB_Window_SystemMenu)

WebViewGadget(0, 0, 0, 400, 400, #PB_WebView_Debug)

; Get the ICoreController interface 
;
Controller.ICoreWebView2Controller = GetGadgetAttribute(0, #PB_WebView_ICoreController)

; Get the ICoreWebView2 interface 
;
Controller\get_CoreWebView2(@Core.ICoreWebView2)
Core\Navigate("https://www.purebasic.com")


*eventScriptDialogOpening = wv2_EventHandler_New(@ScriptDialogOpening(), #Null)

Core\add_ScriptDialogOpening(*eventScriptDialogOpening, #Null)

Repeat
  Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
dige
Addict
Addict
Posts: 1417
Joined: Wed Apr 30, 2003 8:15 am
Location: Germany
Contact:

Re: New Edge WebGadget and old IE Functions

Post by dige »

Thx Infratec. Unfortunately, this is too much for my grey brain cell. How can I use it to create a browser screenshot of a entire page?
"Daddy, I'll run faster, then it is not so far..."
User avatar
Caronte3D
Addict
Addict
Posts: 1371
Joined: Fri Jan 22, 2016 5:33 pm
Location: Some Universe

Re: New Edge WebGadget and old IE Functions

Post by Caronte3D »

Hi, I use this Procedure to capture the gadget (ie: WebGadget) but only captures the visible rectangle, not the whole page if it doesn't fit.

I don't know where the snippet comes from (I think RASHAD):

Code: Select all

#imageCapture = 100

Prototype.i PrintWindow(hWnd, hdcBlt, nFlags)
Global PrintWindow.PrintWindow


Procedure Gadget2Image(hWnd)
  Protected r.RECT
  
  #PW_RENDERFULLCONTENT = $00000002
  
  If OpenLibrary(User32, "User32.dll")
    PrintWindow = GetFunction(User32, "PrintWindow")
    
    If GetWindowRect_(hWnd, r.RECT)
      If CreateImage(#imageCapture, r\right-r\left, r\bottom-r\top, 32,#Black)
        hdc = StartDrawing(ImageOutput(#imageCapture))
        
        ; PW_RENDERFULLCONTENT -> new in Windows 8.1, can capture DirectX screens through DWM
        
        Okay = PrintWindow(hWnd, hdc, #PW_RENDERFULLCONTENT)
        StopDrawing()
        
        CloseLibrary(User32)
        
        If Okay
          ProcedureReturn #True
        Else
          ProcedureReturn #False
        EndIf
        
      EndIf
    EndIf
    CloseLibrary(User32)
    ProcedureReturn #False
  EndIf
  ProcedureReturn #False
  
EndProcedure

dige
Addict
Addict
Posts: 1417
Joined: Wed Apr 30, 2003 8:15 am
Location: Germany
Contact:

Re: New Edge WebGadget and old IE Functions

Post by dige »

Thanks Caronte3D, but with the old iE WebGadget you could get the rendered image via.

Code: Select all

hr = *m_pWebBrowser\QueryInterface(?IID_IViewObject2, @pViewObject)
So you had the complete website as one image. I need help now with the adaptation for the new edge WebGadget.
"Daddy, I'll run faster, then it is not so far..."
breeze4me
Enthusiast
Enthusiast
Posts: 633
Joined: Thu Mar 09, 2006 9:24 am
Location: S. Kor

Re: New Edge WebGadget and old IE Functions

Post by breeze4me »

dige wrote: Mon Feb 12, 2024 8:55 am ... take a web page snapshot?
It seems to work almost as well.
However, on some sites, certain elements don't seem to be captured properly.

Tested on Windows 10 Home 22H2 build 19045.4170 x64.

Edit:
Improved code.
https://www.purebasic.fr/english/viewtopic.php?t=83833

Code: Select all

EnableExplicit

UsePNGImageDecoder()


DataSection
  IID_IUnknown:
  Data.l $00000000
  Data.w $0000, $0000
  Data.b $C0, $00, $00, $00, $00, $00, $00, $46
EndDataSection

Structure STRUC_IUnknownBase
  *pVtbl
  lRefCount.l
  hEvent.i
EndStructure

Structure STRUC_ICoreWebView2CallDevToolsProtocolMethodCompletedHandlerVtbl Extends STRUC_IUnknownBase
  *pQueryInterface
  *pAddRef
  *pRelease
  *pInvoke
EndStructure

Structure STRUC_ICoreWebView2ExecuteScriptCompletedHandlerVtbl Extends STRUC_IUnknownBase
  *pValue.Integer
  
  *pQueryInterface
  *pAddRef
  *pRelease
  *pInvoke
EndStructure

Procedure.l CoreWebView2CompletedHandler_QueryInterface(*this.STRUC_IUnknownBase, *riid.IID, *ppvObject.Integer)
  If *ppvObject And *riid
    If CompareMemory(*riid, ?IID_IUnknown, SizeOf(IID))
      *this\lRefCount + 1
      *ppvObject\i = *this
      
    Else
      *ppvObject\i = 0
      ProcedureReturn #E_NOINTERFACE
    EndIf
  Else
    ProcedureReturn #E_POINTER
  EndIf
  
  ProcedureReturn #S_OK
EndProcedure

Procedure.l CoreWebView2CompletedHandler_AddRef(*this.STRUC_IUnknownBase)
  *this\lRefCount + 1
  ProcedureReturn *this\lRefCount
EndProcedure

Procedure.l CoreWebView2CallDevToolsProtocolMethodCompletedHandler_Release(*this.STRUC_IUnknownBase)
  *this\lRefCount - 1
  If *this\lRefCount <= 0
    FreeMemory(*this)
    ProcedureReturn 0
  EndIf
  ProcedureReturn *this\lRefCount
EndProcedure

Procedure.l CoreWebView2CallDevToolsProtocolMethodCompletedHandler_Invoke(*this.STRUC_IUnknownBase, errorCode.l, *returnObjectAsJson)
  Protected sJSON.s, iJSON, sImgData.s, iImgDataStrLen, *buffer, iDecodedBytes
  
  If *returnObjectAsJson
    If errorCode = #S_OK
      sJson = PeekS(*returnObjectAsJson)
      If sJSON
        iJSON = ParseJSON(#PB_Any, sJSON)
        If iJSON
          sImgData = GetJSONString(GetJSONMember(JSONValue(iJSON), "data"))
          If sImgData
            iImgDataStrLen = Len(sImgData)
            If iImgDataStrLen > 0
              *buffer = AllocateMemory(iImgDataStrLen * 2)
              If *buffer
                iDecodedBytes = Base64Decoder(sImgData, *buffer, MemorySize(*buffer))
                If iDecodedBytes > 0
                  If CatchImage(#PB_Any, *buffer, iDecodedBytes)
                    
                    ShowLibraryViewer("image")
                    
                    SetEvent_(*this\hEvent)
                    
                  EndIf
                EndIf
                FreeMemory(*buffer)
              EndIf
            EndIf
          EndIf
          
          FreeJSON(iJSON)
        EndIf
      EndIf
    EndIf
  EndIf
  
  ProcedureReturn #S_OK
EndProcedure


Procedure.l CoreWebView2ExecuteScriptCompletedHandler_Release(*this.STRUC_IUnknownBase)
  *this\lRefCount - 1
  ProcedureReturn *this\lRefCount
EndProcedure

Procedure.l CoreWebView2ExecuteScriptCompletedHandler_Invoke(*this.STRUC_ICoreWebView2ExecuteScriptCompletedHandlerVtbl, errorCode.l, *returnObjectAsJson)
  If *returnObjectAsJson
    If errorCode = #S_OK
      ;Debug Val(PeekS(*returnObjectAsJson))
      If *this\pValue
        *this\pValue\i = Val(PeekS(*returnObjectAsJson))
      EndIf
      SetEvent_(*this\hEvent)
    EndIf
  EndIf
  
  ProcedureReturn #S_OK
EndProcedure




Procedure CaptureEdgeWeb(WebGadget)
  Protected Result
  Protected Controller.ICoreWebView2Controller, Core.ICoreWebView2
  Protected *CoreWebView2CallDevToolsProtocolMethodCompletedHandler.STRUC_ICoreWebView2CallDevToolsProtocolMethodCompletedHandlerVtbl
  Protected *CoreWebView2ExecuteScriptCompletedHandler.STRUC_ICoreWebView2ExecuteScriptCompletedHandlerVtbl
  Protected hEvent, iValue, w, h, sParam.s
  
  If GadgetType(WebGadget) <> #PB_GadgetType_Web : ProcedureReturn 0 : EndIf
  
  Controller = GetGadgetAttribute(WebGadget, #PB_WebView_ICoreController)
  If Controller = 0 : Goto Proc_Exit : EndIf
  
  If Controller\get_CoreWebView2(@Core) <> #S_OK Or Core = 0 : Goto Proc_Exit : EndIf
  
  *CoreWebView2ExecuteScriptCompletedHandler = AllocateMemory(SizeOf(STRUC_ICoreWebView2ExecuteScriptCompletedHandlerVtbl))
  If *CoreWebView2ExecuteScriptCompletedHandler = 0 : Goto Proc_Exit : EndIf
  
  hEvent = CreateEvent_(0, 0, 0, 0)
  If hEvent = 0 : Goto Proc_Exit : EndIf
  
  With *CoreWebView2ExecuteScriptCompletedHandler
    \pVtbl = *CoreWebView2ExecuteScriptCompletedHandler + OffsetOf(STRUC_ICoreWebView2ExecuteScriptCompletedHandlerVtbl\pQueryInterface)
    \pQueryInterface = @CoreWebView2CompletedHandler_QueryInterface()
    \pAddRef = @CoreWebView2CompletedHandler_AddRef()
    \pRelease = @CoreWebView2ExecuteScriptCompletedHandler_Release()
    \pInvoke = @CoreWebView2ExecuteScriptCompletedHandler_Invoke()
    
    \pValue = @iValue
    \hEvent = hEvent
  EndWith
  
  If Core\ExecuteScript("document.body.scrollWidth", *CoreWebView2ExecuteScriptCompletedHandler) = #S_OK
    
    While WaitForSingleObject_(hEvent, 0) <> #WAIT_OBJECT_0
      While WindowEvent() : Wend
    Wend
    
    w = iValue
  EndIf
  
  If Core\ExecuteScript("document.body.scrollHeight", *CoreWebView2ExecuteScriptCompletedHandler) = #S_OK
    
    While WaitForSingleObject_(hEvent, 0) <> #WAIT_OBJECT_0
      While WindowEvent() : Wend
    Wend
    
    h = iValue
  EndIf
  
  FreeMemory(*CoreWebView2ExecuteScriptCompletedHandler)
  *CoreWebView2ExecuteScriptCompletedHandler = 0
  
  If w <= 0 Or h <= 0 : Goto Proc_Exit : EndIf
  
  *CoreWebView2CallDevToolsProtocolMethodCompletedHandler = AllocateMemory(SizeOf(STRUC_ICoreWebView2CallDevToolsProtocolMethodCompletedHandlerVtbl))
  If *CoreWebView2CallDevToolsProtocolMethodCompletedHandler = 0 : Goto Proc_Exit : EndIf
  
  With *CoreWebView2CallDevToolsProtocolMethodCompletedHandler
    \pVtbl = *CoreWebView2CallDevToolsProtocolMethodCompletedHandler + OffsetOf(STRUC_ICoreWebView2CallDevToolsProtocolMethodCompletedHandlerVtbl\pQueryInterface)
    \pQueryInterface = @CoreWebView2CompletedHandler_QueryInterface()
    \pAddRef = @CoreWebView2CompletedHandler_AddRef()
    \pRelease = @CoreWebView2CallDevToolsProtocolMethodCompletedHandler_Release()
    \pInvoke = @CoreWebView2CallDevToolsProtocolMethodCompletedHandler_Invoke()
    
    \hEvent = hEvent
  EndWith
  
  ; https://chromedevtools.github.io/devtools-protocol/tot/Page/#method-captureScreenshot
  
  sParam = ~"{ \"format\" : \"png\", \"quality\" : 100, \"clip\" : { \"x\" : 0, \"y\" : 0, \"width\" : " + w + ~", \"height\" : " + h + ~", \"scale\" : 1 }, \"fromSurface\" : true, \"captureBeyondViewport\" : true, \"optimizeForSpeed\" : false }"
  
  ;If Core\CallDevToolsProtocolMethod("Page.captureScreenshot", "{}", *CoreWebView2CallDevToolsProtocolMethodCompletedHandler) = #S_OK
  If Core\CallDevToolsProtocolMethod("Page.captureScreenshot", sParam, *CoreWebView2CallDevToolsProtocolMethodCompletedHandler) = #S_OK
    
    While WaitForSingleObject_(hEvent, 0) <> #WAIT_OBJECT_0
      While WindowEvent() : Wend
    Wend
    
    Result = 1
    *CoreWebView2CallDevToolsProtocolMethodCompletedHandler = 0
  EndIf
  
  Core\Release()
  
  Proc_Exit:
  If hEvent : CloseHandle_(hEvent) : EndIf
  If *CoreWebView2ExecuteScriptCompletedHandler : FreeMemory(*CoreWebView2ExecuteScriptCompletedHandler) : EndIf
  If *CoreWebView2CallDevToolsProtocolMethodCompletedHandler : FreeMemory(*CoreWebView2CallDevToolsProtocolMethodCompletedHandler) : EndIf
  
  ProcedureReturn Result
EndProcedure


Define e

OpenWindow(0, 0, 0, 1000, 700, "", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)

ButtonGadget(0, 20, 4, 80, 24, "Capture")
WebGadget(1, 0, 30, 1000, 660, "https://www.purebasic.com", #PB_Web_Edge)

Repeat
  e = WaitWindowEvent()
  
  If e = #PB_Event_Gadget And EventGadget() = 0
    CaptureEdgeWeb(1)
  EndIf
  
Until e = #PB_Event_CloseWindow
Post Reply