Currently AI have not enough knowledge about LibreAutomate to create working code. I tried to ask this question too, and got another non-working code.
But when I gave it relevant LibreAutomation documentation articles, AI created this code (just forgot to assign false/null to the variables, I fixed it). And it works. I used OpenAI model `gpt-5` via API.
I would do it differently, but this works too.
You probably will want to move that code to your `Hotkey triggers` file. Then need to modify it slightly. Code to paste in file `Hotkey triggers`:
Here I changed the hotkey to F9.
Most of this code could be moved to a separate script.
But when I gave it relevant LibreAutomation documentation articles, AI created this code (just forgot to assign false/null to the variables, I fixed it). And it works. I used OpenAI model `gpt-5` via API.
bool sending=false;
Thread? worker=null;
var at = new Au.Triggers.ActionTriggers();
at.Hotkey["T"] = o => {
sending = !sending;
print.it(sending ? "T spam ON" : "T spam OFF");
if (sending && worker is null) {
worker = run.thread(() => {
while (sending) {
keys.more.sendKey(KKey.T); // press and release T
10.ms(); // ~100 per second (see note below)
}
worker = null;
});
}
};
at.Hotkey["Esc"] = o => script.end();
at.Run();I would do it differently, but this works too.
You probably will want to move that code to your `Hotkey triggers` file. Then need to modify it slightly. Code to paste in file `Hotkey triggers`:
bool sending = false;
Thread worker = null;
hk["F9"] = o => {
sending = !sending;
print.it(sending ? "T spam ON" : "T spam OFF");
if (sending && worker is null) {
worker = run.thread(() => {
try {
while (sending) {
keys.more.sendKey(KKey.T); // press and release T
10.ms(); // ~100 per second (see note below)
}
}
catch (Exception) { sending = false; }
worker = null;
});
}
};Here I changed the hotkey to F9.
Most of this code could be moved to a separate script.
