PB.Ex WebGadget (Windows) (WebKit)

Applications, Games, Tools, User libs and useful stuff coded in PureBasic
User avatar
RSBasic
Moderator
Moderator
Posts: 1218
Joined: Thu Dec 31, 2009 11:05 pm
Location: Gernsbach (Germany)
Contact:

PB.Ex WebGadget (Windows) (WebKit)

Post by RSBasic »

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: Select all

      Result = WebGadgetEx(ID, X, Y, Width, Height, URL$, ParentWindowID, @ErrorOutput$)
    • Description: Creates a WebGadget with the WebKit engine.
    • Parameter:
      1. ID: A unique number for the gadget. #PB_Any can be used to generate the number automatically.
      2. X: Defines the position.
      3. Y: Defines the position.
      4. Width: Sets the width.
      5. Height: Sets the height.
      6. URL$: The address of the website you want to open.
      7. ParentWindowID: Specifies the target window in which the gadget will be created.
      8. @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: Select all

      EnableExplicit
      
      Global PBEx_WebGadget
      
      #PBEx_WebGadgetEx_Version$ = "1.1.5.0"
      #PB_Web_Zoom = 100
      #PB_Web_EnableDrop = 101
      #PB_Web_StatusCode = 9
      #PB_Web_AllText = 5
      #PB_Web_SelectAll = 5
      #PB_Web_Print = 6
      
      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, 1500, 1000, "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, DesktopScaledY(60), DesktopScaledX(1500), DesktopScaledY(1000-60), "https://www.rsbasic.de", WindowID(0), @ErrorOutput$)
        ;WebGadgetEx(1, 0, DesktopScaledY(60), DesktopScaledX(1500), DesktopScaledY(1000-60), "https://www.whatismybrowser.com/detect/what-is-my-user-agent", WindowID(0), @ErrorOutput$)
        ;WebGadgetEx(1, 0, DesktopScaledY(60), DesktopScaledX(1500), DesktopScaledY(1000-60), "https://www.google.com", WindowID(0), @ErrorOutput$)
        
        ButtonGadget(2, 0, 0, 70, 30, "Back", 0)
        ButtonGadget(3, 70, 0, 70, 30, "Forward", 0)
        ButtonGadget(4, 140, 0, 70, 30, "Reload", 0)
        ButtonGadget(5, 210, 0, 70, 30, "Stop", 0)
        ButtonGadget(6, 280, 0, 70, 30, "Google", 0)
        ButtonGadget(7, 350, 0, 70, 30, "Own HTML", 0)
        ButtonGadget(8, 420, 0, 70, 30, "Get HTML", 0)
        ButtonGadget(10, 490, 0, 70, 30, "Get URL", 0)
        ButtonGadget(11, 560, 0, 150, 30, "Get size && position", 0)
        ButtonGadget(12, 710, 0, 70, 30, "Get ID", 0)
        ButtonGadget(13, 780, 0, 70, 30, "Hide", 0)
        ButtonGadget(14, 850, 0, 70, 30, "Show", 0)
        ButtonGadget(15, 920, 0, 70, 30, "Size", 0)
        ButtonGadget(16, 990, 0, 150, 30, "Show/Hide DevT.", 0)
        ButtonGadget(17, 1140, 0, 70, 30, "Execute JS", 0)
        ButtonGadget(18, 1210, 0, 70, 30, "BindProc", 0)
        ButtonGadget(19, 1280, 0, 70, 30, "CallProc", 0)
        ButtonGadget(20, 1350, 0, 70, 30, "IsBusy?", 0)
        ButtonGadget(21, 1420, 0, 70, 30, "GetZoom", 0)
        ButtonGadget(22, 0, 30, 70, 30, "Zoom=200", 0)
        ButtonGadget(23, 70, 30, 70, 30, "StatusCode?", 0)
        ButtonGadget(24, 140, 30, 100, 30, "Get selected Text", 0)
        ButtonGadget(25, 240, 30, 70, 30, "Get all Text", 0)
        ButtonGadget(26, 310, 30, 70, 30, "Select all", 0)
        ButtonGadget(27, 380, 30, 70, 30, "Print", 0)
        
        SetWebGadgetExAttribute(1, #PB_Web_EnableDrop, 0, @ErrorOutput$)
        
        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, "https://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$)
                Case 23
                  Debug GetWebGadgetExAttribute(1, #PB_Web_StatusCode, @ErrorOutput$)
                  ;Some status codes:
                  ;0 = No error
                  ;105 = Website not found
                  ;3 = Load aborted
                  ;118 = Timeout
                  ;-All status codes here: https://cefsharp.github.io/api/63.0.0/html/T_CefSharp_CefErrorCode.htm
                Case 24
                  GetWebGadgetExItemText(1, #PB_Web_SelectedText, @Output$, @ErrorOutput$)
                  Debug Output$
                Case 25
                  GetWebGadgetExItemText(1, #PB_Web_AllText, @Output$, @ErrorOutput$)
                  Debug Output$
                Case 26
                  SetWebGadgetExState(1, #PB_Web_SelectAll, @ErrorOutput$)
                Case 27
                  SetWebGadgetExState(1, #PB_Web_Print, @ErrorOutput$)
                
              EndSelect
            Case #PB_Event_CloseWindow
              CloseLibrary(PBEx_WebGadget)
              End
          EndSelect
        ForEver
      EndIf
      
  • SetWebGadgetExText()
    • Syntax:

      Code: Select all

      Result = SetWebGadgetExText(ID, URL$, @ErrorOutput$)
    • Description: The address of the website you want to open.
    • Parameter:
      1. ID: The number of the created gadget.
      2. URL$: The address of the website you want to open.
      3. @ErrorOutput$: If an error occurs, the error message is saved in the string variable.
    • Return value:
      • 1: The process was successful.
  • GetWebGadgetExText()
    • Syntax:

      Code: Select all

      Result = GetWebGadgetExText(ID, @Output$, @ErrorOutput$)
    • Description: Determines the current address of the called website.
    • Parameter:
      1. ID: The number of the created gadget.
      2. @Output$: The address of the website is stored in this variable.
      3. @ErrorOutput$: If an error occurs, the error message is saved in the string variable.
    • Return value:
      • 1: The process was successful.
  • SetWebGadgetExState()
    • Syntax:

      Code: Select all

      Result = SetWebGadgetExState(ID, State, @ErrorOutput$)
    • Description: Performs an action.
    • Parameter:
      1. ID: The number of the created gadget.
      2. State: One of the following actions can be used:
        • #PB_Web_Back: One step back in the navigation history.
        • #PB_Web_Forward: One step forward in the navigation history.
        • #PB_Web_Refresh: Reload page.
        • #PB_Web_Stop: Cancel the operation of a page that is still being loaded.
        • #PB_Web_SelectAll: Marks all..
        • #PB_Web_Print: Print the page.
      3. @ErrorOutput$: If an error occurs, the error message is saved in the string variable.
    • Return value:
      • 1: The process was successful.
  • SetWebGadgetExItemText()
    • Syntax:

      Code: Select all

      Result = SetWebGadgetExItemText(ID, Entry, Text$, @ErrorOutput$)
    • Description: Performs an action.
    • Parameter:
      1. ID: The number of the created gadget.
      2. Entry: One of the following actions can be used:
        • #PB_Web_HtmlCode: Changes the page source text.
      3. Text$: The value for the action.
      4. @ErrorOutput$: If an error occurs, the error message is saved in the string variable.
    • Return value:
      • 1: The process was successful.
  • GetWebGadgetExItemText()
    • Syntax:

      Code: Select all

      Result = GetWebGadgetExItemText(ID, Entry, @Output, @ErrorOutput$)
    • Description: Performs an action.
    • Parameter:
      1. ID: The number of the created gadget.
      2. Entry: One of the following actions can be used:
        • #PB_Web_HtmlCode: Returns the page source code.
        • #PB_Web_SelectedText: Gets the selected text.
        • #PB_Web_AllText: Gets the all texts.
      3. @Output: The value of the action is saved in the variable.
      4. @ErrorOutput$: If an error occurs, the error message is saved in the string variable.
    • Return value:
      • 1: The process was successful.
  • FreeWebGadgetEx()
    • Syntax:

      Code: Select all

      Result = FreeWebGadgetEx(ID, @ErrorOutput$)
    • Description: Free the gadget.
    • Parameter:
      1. ID: The number of the created gadget.
      2. @ErrorOutput$: If an error occurs, the error message is saved in the string variable.
    • Return value:
      • 1: The process was successful.
  • IsWebGadgetEx()
    • Syntax:

      Code: Select all

      Result = IsWebGadgetEx(ID, @ErrorOutput$)
    • Description: Checks if the gadget is still valid.
    • Parameter:
      1. ID: The number of the created gadget.
      2. @ErrorOutput$: If an error occurs, the error message is saved in the string variable.
    • Return value:
      • 1: The gadget is valid.
  • WebGadgetExWidth()
    • Syntax:

      Code: Select all

      Result = WebGadgetExWidth(ID, @ErrorOutput$)
    • Description: Determines the width of the gadget.
    • Parameter:
      1. ID: The number of the created gadget.
      2. @ErrorOutput$: If an error occurs, the error message is saved in the string variable.
    • Return value: The width of the gadget.
  • WebGadgetExHeight()
    • Syntax:

      Code: Select all

      Result = WebGadgetExHeight(ID, @ErrorOutput$)
    • Description: Determines the height of the gadget.
    • Parameter:
      1. ID: The number of the created gadget.
      2. @ErrorOutput$: If an error occurs, the error message is saved in the string variable.
    • Return value: The height of the gadget.
  • WebGadgetExX()
    • Syntax:

      Code: Select all

      Result = WebGadgetExX(ID, @ErrorOutput$)
    • Description: Determines the position of the gadget.
    • Parameter:
      1. ID: The number of the created gadget.
      2. @ErrorOutput$: If an error occurs, the error message is saved in the string variable.
    • Return value: The position of the gadget.
  • WebGadgetExY()
    • Syntax:

      Code: Select all

      Result = WebGadgetExY(ID, @ErrorOutput$)
    • Description: Determines the position of the gadget.
    • Parameter:
      1. ID: The number of the created gadget.
      2. @ErrorOutput$: If an error occurs, the error message is saved in the string variable.
    • Return value: The position of the gadget.
  • WebGadgetExID()
    • Syntax:

      Code: Select all

      Result = WebGadgetExID(ID, @ErrorOutput$)
    • Description: Determines the handle number of the created gadget. The handle number can be used for WinAPI.
    • Parameter:
      1. ID: The number of the created gadget.
      2. @ErrorOutput$: If an error occurs, the error message is saved in the string variable.
    • Return value: The handle number of the gadget.
  • HideWebGadgetEx()
    • Syntax:

      Code: Select all

      Result = HideWebGadgetEx(ID, State, @ErrorOutput$)
    • Description: Hides or displays the gadget.
    • Parameter:
      1. ID: The number of the created gadget.
      2. State:
        • 0: Show gadget.
        • 1: Hide Gadget.
      3. @ErrorOutput$: If an error occurs, the error message is saved in the string variable.
    • Return value:
      • 1: The process was successful.
  • ResizeWebGadgetEx()
    • Syntax:

      Code: Select all

      Result = ResizeWebGadgetEx(ID, X, Y, Width, Height, @ErrorOutput$)
    • Description: Changes the position and size of the gadget.
    • Parameter:
      1. ID: The number of the created gadget.
      2. X: Change the position of the gadget. #PB_Ignore can be used to ignore the parameter.
      3. Y: Change the position of the gadget. #PB_Ignore can be used to ignore the parameter.
      4. Width: Change the width of the gadget. #PB_Ignore can be used to ignore the parameter.
      5. height: Change the height of the gadget. #PB_Ignore can be used to ignore the parameter.
      6. @ErrorOutput$: If an error occurs, the error message is saved in the string variable.
    • Return value:
      • 1: The process was successful.
  • HideWebGadgetExDevTools()
    • Syntax:

      Code: Select all

      Result = HideWebGadgetExDevTools(ID, State, @ErrorOutput$)
    • Description: Hides or displays the development environment. This allows you to analyze the source code.
    • Parameter:
      1. ID: The number of the created gadget.
      2. State:
        • 0: Show
        • 1: Hide
      3. @ErrorOutput$: If an error occurs, the error message is saved in the string variable.
    • Return value:
      • 1: The process was successful.
  • ExecuteWebGadgetExJavaScript()
    • Syntax:

      Code: Select all

      Result = ExecuteWebGadgetExJavaScript(ID, Code$, @Output$, @ErrorOutput$)
    • Description: Executes any Javascript code. Hint: If you want to execute modal dialogs like Alert(), the parameter "Output" must be set to 0.
    • Parameter:
      1. ID: The number of the created gadget.
      2. Code$: Javascript code that is to be executed.
      3. @Output$: If a Javascript function has a return value, it is saved in this variable. If an error exists in the Javascript code, the Javascript error is saved in this variable.
      4. @ErrorOutput$: If an error occurs, the error message is saved in the string variable.
    • Return value:
      • 1: The process was successful.
  • BindWebGadgetExJavaScript()
    • Syntax:

      Code: Select all

      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:
      1. ID: The number of the created gadget.
      2. PBProcedureName$: The name of the procedure to be executed.
      3. PBProcedureHandle: The handle number of the procedure to be executed.
      4. PID: The PID number of your own program.
      5. @ErrorOutput$: If an error occurs, the error message is saved in the string variable.
    • Return value:
      • 1: The process was successful.
  • GetWebGadgetExAttribute()
    • Syntax:

      Code: Select all

      Result = GetWebGadgetExAttribute(ID, Attribute, @ErrorOutput$)
    • Description: Determines the value using the specified attribute.
    • Parameter:
      1. ID: The number of the created gadget.
      2. Attribute: One of the following attributes can be used:
        • #PB_Web_Busy: Checks if the page is still loading.
        • #PB_Web_Zoom: Determines the zoom value in percent.
        • #PB_Web_StatusCode: Determines the status code after loading the page, e.g. website not found or timeout.
      3. @ErrorOutput$: If an error occurs, the error message is stored in the string variable.
    • Return value: Value using the specified attribute.
  • SetWebGadgetExAttribute()
    • Syntax:

      Code: Select all

      Result = SetWebGadgetExAttribute(ID, Attribute, Value, @ErrorOutput$)
    • Description: Changes the value using the specified attribute.
    • Parameter:
      1. ID: The number of the created gadget.
      2. Attribute: One of the following attributes can be used:
        • #PB_Web_Zoom: Changes the zoom value in percent.
        • #PB_Web_BlockPopupMenu: Enables or disables the context menu.
        • #PB_Web_EnableDrop: Enables or disables the drop feature.
      3. @ErrorOutput$: If an error occurs, the error message is stored in the string variable.
    • Return value:
      • 1: The process was successful.
  • EnableRemoteDebugger()
    • Syntax:

      Code: Select all

      Result = EnableRemoteDebugger(Port, @ErrorOutput$)
    • Description: This allows you to debug the opened page on another port with DevTools. It can only be enabled and used once per process before gadget creation. Example address for port 8088: http://localhost:8088/
    • Parameter:
      1. Port: Port number for debugging an open page. The port number must be between 1024 and 65535.
      2. @ErrorOutput$: If an error occurs, the error message is stored in the string variable.
    • Return value:
      • 1: The process was successful.
  • SetWebGadgetExSetUserAgent()
    • Syntax:

      Code: Select all

      Result = SetWebGadgetExSetUserAgent(UserAgent$, @ErrorOutput$)
    • Description: Changes the UserAgent string for the WebGadget. It can only be set once per process before gadget creation.
    • Parameter:
      1. UserAgent$: UserAgent
      2. @ErrorOutput$: If an error occurs, the error message is saved in the string variable.
    • Return value:
      • 1: The process was successful.
  • SetWebGadgetExProxy()
    • Syntax:

      Code: Select all

      Result = SetWebGadgetExProxy(Proxy$, @ErrorOutput$)
    • Description: Changes the proxy server for the WebGadget. It can only be set once per process before gadget creation.
    • Parameter:
      1. Proxy$: Address and port number of the proxy server.
      2. @ErrorOutput$: If an error occurs, the error message is stored in the string variable.
    • Return value:
      • 1: The process was successful.
System requirements:
  • .NET Framework 4.7.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:
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: https://www.rsbasic.de/downloads/downlo ... Gadget.zip
Image

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.
Image
Image
HanPBF
Enthusiast
Enthusiast
Posts: 563
Joined: Fri Feb 19, 2010 3:42 am

Re: PB.Ex WebGadget (Windows) (WebKit)

Post by HanPBF »

Great!

Tried it and https://www.whatismybrowser.com/ says it's Chrome 71 on Windows 8 while my Chrome browser is up to date and says version 74 on Windows 10.
Nothing wrong here, so simply the dlls need to be exchanged?

As developer tools are "missing" (F12), I use full browser (Vivaldi for chromeless) and "background" local web server (s. a. postgres admin as an example).

But, JS/CSS3 are so powerful; this is a great "add-on" for PureBasic!

Thanks a lot!!!

(for this I waited for years now!)
Last edited by HanPBF on Wed Apr 24, 2019 7:42 pm, edited 1 time in total.
HanPBF
Enthusiast
Enthusiast
Posts: 563
Joined: Fri Feb 19, 2010 3:42 am

Re: PB.Ex WebGadget (Windows) (WebKit)

Post by HanPBF »

Tried some more pages and could not "kill" Your source :D

Now, next question: how to communicate between browser and host?
At the moment, I use WebSocket from regular browser to background client and to be future proof when a web server is available...
WebSocket runs seemless overall.

Another, "more direct" way via string exchange?
Copy to clipboard is JS side available.
User avatar
chi
Addict
Addict
Posts: 1028
Joined: Sat May 05, 2007 5:31 pm
Location: Linz, Austria

Re: PB.Ex WebGadget (Windows) (WebKit)

Post by chi »

This is just... awesome!!! Thank you very much 8)
Et cetera is my worst enemy
User avatar
RSBasic
Moderator
Moderator
Posts: 1218
Joined: Thu Dec 31, 2009 11:05 pm
Location: Gernsbach (Germany)
Contact:

Re: PB.Ex WebGadget (Windows) (WebKit)

Post by RSBasic »

PB.Ex WebGadget 1.0.1.0 has been released.

Changelog:
  • Added: 32 bit support
Image
Image
User avatar
RSBasic
Moderator
Moderator
Posts: 1218
Joined: Thu Dec 31, 2009 11:05 pm
Location: Gernsbach (Germany)
Contact:

Re: PB.Ex WebGadget (Windows) (WebKit)

Post by RSBasic »

PB.Ex WebGadget 1.0.2.0 has been released.

Changelog:
  • Added: DevTools
HanPBF wrote:As developer tools are "missing"
I added that. You have to create the key event yourself.
HanPBF wrote:Now, next question: how to communicate between browser and host?
At the moment, I use WebSocket from regular browser to background client and to be future proof when a web server is available...
WebSocket runs seemless overall.
I don't know yet if it's possible. I'll check later.
HanPBF wrote:Another, "more direct" way via string exchange?
Copy to clipboard is JS side available.
What do you mean? What do you want to copy?
Image
Image
HanPBF
Enthusiast
Enthusiast
Posts: 563
Joined: Fri Feb 19, 2010 3:42 am

Re: PB.Ex WebGadget (Windows) (WebKit)

Post by HanPBF »

F12 -> developer tools; ok, will check what is shown; thanks a lot!

WebSocket -> no need to check, they will work!

Embedded browser and host program need to exchange data; sometimes it's done via status bar or executing JavaScript or maybe clipboard does work.
As mentioned, WebSocket will of course work also with embedded browser.
File exchange could work as Google Chrome supports the file writer API (https://caniuse.com/#feat=filesystem).

Again, great work! Thanks a lot!
User avatar
RSBasic
Moderator
Moderator
Posts: 1218
Joined: Thu Dec 31, 2009 11:05 pm
Location: Gernsbach (Germany)
Contact:

Re: PB.Ex WebGadget (Windows) (WebKit)

Post by RSBasic »

PB.Ex WebGadget 1.0.3.0 has been released.

Changelog:
  • Added: ExecuteWebGadgetExJavaScript(): Executes any Javascript code.
  • Added: BindWebGadgetExJavaScript(): Creates a link between PB procedure and Javascript. This makes it possible to execute a PB procedure from Javascript, including passing parameters.
See example code in the first post.
Image
Image
User avatar
RSBasic
Moderator
Moderator
Posts: 1218
Joined: Thu Dec 31, 2009 11:05 pm
Location: Gernsbach (Germany)
Contact:

Re: PB.Ex WebGadget (Windows) (WebKit)

Post by RSBasic »

PB.Ex WebGadget 1.0.4.0 has been released.

Changelog:
  • Bugfix: BindWebGadgetExJavaScript(): Now also works on x86.
Image
Image
HanPBF
Enthusiast
Enthusiast
Posts: 563
Joined: Fri Feb 19, 2010 3:42 am

Re: PB.Ex WebGadget (Windows) (WebKit)

Post by HanPBF »

Ok, I can not as fast check the new functions as You implement them -> so, slow down :D

Code: Select all

Result = ExecuteWebGadgetExJavaScript(ID, Code$, @Output$, @ErrorOutput$) 
-> output with result -> cooooool!!!

Code: Select all

Result = BindWebGadgetExJavaScript(ID, PBProcedureName$, PBProcedureHandle, PID, @ErrorOutput$)
-> handle is address?
-> PID - process ID; found some solutions in the forum; for own exe easier to get?


You "just" bound PureBasic to another world!
Awesome!
User avatar
RSBasic
Moderator
Moderator
Posts: 1218
Joined: Thu Dec 31, 2009 11:05 pm
Location: Gernsbach (Germany)
Contact:

Re: PB.Ex WebGadget (Windows) (WebKit)

Post by RSBasic »

HanPBF wrote:

Code: Select all

Result = BindWebGadgetExJavaScript(ID, PBProcedureName$, PBProcedureHandle, PID, @ErrorOutput$)
-> handle is address?
-> PID - process ID; found some solutions in the forum; for own exe easier to get?
In the first post you have an example code:

Code: Select all

[...]
BindWebGadgetExJavaScript(1, "MyJSCallback", @MyJSCallback(), GetCurrentProcessId_(), @ErrorOutput$)
[...]
Handle is the memory address of your procedure. E.g.: @YourProcedure()
PID is the process ID of your application: GetCurrentProcessId_()
Image
Image
User avatar
RSBasic
Moderator
Moderator
Posts: 1218
Joined: Thu Dec 31, 2009 11:05 pm
Location: Gernsbach (Germany)
Contact:

Re: PB.Ex WebGadget (Windows) (WebKit)

Post by RSBasic »

PB.Ex WebGadget 1.0.5.0 has been released.

Changelog:
  • Added: GetWebGadgetExAttribute(): #PB_Web_Busy can be used to check whether the page is still loading.
  • Bugfix: ExecuteWebGadgetExJavaScript()
Image
Image
JHPJHP
Addict
Addict
Posts: 2129
Joined: Sat Oct 09, 2010 3:47 am
Contact:

Re: PB.Ex WebGadget (Windows) (WebKit)

Post by JHPJHP »

Hi RSBasic,

I don't usually post outside of my own threads, but with all the incredible work you have provided the PureBasic community, I wanted to express my sincere respect.

The following is some information worth noting...

HTML5test:
PureBasic WebGadget: Your browser scores 312 out of 555 points
Microsoft Edge: Your browser scores 492 out of 555 points
PB.Ex WebGadget: Your browser scores 523 out of 555 points

Cheers :!:
User avatar
RSBasic
Moderator
Moderator
Posts: 1218
Joined: Thu Dec 31, 2009 11:05 pm
Location: Gernsbach (Germany)
Contact:

Re: PB.Ex WebGadget (Windows) (WebKit)

Post by RSBasic »

Thanks for the compliments and thanks for the HTML5 test. :)
Image
Image
LuckyLuke
Enthusiast
Enthusiast
Posts: 181
Joined: Fri Jun 06, 2003 2:41 pm
Location: Belgium

Re: PB.Ex WebGadget (Windows) (WebKit)

Post by LuckyLuke »

This is really cool !

I was wondering if it would be easy to replace the current engine by https://ultralig.ht/.

The reason I ask this ...
Ultra-light
Only 8MB compressed, low memory usage, we've stripped WebKit to the bare essentials.
Kind regards

LuckyLuke
Post Reply