 |
Moderator |
 |
Joined: Thu Dec 31, 2009 11:05 pm Posts: 1113 Location: Gernsbach (Germany)
|
Hello If you want to use the WebGadget, you always have the problem under Windows that Internet Explorer 7 is used by default. With Internet Explorer 7 you cannot display many websites without Javascript errors. Also HTML5 and CSS3 are not supported. It is always necessary to make a setting in the registry for your own program. Under Linux you don't have the problem because the WebKit engine is used there. If you also want to use the WebKit engine under Windows, you can use my library and display any modern website without errors. Functions: - WebGadgetEx()
- Syntax:
Code: Result = WebGadgetEx(ID, X, Y, Width, Height, URL$, ParentWindowID, @ErrorOutput$) - Description: Creates a WebGadget with the WebKit engine.
- Parameter:
- ID: A unique number for the gadget. #PB_Any can be used to generate the number automatically.
- X: Defines the position.
- Y: Defines the position.
- Width: Sets the width.
- Height: Sets the height.
- URL$: The address of the website you want to open.
- ParentWindowID: Specifies the target window in which the gadget will be created.
- @ErrorOutput$: If an error occurs, the error message is saved in the string variable.
- Return value:
- 1: The process was successful. If #PB_Any is used, the ID is returned.
- Example :
Code: ;Version: 1.1.0.0
EnableExplicit
Global PBEx_WebGadget
#PBEx_WebGadgetEx_Version$ = "1.1.0.0" #PB_Web_Zoom = 100
CompilerIf #PB_Compiler_Processor = #PB_Processor_x86 PBEx_WebGadget = OpenLibrary(#PB_Any, "PB.Ex_WebGadget_x86.dll") CompilerElseIf #PB_Compiler_Processor = #PB_Processor_x64 PBEx_WebGadget = OpenLibrary(#PB_Any, "PB.Ex_WebGadget_x64.dll") CompilerEndIf
If PBEx_WebGadget Prototype WebGadgetEx(ID, X, Y, Width, Height, URL.p-Unicode, ParentWindowID, ErrorOutput) Global WebGadgetEx.WebGadgetEx = GetFunction(PBEx_WebGadget, "WebGadgetEx") Prototype SetWebGadgetExText(ID, URL.p-Unicode, ErrorOutput) Global SetWebGadgetExText.SetWebGadgetExText = GetFunction(PBEx_WebGadget, "SetWebGadgetExText") Prototype GetWebGadgetExText(ID, Output, ErrorOutput) Global GetWebGadgetExText.GetWebGadgetExText = GetFunction(PBEx_WebGadget, "GetWebGadgetExText") Prototype SetWebGadgetExState(ID, State, ErrorOutput) Global SetWebGadgetExState.SetWebGadgetExState = GetFunction(PBEx_WebGadget, "SetWebGadgetExState") Prototype SetWebGadgetExItemText(ID, Entry, Text.p-Unicode, ErrorOutput) Global SetWebGadgetExItemText.SetWebGadgetExItemText = GetFunction(PBEx_WebGadget, "SetWebGadgetExItemText") Prototype GetWebGadgetExItemText(ID, Entry, Output, ErrorOutput) Global GetWebGadgetExItemText.GetWebGadgetExItemText = GetFunction(PBEx_WebGadget, "GetWebGadgetExItemText") Prototype FreeWebGadgetEx(ID, ErrorOutput) Global FreeWebGadgetEx.FreeWebGadgetEx = GetFunction(PBEx_WebGadget, "FreeWebGadgetEx") Prototype IsWebGadgetEx(ID, ErrorOutput) Global IsWebGadgetEx.IsWebGadgetEx = GetFunction(PBEx_WebGadget, "IsWebGadgetEx") Prototype WebGadgetExWidth(ID, ErrorOutput) Global WebGadgetExWidth.WebGadgetExWidth = GetFunction(PBEx_WebGadget, "WebGadgetExWidth") Prototype WebGadgetExHeight(ID, ErrorOutput) Global WebGadgetExHeight.WebGadgetExHeight = GetFunction(PBEx_WebGadget, "WebGadgetExHeight") Prototype WebGadgetExX(ID, ErrorOutput) Global WebGadgetExX.WebGadgetExX = GetFunction(PBEx_WebGadget, "WebGadgetExX") Prototype WebGadgetExY(ID, ErrorOutput) Global WebGadgetExY.WebGadgetExY = GetFunction(PBEx_WebGadget, "WebGadgetExY") Prototype WebGadgetExID(ID, ErrorOutput) Global WebGadgetExID.WebGadgetExID = GetFunction(PBEx_WebGadget, "WebGadgetExID") Prototype HideWebGadgetEx(ID, State, ErrorOutput) Global HideWebGadgetEx.HideWebGadgetEx = GetFunction(PBEx_WebGadget, "HideWebGadgetEx") Prototype ResizeWebGadgetEx(ID, X, Y, Width, Height, ErrorOutput) Global ResizeWebGadgetEx.ResizeWebGadgetEx = GetFunction(PBEx_WebGadget, "ResizeWebGadgetEx") Prototype HideWebGadgetExDevTools(ID, State, ErrorOutput) Global HideWebGadgetExDevTools.HideWebGadgetExDevTools = GetFunction(PBEx_WebGadget, "HideWebGadgetExDevTools") Prototype ExecuteWebGadgetExJavaScript(ID, Code.p-Unicode, Output, ErrorOutput) Global ExecuteWebGadgetExJavaScript.ExecuteWebGadgetExJavaScript = GetFunction(PBEx_WebGadget, "ExecuteWebGadgetExJavaScript") Prototype BindWebGadgetExJavaScript(ID, PBProcedureName.p-Unicode, PBProcedureHandle, PID, ErrorOutput) Global BindWebGadgetExJavaScript.BindWebGadgetExJavaScript = GetFunction(PBEx_WebGadget, "BindWebGadgetExJavaScript") Prototype GetWebGadgetExAttribute(ID, Attribute, ErrorOutput) Global GetWebGadgetExAttribute.GetWebGadgetExAttribute = GetFunction(PBEx_WebGadget, "GetWebGadgetExAttribute") Prototype SetWebGadgetExAttribute(ID, Attribute, Value, ErrorOutput) Global SetWebGadgetExAttribute.SetWebGadgetExAttribute = GetFunction(PBEx_WebGadget, "SetWebGadgetExAttribute") Prototype EnableRemoteDebugger(Port, ErrorOutput) Global EnableRemoteDebugger.EnableRemoteDebugger = GetFunction(PBEx_WebGadget, "EnableRemoteDebugger") Prototype SetWebGadgetExSetUserAgent(UserAgent.p-Unicode, ErrorOutput) Global SetWebGadgetExSetUserAgent.SetWebGadgetExSetUserAgent = GetFunction(PBEx_WebGadget, "SetWebGadgetExSetUserAgent") Prototype SetWebGadgetExProxy(Proxy.p-Unicode, ErrorOutput) Global SetWebGadgetExProxy.SetWebGadgetExProxy = GetFunction(PBEx_WebGadget, "SetWebGadgetExProxy") EndIf
Define Output$ = Space(1000000) Define ErrorOutput$ = Space(128) Define IsDevTools = #True
Procedure MyJSCallback(aaa) Debug "This procedure was executed from Javascript: " + PeekS(aaa) EndProcedure
If OpenWindow(0, 0, 0, 1200, 768, "Window", #PB_Window_SystemMenu | #PB_Window_ScreenCentered) ;SetWebGadgetExSetUserAgent("PureBasic Bot", @ErrorOutput$) ;SetWebGadgetExProxy("108.61.86.187:8080", @ErrorOutput$);https://www.proxy-list.download/HTTPS WebGadgetEx(1, 0, 20, 1200, 748, "http://www.rsbasic.de", WindowID(0), @ErrorOutput$) ;WebGadgetEx(1, 0, 20, 1200, 748, "https://www.whatismybrowser.com/detect/what-is-my-user-agent", WindowID(0), @ErrorOutput$) ButtonGadget(2, 0, 0, 50, 20, "Back", 0) ButtonGadget(3, 50, 0, 50, 20, "Forward", 0) ButtonGadget(4, 100, 0, 50, 20, "Reload", 0) ButtonGadget(5, 150, 0, 50, 20, "Stop", 0) ButtonGadget(6, 200, 0, 50, 20, "Google", 0) ButtonGadget(7, 250, 0, 70, 20, "Own HTML", 0) ButtonGadget(8, 320, 0, 70, 20, "Get HTML", 0) ButtonGadget(10, 390, 0, 70, 20, "Get URL", 0) ButtonGadget(11, 460, 0, 100, 20, "Get size && position", 0) ButtonGadget(12, 560, 0, 50, 20, "Get ID", 0) ButtonGadget(13, 610, 0, 50, 20, "Hide", 0) ButtonGadget(14, 660, 0, 50, 20, "Show", 0) ButtonGadget(15, 710, 0, 50, 20, "Size", 0) ButtonGadget(16, 760, 0, 100, 20, "Show/Hide DevT.", 0) ButtonGadget(17, 860, 0, 70, 20, "Execute JS", 0) ButtonGadget(18, 930, 0, 50, 20, "BindProc", 0) ButtonGadget(19, 980, 0, 50, 20, "CallProc", 0) ButtonGadget(20, 1030, 0, 50, 20, "IsBusy?", 0) ButtonGadget(21, 1080, 0, 50, 20, "GetZoom", 0) ButtonGadget(22, 1130, 0, 60, 20, "Zoom=200", 0) Repeat Select WaitWindowEvent() Case #PB_Event_Gadget Select EventGadget() Case 2 SetWebGadgetExState(1, #PB_Web_Back, @ErrorOutput$) Case 3 SetWebGadgetExState(1, #PB_Web_Forward, @ErrorOutput$) Case 4 SetWebGadgetExState(1, #PB_Web_Refresh, @ErrorOutput$) Case 5 SetWebGadgetExState(1, #PB_Web_Stop, @ErrorOutput$) Case 6 SetWebGadgetExText(1, "http://www.google.de", @ErrorOutput$) Case 7 SetWebGadgetExItemText(1, #PB_Web_HtmlCode, "<html><head></head><body><h1>Hello PureBasic Friends!</h1></body></html>", @ErrorOutput$) Case 8 GetWebGadgetExItemText(1, #PB_Web_HtmlCode, @Output$, @ErrorOutput$) Debug Output$ Case 10 GetWebGadgetExText(1, @Output$, @ErrorOutput$) Debug Output$ Case 11 Debug WebGadgetExWidth(1, @ErrorOutput$) Debug WebGadgetExHeight(1, @ErrorOutput$) Debug WebGadgetExX(1, @ErrorOutput$) Debug WebGadgetExY(1, @ErrorOutput$) Case 12 Debug WebGadgetExID(1, @ErrorOutput$) Case 13 HideWebGadgetEx(1, 1, @ErrorOutput$) Case 14 HideWebGadgetEx(1, 0, @ErrorOutput$) Case 15 ResizeWebGadgetEx(1, 100, 50, 200, 400, @ErrorOutput$) Case 16 IsDevTools ! #True HideWebGadgetExDevTools(1, IsDevTools, @ErrorOutput$) Case 17 ExecuteWebGadgetExJavaScript(1, "document.body.style.backgroundColor = " + Chr(34) + "#ff0000" + Chr(34), @Output$, @ErrorOutput$) ExecuteWebGadgetExJavaScript(1, "document.body.offsetHeight;", @Output$, @ErrorOutput$) Debug Output$ ;If you want to run modal dialogs like Alert(), please set the parameter "Output" to 0. ExecuteWebGadgetExJavaScript(1, "alert('Hello');", 0, @ErrorOutput$) Case 18 BindWebGadgetExJavaScript(1, "MyJSCallback", @MyJSCallback(), GetCurrentProcessId_(), @ErrorOutput$) Case 19 ExecuteWebGadgetExJavaScript(1, "(async function() { await CefSharp.BindObjectAsync('PBProcedure'); PBProcedure.call('MyJSCallback', 'Hello PureBasic'); })();", @Output$, @ErrorOutput$) Case 20 Debug GetWebGadgetExAttribute(1, #PB_Web_Busy, @ErrorOutput$) Case 21 Debug GetWebGadgetExAttribute(1, #PB_Web_Zoom, @ErrorOutput$) Case 22 SetWebGadgetExAttribute(1, #PB_Web_Zoom, 200, @ErrorOutput$) EndSelect Case #PB_Event_CloseWindow CloseLibrary(PBEx_WebGadget) End EndSelect ForEver EndIf - SetWebGadgetExText()
- GetWebGadgetExText()
- SetWebGadgetExState()
- SetWebGadgetExItemText()
- GetWebGadgetExItemText()
- FreeWebGadgetEx()
- IsWebGadgetEx()
- WebGadgetExWidth()
- WebGadgetExHeight()
- WebGadgetExX()
- WebGadgetExY()
- WebGadgetExID()
- HideWebGadgetEx()
- ResizeWebGadgetEx()
- Syntax:
Code: Result = ResizeWebGadgetEx(ID, X, Y, Width, Height, @ErrorOutput$) - Description: Changes the position and size of the gadget.
- Parameter:
- ID: The number of the created gadget.
- X: Change the position of the gadget. #PB_Ignore can be used to ignore the parameter.
- Y: Change the position of the gadget. #PB_Ignore can be used to ignore the parameter.
- Width: Change the width of the gadget. #PB_Ignore can be used to ignore the parameter.
- height: Change the height of the gadget. #PB_Ignore can be used to ignore the parameter.
- @ErrorOutput$: If an error occurs, the error message is saved in the string variable.
- Return value:
- 1: The process was successful.
- HideWebGadgetExDevTools()
- ExecuteWebGadgetExJavaScript()
- BindWebGadgetExJavaScript()
- Syntax:
Code: Result = BindWebGadgetExJavaScript(ID, PBProcedureName$, PBProcedureHandle, PID, @ErrorOutput$) - Beschreibung: Creates a link between PB procedure and Javascript. This makes it possible to execute a PB procedure from Javascript, including passing parameters.
- Parameter:
- ID: The number of the created gadget.
- PBProcedureName$: The name of the procedure to be executed.
- PBProcedureHandle: The handle number of the procedure to be executed.
- PID: The PID number of your own program.
- @ErrorOutput$: If an error occurs, the error message is saved in the string variable.
- Return value:
- 1: The process was successful.
- GetWebGadgetExAttribute()
- SetWebGadgetExAttribute()
- EnableRemoteDebugger()
- SetWebGadgetExSetUserAgent()
- SetWebGadgetExProxy()
System requirements:- Windows Vista or higher
- .NET Framework 4.5.2 or higher
- Unicode activation (default from PB 5.50)
License: This DLL file is based on the component CefSharp and Chromium with version 71.0.3578.98 and is licensed as BSD. The component is free and may be used both privately and commercially. The following copyright texts must be included: Quote: Copyright © The CefSharp Authors. All rights reserved. Copyright 2015 The Chromium Authors. All rights reserved. Copyright © 2019 RSBasic.de
The framework CEF (Chromium Embedded Framework) is also used in many other products. E.G: GTA Online, Minecraft, Unity3D, Unreal Engine, Amazon Music, Facebook Messenger, ... Download: http://www.rsbasic.de/downloads/downloa ... Gadget.zip I would be very pleased about feedbacks, improvement suggestions, error messages or wishes. If you want to support me, you can also donate me a little something. Thanks  PS: In the first version there is still a small bug in the gadget, which only occurs sometimes and it can happen that the position and size of the gadget is not right. If you also have this bug, please let me know.
_________________
  
|
|