Ole based browser fails on second .Navigate lazarus / 38-Networking and Web Programming ---------------------------------------------------------------------- RedOctober · 2021-08-27 18:14 Platform:  Laz 2.0.10  FPC  3.2.0  Windows Server 2016 (all updates) Background:  I need to launch InternetExplorer and have it navigate to a website. In this case NetCare, a well known health information website for physicians in Alberta Canada.  I was trying to do this with ActiveX but IE has moved on since the ActiveX example for Lazarus was made, and the imported TLB doesn't match the example anymore.  I am unable to get it to work.  So I used Ole instead. (BTW, I built this exact thing in Delphi and it worked great for many years, using the TWebBrowser component in Delphi.  (I say this just to confirm that the goal is achievable, not to "trash" Lazarus.  I'm a Lazarus fan.)(Also, I am unable to convert TWebBrowser from Delphi, as some have suggested.) Problem:  The below source code works.... "sort of".  It will only do one Navigate, the first one.  After that, subsequent .Navigate calls fail, and the user gets the message "RPC server disconnected". Does anyone have a working example to do a Parameter Launched Browser session using Lazarus?  Specifically for NetCare, which uses Citrix. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i unit f_netcare; {$mode objfpc}{$H+} interface uses  Classes, SysUtils, Forms, Controls, Graphics, Dialogs; // , SHDocVw_1_1_TLB type   { TfrmNetCare }   TfrmNetCare = class(TForm)    procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);    procedure FormCreate(Sender: TObject);    procedure FormDestroy(Sender: TObject);  private    //IEBrowser: TAxcWebBrowser;    Browser: OleVariant;    procedure LoadDefaults;    procedure LoadPersistent;   public    procedure GoToClient(const pnt_uli: String);    procedure GoToURL(const url_str: String);  end; implementation uses Windows, ComObj, u_gv; {$R *.lfm} { TfrmNetCare } procedure TfrmNetCare.FormClose(Sender: TObject; var CloseAction: TCloseAction);begin  CloseAction := caHide;end; procedure TfrmNetCare.FormCreate(Sender: TObject);begin  LoadDefaults;  LoadPersistent;end; procedure TfrmNetCare.FormDestroy(Sender: TObject);begin  //GV.IEBrowser.Free;  Browser := Unassigned;end; procedure TfrmNetCare.LoadDefaults;begin  //GV.IEBrowser := TAxcWebBrowser.Create(Self);  //GV.IEBrowser := TAxcWebBrowser.CreateParented(Handle);  //GV.IEBrowser.OleServer.Visible := True;  //GV.IEBrowser.OleServer.ToolBar := False;  //GV.IEBrowser.OleServer.ShowBrowserBar();  //GV.IEBrowser.OleServer.FullScreen := False;   try    Browser := CreateOleObject('InternetExplorer.Application');    Windows.SetParent(Browser.hwnd, Self.Handle);     Browser.Toolbar := False;    Browser.Fullscreen := True;    //Browser.Resizable := False;    Browser.Visible := True;  except    on E: Exception do      begin        if SameText(E.ClassName, 'EOleSysError') then          begin            GV.NetCare.OLE_Blocked := True;            //ShowMessage('It appears that a previous copy of this app was unable to release the Browser.OleObject.  This means that this instance of this app will not be able to call NetCare.  Instead, you can use NetCare in tne other open instance of RUBI, or, use click/copy of Client Billing ID numbers from this app and paste into NetCare manually.');          end;      end;  end; end; procedure TfrmNetCare.LoadPersistent;begin  //end; procedure TfrmNetCare.GoToClient(const pnt_uli: String);var go2url: String;begin  GV.NetCare.was_used := True;  go2url := StringReplace(GV.NetCare.BaseURL, '[LOGIN_ID]', GV.UsrProps.netcare_login_id, []);  go2url := StringReplace(go2url, '[AHC_ID]', pnt_uli, []);  GoToURL(go2url);end; procedure TfrmNetCare.GoToURL(const url_str: String);var  w_url_str: WideString;  ole_url, ole_null: Olevariant;begin  w_url_str := url_str;  Browser.Silent := True;  Browser.Navigate(w_url_str, null, null, null, null);  Show;  BringToFront;end; end. ---------------------------------------------------------------------- winni · 2021-08-27 19:07 Hi! Read the old news from Microsoft: ______________________________ Important The Internet Explorer 11 desktop application will be retired and go out of support on June 15, 2022 (for a list of what's in scope, see the FAQ). The same IE11 apps and sites you use today can open in Microsoft Edge with Internet Explorer mode. Learn more here. _______________________________ From https://docs.microsoft.com/en-us/troubleshoot/browsers/only- secure-content-is-displayed-message You can integrate the Chromium web browser in your Lazarus project: https://forum.lazarus.freepascal.org/index.php/topic,55287.msg411329.h tml#msg411329 Winni ---------------------------------------------------------------------- Soner · 2021-08-27 20:43 Use the function OpenURL form the unit lclintf. It is crossplatform. Or when you still want use Internet Explorer then look at my example code. It compiles on Lazarus and Delphi 7 and Delphi 2006 tested. Also you can enable and disable some functions, look at the code. Also look at this  topic. I posted there similiar code. ---------------------------------------------------------------------- Jurassic Pork · 2021-08-28 11:34 hello, Quote from: RedOctober on August 27, 2021, 08:14:36 pmPlatform:  Laz 2.0.10  FPC  3.2.0  Windows Server 2016 (all updates) Background:  I need to launch InternetExplorer and have it navigate to a website. In this case NetCare, a well known health information website for physicians in Alberta Canada.  to automate a browser to get informations from a website you can use selenium. With selenium you can use chrome , edge chromium, firefox as automating browser. for lazarus you can try to use Webdriver4L (not all selenium functions , not tested with edge) : QuoteWebDriver4L   Selenium Webdriver for Lazarus   // Jurassic Pork 01/2021 Derivative work from Ericwang1104/WebDriver4D  : https://github.com/Ericwang1104/WebDriver4D Source code modified to use fphttpclient, fpjson,jsonparser. The project is in alpha stage. A demo project is included :  get a screenshot of the lazarus forum, get all the recent topics and display then in a memo, get stats. the demo project has been tested on windows 10 lazarus 2.0.10   with chrome browser and on Ubuntu 20.04 Lazarus 2.0.10 with firefox browser. You must download the selenium Webdriver for your browser and put it in your project folder. You must use a compatible driver version of your browser : For Chrome the selenium drivers are here : https://chromedriver.chromium.org/downloads For Firefox the selenium drivers are here : https://github.com/mozilla/geckodriver/releases For example if you use Chrome 92.X on Windows  download a 92  version of the driver. The Software is provided “as is”, without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose and noninfringement. In no event shall the authors or copyright holders X be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the software or the use or other dealings in the Software. Ericwang1104/WebDriver4D has no license so this project will not be published on github. No activity since March 2019 Friendly, J.P ---------------------------------------------------------------------- PascalDragon · 2021-08-28 12:15 Quote from: RedOctober on August 27, 2021, 08:14:36 pmDoes anyone have a working example to do a Parameter Launched Browser session using Lazarus?  Specifically for NetCare, which uses Citrix. I don't have an example which uses parameters, but I've attached a simple browser that uses an Edit and a Button to trigger the navigation and that works here at least on Windows 10 21H1 (Build 19043.1165). Can you maybe provide a self contained example that shows your problem? ---------------------------------------------------------------------- RedOctober · 2021-08-30 15:14 Hi PascalDragon,  thanks for your help. I'm beginning to think there is a difference between the IE on Windows Server 2016 and the IE on Windows 10.  Your demo starts a browser, but it is only partially functional.  The loaded page always has something missing.  Either the text of the page is missing and only the images show up, or, there is only shadow outlines of the images and text blocks, and nothing else.  UPDATE:  I read this message before winnie 's message above. The secure content issue is what is probably causing this. Out of curiosity, I added the following line to your example (at the Button1Click): Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.Button1Click(Sender: TObject);var  ThisBrowser: OleVariant;begin  ThisBrowser := GetActiveOleObject('InternetExplorer.Application');...  The same error occurs.  I will now have a look at Selenium. Project iebrowser raised exception class 'EOleSysError' with message: Operation unavailable  At address 10019801F ---------------------------------------------------------------------- RedOctober · 2021-08-30 15:17 Hi Soner,  thanks for your help. I have used OpenURL before, to open a web page.  But my understanding is that OpenURL will always open a new browser (or new tab in an open browser).  I can't have that for NetCare.  The existing browser session must be opened at a new page, not a new one created.  Am I wrong?  Will OpenURL open an existing browser, existing tab, to the new URL fed to it? I will experiment with it. UPDATE:   OpenURL always opens an additional new tab in a browser.   It would be amazing if OpenURL() had a parameter that you could feed it that wd tell it to navigate the existing focused tab to a new URL. That wd solve my problem. ---------------------------------------------------------------------- winni · 2021-08-30 19:42 Hi! The windows version of OpenURL calls finally Shellexecute which does not know anything about tabs. It searches the default browser and passes the URL to the browser. Now it is up to the browser what happens. I dont have an idea how to control that. Winni ---------------------------------------------------------------------- winni · 2021-08-30 19:52 Ha - you are not alone. Firefox seems to support "always use the same tab" The Mozilla support says: Code: Text  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i To make Firefox open all links in the same tab, follow these instructions:   Type about:config in the Firefox address bar    Bypass the security warning    Find the browser.link.open_newwindow.restriction preference    Double click it to change the value to 0    Find the browser.link.open_newwindow preference    Double click it to change the value to 1 From : https://support.mozilla.org/en-US/questions/1226151 Dont know if that works Winni ---------------------------------------------------------------------- loaded · 2021-08-30 23:22 In my opinion, the browser beast CEF3 or using CEF4Delphi it's time