Accessing HTML button OnClick event lazarus / 38-Networking and Web Programming ---------------------------------------------------------------------- lennit · 2016-01-23 19:46 Hello, In my previous project I used URL to perform actions (click and switch on/off a relay with Arduino for example). However doing it like this (code below) proves to be too slow and doesn't always work. For example when the server is busy updating sensor data, it doesn't always process the command. 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 client.URI:='172.16.1.38/?button1on';client.SendRequest;        Can I access directly the OnClick event of the button through Lazarus? I searched for a way for quite a while, but either I don't know where to look, or I can't figure out what to look for. ---------------------------------------------------------------------- Leledumbo · 2016-01-24 07:15 If it's across devices, the I believe there's no better way than networking. The lowest (and fastest) that you can get is custom protocol on top of tcp (you seem to be using http). If it's on the same device, ipc could be better. ---------------------------------------------------------------------- lennit · 2016-01-24 09:52 Yes, it's two separate devices and I use HTTP. Thanks ---------------------------------------------------------------------- lennit · 2016-01-25 09:05 I managed to fire the OnClick using Synapse's blcksock, but as I've never worked with these kinds of protocols, what happens is that I can only send the data to the server once.. This is my code: 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 Unit1; {$mode objfpc}{$H+} interface uses  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,  ExtCtrls, BlckSock; type   { TForm1 }   TTCPBlockSocket = class(TSocksBlockSocket);  TForm1 = class(TForm)    Button1: TButton;    procedure Button1Click(Sender: TObject);   private    { private declarations }  public    { public declarations }  end;   varForm1: TForm1;       aSocket:TTCPBlockSocket;buffer:string;  procedure TForm1.FormCreate(Sender: TObject);begin  aSocket:=TTCPBlockSocket.Create;aSocket.Connect('172.16.1.38','80'); end; procedure TForm1.Button1Click(Sender: TObject);begin    aSocket.SendString('GET /relay01 HTTP/1.1'#13#10'Host: 172.16.1.38'#13#10#13#10);  buffer:='';  repeat        buffer := aSocket.RecvPacket(20);  until buffer = '';   end;       end.  That's the simplest way I could think of (and find). What do I miss? Where can I look for some information how to work and understand this kind of programming? ---------------------------------------------------------------------- lennit · 2016-01-27 05:47 Finally solved it. Instead of 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.FormCreate(Sender: TObject);begin  aSocket:=TTCPBlockSocket.Create;aSocket.Connect('172.16.1.38','80');  end; procedure TForm1.Button1Click(Sender: TObject);begin    aSocket.SendString('GET /relay01 HTTP/1.1'#13#10'Host: 172.16.1.38'#13#10#13#10);  buffer:='';  repeat        buffer := aSocket.RecvPacket(20);  until buffer = '';  end;     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);begin     aSocket := TTCPBlockSocket.Create;  aSocket.Connect('172.16.1.38', '80');  if aSocket.LastError = 0 then  begin    aSocket.SendString('GET /relay01 HTTP/1.1'#13);    content := aSocket.RecvString(1000);    serverstate.Caption := content;   //helped me then monitor the output  end;  aSocket.Free;   end; This is far not as fast as I wish for the moment, but until I make the SNMP configuring of the server that will do.