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);Read file from resource not working
-
I don't know if i'm doing something wrong but if i put inside the "Read file" command an resource file path "lines from file" the function doesn't work
What am i doing wrong ?Edit : I understood what i was doing wrong , but i was wondering if you could somehow put */Desktop/software/file.txt or something similar for a fixed path so that if you move the software to another computer it will still work with the predefined path
-
@denanotherday i found what i was doing wrong but if you could help me with the part i edited above i would really appreciate it
-
File from folder and from the resource use fixed string and put the directory example D:
and from script read file by {{your_resource_path}}\file_name.txtif this not meet with ur question, lemme know :)
Regards
-
@bogdan said in Read file from resource not working:
I don't know if i'm doing something wrong but if i put inside the "Read file" command an resource file path "lines from file" the function doesn't work
Doing so means that there is path to another file inside your original file.
Just use resource anywhere in your code.