I am making a small jquery script that helps me do something when I'm not on my computer. Something like a bot.
This bot should perform some left-clicks on specific points on the X, Y page.
I use this code and works great: document.elementFromPoint (X, Y) .click ();
But I also need to make a long click on another point of the page. I need to simulate this: Left-click on (x, y) ... Wait 3 seconds ... Release the left-click.
Is there a way to do something like this?
Thank.
Using pure JavaScript, this may not be possible. At least not for all circumstances.
, , , mousedown mouseup, " ", :
mousedown
mouseup
document.elementFromPoint(X, Y).mousedown(); setTimeout(() => document.elementFromPoint(X, Y).mouseup(), 3000);
, , , .
mousedown mouseup
, - :
function listenForLongClick (domElement, timeout = 3000) { let mouseDownStarted = false; let timeoutCheck = null; domElement.addEventListener('mousedown', () => { mouseDownStarted = true; timeoutCheck = setTimeout(() => mouseDownStarted = false, timeout); }, false); domElement.addEventListener('mouseup', () => { clearTimeout(timeoutCheck); if (mouseDownStarted) { console.log('within the 3 seconds'); } mouseDownStarted = false; }, false); }
Source: https://habr.com/ru/post/1684681/More articles:Removing mixed variables in SymPy series extension - pythonView IF conditional code to save processor cycles - cFacebook API Graph API does not return category_list for specific pages - facebookAPI - Shopper update on BlueSnap - apiXamarin iOS: check if notification is enabled - xamarinQuick close - forced close is always completed - closuresHow to use variable arguments with printf in a macro? - cWhy do I have different results when using commands with pipelines as opposed to && concatenated commands in bash? - command-lineReturning a promise in JavaScript es6 - javascriptЗаполните карту со значением по умолчанию - javascriptAll Articles