you can use the "Cycle between multiple actions" meta action to toggle between multiple
I think it doesnt fit in my situation because you need to know which language is already specified.
can I trigger an action from inside javascript transforming text ?
yes, the easiest would be to create two named triggers in the "automations, named & other triggers" section, then you can trigger it via:
trigger_named_async_without_response({trigger_name: 'TheNameOfYourNamedTrigger', wait_for_reply: false});
1 Like
this is the code for anyone that wants to do the same
async (clipboardContentString) => {
var alphabet1 = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
var alphabet2 = "αβψδεφγηιξκλμνοπ;ρστθωςχυζΑΒΨΔΕΦΓΗΙΞΚΛΜΝΟΠ;ΡΣΤΘΩΧΥΖ";
var newMessage = "";
messageArr = clipboardContentString.split('');
var index0 = alphabet1.indexOf(messageArr[0]);
if (index0 !== -1) {
await trigger_named_async_without_response({trigger_name: 'changeInputGR', wait_for_reply: false});
}
else {
await trigger_named_async_without_response({trigger_name: 'changeInputEN', wait_for_reply: false});
}
for (i in messageArr) {
var char = messageArr[i];
var index = alphabet2.indexOf(char);
if (index !== -1) {
newMessage += alphabet1.charAt(index);
} else {
index = alphabet1.indexOf(char);
if (index !== -1) {
newMessage += alphabet2.charAt(index);
} else {
newMessage += char;
}
}
}
return newMessage;
}
Thank you very much!
FYI: v4.284 now has an option that can make such key sequences possible by specifying the "Only recognize if no further keyboard input is recognized for" option:
1 Like
thank you!!
I noticed that "transform selection with javascript" triggers if nothing is selected.
Is this the default behavior ?
expected:
when double shift with no text selected -> javascript should not run