08-12-2022, 01:27 PM
QM3 editor supports only command line. The speed is ~100 ms if fast CPU.
If need a faster way, in QM3 create a script that runs all the time and somehow listens for QM2. For example with TCP it's easy to send and receive data. Speed: less than 1 ms if no script started, 4-16 ms if started.
TCP example.
In QM2 you need class TcpSocket. Import folder TcpSocket from https://www.quickmacros.com/forum/showth...p?tid=2852
Macro TCP to QM3
In QM3 create this script and run. To run at startup, add it to Options -> General -> Run scripts...
This is raw code, need to test better and make easier to use.
If need a faster way, in QM3 create a script that runs all the time and somehow listens for QM2. For example with TCP it's easy to send and receive data. Speed: less than 1 ms if no script started, 4-16 ms if started.
TCP example.
In QM2 you need class TcpSocket. Import folder TcpSocket from https://www.quickmacros.com/forum/showth...p?tid=2852
Macro TCP to QM3
#compile "__TcpSocket"
TcpSocket x.ClientConnect("127.0.0.1" 51885)
str s
x.Send("request ą")
x.Receive(s 10000)
out F"response: {s}"
x.Send("request ą")
x.Receive(s 10000)
out F"response: {s}"
In QM3 create this script and run. To run at startup, add it to Options -> General -> Run scripts...
C# code:
// script "TCP triggers.cs"
using System.Net;
using System.Net.Sockets;
TcpListener server = null;
try {
server = new TcpListener(IPEndPoint.Parse("127.0.0.1:51885"));
server.Start();
var b = new byte[100_000];
for (; ; ) {
var client = server.AcceptTcpClient();
var stream = client.GetStream();
int n;
while ((n = stream.Read(b, 0, b.Length)) != 0) {
var s = Encoding.UTF8.GetString(b, 0, n);
print.it(s);
//here add code to parse s and run a script or thread/task or execute any short/fast code. The QM2 script will wait and receive res. Examples:
//script.run(@"\Script15.cs", "arg1", "arg2"); //run async
//script.runWait(out var res, @"\Script15.cs"); //run sync and get its script.writeResult text
//run.thread(() => { print.it("thread"); });
//Task.Run(() => { print.it("thread"); });
var res = "result č";
stream.Write(Encoding.UTF8.GetBytes(res));
}
client.Close();
}
}
finally {
server.Stop();
}
This is raw code, need to test better and make easier to use.