… copy results to the clipboard

55 views
Skip to first unread message

Aly IGERY

unread,
Jul 10, 2026, 8:09:35 AM (12 days ago) Jul 10
to mementodatabase
Hello,
I have a code generator like the one below…

=======================================
let e = entry();

// Fester Zeichensatz
let allChars = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$^%&*-+:;?,.~`|_/=><([{}])";

// Zufällige Länge zwischen 5 und 25
function getRandomLength() {
  return Math.floor(Math.random() * (25- 5+ 1)) + 5;
}

function getRandomChar() {
  let randomIndex = Math.floor(Math.random() * allChars.length);
  return allChars[randomIndex];
}

function generateRandomString(length) {
  let result = "";
  for (let i = 0; i < length; i++) {
    result += getRandomChar();
  }
  return result;
}

// Länge bestimmen und Code erzeugen
let length = getRandomLength();
let code = generateRandomString(length);

// In das Feld OPSCdGen schreiben
e.set('OPSCdGen', code);
=======================================

When I press the [Generate OPSCd] button, a code between 5 and 25 characters long is created in the [OPSCdGen] field. Sometimes this button gets pressed accidentally, causing the code to change.

I would like the generated code to be copied to the clipboard instead of the [OPSCdGen] field when I press the [Generate OPSCd] button. Is this possible? (for Android and Windows)

Many thanks in advance…

Mmm

unread,
Jul 10, 2026, 8:21:34 AM (12 days ago) Jul 10
to mementodatabase
Добавьте рядом вторую кнопку "Share OPSCd". 
В кнопке установите "Действие" - Поделиться. В поле для текста выберите поле "OPSCdGen".
Одна кнопка будет отвечать за генерацию кода, вторая позволит им делиться.

Вместо второй кнопки можно использовать Правило - Действие или Скрипт - Действие.

пятница, 10 июля 2026 г. в 15:09:35 UTC+3, warna...@gmail.com:

Mmm

unread,
Jul 10, 2026, 8:42:04 AM (12 days ago) Jul 10
to mementodatabase
Кроме того, в скрипт для генерации можете добавить условие, что генерация и сохранение нового кода может выполняться только если поле  "OPSCdGen" пустое.
Это позволит исключить случайную генерацию кода.

пятница, 10 июля 2026 г. в 15:21:34 UTC+3, Mmm:

Aly IGERY

unread,
Jul 10, 2026, 8:48:31 AM (12 days ago) Jul 10
to mementodatabase
… I meant redirecting the result directly to the "clipboard." If there’s no other way, I’m happy with that too. Many thanks! 🙏

Aly IGERY

unread,
Jul 10, 2026, 8:49:08 AM (12 days ago) Jul 10
to mementodatabase
… if only I knew how to do that 🤔

Mmm

unread,
Jul 10, 2026, 9:04:23 AM (12 days ago) Jul 10
to mementodatabase
1.
=======================================
let e = entry();

if (e.field('OPSCdGen')) {
    message('Ваш текст'); //если нужно сообщить, что поле не пустое
    exit();
}
...

Остальной код без изменений.

2. После нажатия на кнопку "Share OPSCd" будет доступен пункт Копировать текст.

пятница, 10 июля 2026 г. в 15:49:08 UTC+3, warna...@gmail.com:

Aly IGERY

unread,
Jul 10, 2026, 10:36:28 AM (12 days ago) Jul 10
to mementodatabase
Thanks, Mmm 🙏, works well.
Reply all
Reply to author
Forward
0 new messages