I tried applying this using ChatGPT, but it didn't work for me. Can you tell me where to put this code to make my code work?
// Функция для эмуляции нажатия мыши внутри элемента <canvas data-sentry-element="Stage"> function simulateMouseClickInCanvas() { const canvas = document.querySelector('canvas[data-sentry-element="Stage"]'); if (!canvas) { console.error("Элемент <canvas> не найден."); return; } const rect = canvas.getBoundingClientRect(); // Выбираем случайные координаты внутри элемента <canvas> const randomX = Math.random() * rect.width + rect.left; const randomY = Math.random() * rect.height + rect.top; // Создаём события мыши const mouseDownEvent = new MouseEvent("mousedown", { bubbles: true, cancelable: true, clientX: randomX, clientY: randomY, }); const mouseUpEvent = new MouseEvent("mouseup", { bubbles: true, cancelable: true, clientX: randomX, clientY: randomY, }); const clickEvent = new MouseEvent("click", { bubbles: true, cancelable: true, clientX: randomX, clientY: randomY, }); // Эмулируем события canvas.dispatchEvent(mouseDownEvent); canvas.dispatchEvent(mouseUpEvent); canvas.dispatchEvent(clickEvent); } // Функция для выполнения кликов с рандомной задержкой function performRandomClicksInCanvas(maxClicks) { let clicksCount = 0; function clickWithRandomDelay() { if (clicksCount >= maxClicks) { console.log("Все клики выполнены"); return; } const delay = Math.random() * (2000 - 100) + 100; // Рандомная задержка от 0.1 до 2 секунд setTimeout(() => { simulateMouseClickInCanvas(); clicksCount++; console.log(`Клик ${clicksCount} выполнен (задержка: ${Math.round(delay)} мс)`); clickWithRandomDelay(); // Рекурсивный вызов для следующего клика }, delay); } clickWithRandomDelay(); } // Запуск выполнения 10 кликов performRandomClicksInCanvas(10);Script works on record mode but not on run mode
-
Hello guys, I just made a few major changes to my script and now it does not run as intended.
There is no direct error, BAS just finishes with "Success(0) Fails(0)..." and if i click on "OK" BAS closes completely.
The strange thing is, that the script worked the entire time in the record/editor modus and still does.
In the BAS/logs/log folder there is only a "All data have been processed, Script finished correctly"?
I would be very happy if someone can help.
Thanks :)
-
@basmail said in Script works on record mode but not on run mode:
Hello guys, I just made a few major changes to my script and now it does not run as intended.
its strange that happens to me too yesterday. I did send a message to @support in skype hope they can solve it
-
@gudolik said in Script works on record mode but not on run mode:
@basmail said in Script works on record mode but not on run mode:
Hello guys, I just made a few major changes to my script and now it does not run as intended.
its strange that happens to me too yesterday. I did send a message to @support in skype hope they can solve it