Now you can find C# code for tasks like this in stackoverflow and many other places on the internet. It is one of main advantages of QM3.
Script without trigger.
The same with the newer class HttpClient. May be slower. Both codes not tested.
Script without trigger.
C# code:
// script "" //.
using Au; using Au.Types; using static Au.AStatic; using System; using System.Collections.Generic;
using System.Net;
using System.Text;
class Script : AScript { [STAThread] static void Main(string[] a) => new Script(a); Script(string[] args) { //;;;
using (var client = new WebClient()) {
client.Headers.Add("accept", "application/json");
client.Headers.Add("content-type", "application/json-rpc");
var enc = Convert.ToBase64String(Encoding.UTF8.GetBytes("admin:password"));
client.Headers.Add("Authorization", $"Basic {enc}");
var data = "{''jsonrpc'':''1.1'',''method'':''change'',''id'': 0,''params'':[{}]}";
client.UploadString("http://192.168.1.1/test/", data);
}
}}
The same with the newer class HttpClient. May be slower. Both codes not tested.
C# code:
// script "" //.
using Au; using Au.Types; using static Au.AStatic; using System; using System.Collections.Generic;
using System.Net.Http;
using System.Text;
class Script : AScript { [STAThread] static void Main(string[] a) => new Script(a); Script(string[] args) { //;;;
using var client = new HttpClient();
var h = client.DefaultRequestHeaders;
h.Add("accept", "application/json");
h.Add("content-type", "application/json-rpc");
var enc = Convert.ToBase64String(Encoding.UTF8.GetBytes("admin:password"));
h.Add("Authorization", $"Basic {enc}");
var data = "{''jsonrpc'':''1.1'',''method'':''change'',''id'': 0,''params'':[{}]}";
var r = client.PostAsync("http://192.168.1.1/test/", new StringContent(data)).Result;
}}