Hi guys,
I open the .exe of TinyBrowser2, but I want to be able to send a link programmatically through a button but it's not working, can anyone help me?
see how I'm doing it, but it doesn't work..I would like to be able to interact through ExecuteJavaScrip
procedure TForm1.Button1Click(Sender: TObject);
begin
InitializeBrowser('https://www.mercadolivre.com.br');
end;
procedure TForm1.InitializeBrowser(const URL: string);
var
ExecInfo: TShellExecuteInfo;
begin
FillChar(ExecInfo, SizeOf(ExecInfo), 0);
ExecInfo.cbSize := SizeOf(ExecInfo);
ExecInfo.fMask := SEE_MASK_NOCLOSEPROCESS;
ExecInfo.lpFile := 'C:\Users\Luiz\Desktop\Navegator\Win32\Debug\TinyBrowser2.exe';
if ShellExecuteEx(@ExecInfo) then
begin
//Wait for the process to finish if necessary
WaitForSingleObject(ExecInfo.hProcess, INFINITE);
// Close process handle
CloseHandle(ExecInfo.hProcess);
end
else
begin
ShowMessage('Erro ao iniciar o processo');
end;
end;
Disclosure Statement: This site contains affiliate links, which means that I may receive a commission if you make a purchase using these links. As an eBay Partner, I earn from qualifying purchases.
How to send link to TinyBrowser2 programmatically?y?
-
- Posts: 8
- Joined: Sat Jun 24, 2023 5:28 am
- salvadordf
- Posts: 4093
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: How to send link to TinyBrowser2 programmatically?y?
Hi,
This is a pure Delphi question. You need to pass the URL as a parameter and modify TinyBrowser2 to read the parameter.
Perhaps the information in these pages can help you :
https://stackoverflow.com/questions/72601144/execute-a-command-line-application-via-shellexecute-and-get-its-return-value
https://stackoverflow.com/questions/38759198/open-external-application-with-passing-parameters-using-delphi-application
This is a pure Delphi question. You need to pass the URL as a parameter and modify TinyBrowser2 to read the parameter.
Perhaps the information in these pages can help you :
https://stackoverflow.com/questions/72601144/execute-a-command-line-application-via-shellexecute-and-get-its-return-value
https://stackoverflow.com/questions/38759198/open-external-application-with-passing-parameters-using-delphi-application
-
- Posts: 8
- Joined: Sat Jun 24, 2023 5:28 am
Re: How to send link to TinyBrowser2 programmatically?y?
Once again, thank you very much, Salvador, for your immense attention in helping me. The problem is that I can't make the correct change to TinyBrowser2's code so that it can
receiving the parameter, I've tried several ways. but I can't.
receiving the parameter, I've tried several ways. but I can't.
- salvadordf
- Posts: 4093
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: How to send link to TinyBrowser2 programmatically?y?
Modify uTinyBrowser2.pas and define GDefaultURL before the "implementation" section like this :
Then use GDefaultURL in TTinyBrowser2.AfterConstruction like this :
Open the project code in TinyBrowser2.dpr and read GDefaultURL like this :
Read these documents for more information about ParamStr and ParamCount :
https://docwiki.embarcadero.com/Libraries/Sydney/en/System.ParamStr
https://docwiki.embarcadero.com/Libraries/Sydney/en/System.ParamCount
https://stackoverflow.com/questions/1593388/how-do-i-recognize-command-line-parameters-in-my-delphi-program
Code: Select all
var
GDefaultURL : string = 'https://www.google.com';
implementation
Code: Select all
procedure TTinyBrowser2.AfterConstruction;
var
TempHandle : TCefWindowHandle;
TempRect : TRect;
begin
inherited AfterConstruction;
FChromium := TChromiumCore.Create(nil);
FChromium.DefaultURL := GDefaultURL;
FChromium.OnBeforeClose := Chromium_OnBeforeClose;
FChromium.OnBeforePopup := Chromium_OnBeforePopup;
FChromium.OnOpenUrlFromTab := Chromium_OnOpenUrlFromTab;
InitializeWindowHandle(TempHandle);
FChromium.CreateBrowser(TempHandle, TempRect, 'Tiny Browser 2', nil, nil, True);
end;
Code: Select all
begin
CreateGlobalCEFApp;
if ParamCount > 0 then
GDefaultURL := ParamStr(1);
if GlobalCEFApp.StartMainProcess then
begin
GlobalCEFApp.RunMessageLoop;
DestroyTinyBrowser;
end;
DestroyGlobalCEFApp;
end.
https://docwiki.embarcadero.com/Libraries/Sydney/en/System.ParamStr
https://docwiki.embarcadero.com/Libraries/Sydney/en/System.ParamCount
https://stackoverflow.com/questions/1593388/how-do-i-recognize-command-line-parameters-in-my-delphi-program