From c04b07ad0407cece1ed57869b82316f3838850cb Mon Sep 17 00:00:00 2001 From: YuriXbr Date: Thu, 2 May 2024 13:24:00 -0300 Subject: [PATCH] BETA-1.3.2 Added int validation to the macro coordinates --- package-lock.json | 4 ++-- package.json | 2 +- src/utils/mouseManager.js | 29 ++++++++++++++++++++++------- 3 files changed, 25 insertions(+), 10 deletions(-) diff --git a/package-lock.json b/package-lock.json index 298b92a..fda7c1b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "LeagueClicker", - "version": "1.3.1", + "version": "1.3.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "LeagueClicker", - "version": "1.3.1", + "version": "1.3.2", "license": "GPL-3.0-only", "dependencies": { "@nut-tree/nut-js": "^3.1.2", diff --git a/package.json b/package.json index c50ab58..0269559 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "LeagueClicker", - "version": "1.3.1", + "version": "1.3.2", "description": "League Auto Clicker", "main": "index.js", "scripts": { diff --git a/src/utils/mouseManager.js b/src/utils/mouseManager.js index 6715c1c..9263ff7 100644 --- a/src/utils/mouseManager.js +++ b/src/utils/mouseManager.js @@ -21,23 +21,38 @@ async function getMousePosition(print) { async function executeMacro() { let config = require("c:/LeagueClicker/config.json"); - + for (const position in config.clickPositions) { if (cache.pauseMacro()) return; if (config.clickPositions.hasOwnProperty(position)) { - const { x, y, button } = config.clickPositions[position]; - if (x !== null && y !== null && (button >= 0 && button <= 2) ) { - logger.write('macro', 'MouseManager > executeMacro', `Movendo o mouse para posicao: (${x}, ${y})`) + let { x, y, button } = config.clickPositions[position]; + + // Verificar se x e y são strings e convertê-los em números inteiros se necessário + if (typeof x === "string") { + x = parseInt(x, 10); + } + if (typeof y === "string") { + y = parseInt(y, 10); + } + + // Verificar se o valor de button é uma string e convertê-lo em número inteiro, se necessário + if (typeof button === "string") { + button = parseInt(button, 10); + } + + // Verificar se os valores são válidos e executar o clique do mouse + if (!isNaN(x) && !isNaN(y) && (button >= 0 && button <= 2)) { + logger.write('macro', 'MouseManager > executeMacro', `Movendo o mouse para posição: (${x}, ${y})`); await mouse.move({ x, y }); - logger.write('macro', 'MouseManager > executeMacro', `Executando clique em: (${x}, ${y}) com botao ${button}`) + logger.write('macro', 'MouseManager > executeMacro', `Executando clique em: (${x}, ${y}) com botão ${button}`); await mouse.click(button); - await delay(config.config.macroSleepTime); // Espera o tempo especificado entre os cliques + await delay(config.config.macroSleepTime); // Esperar o tempo especificado entre os cliques } } } - if(!cache.pauseMacro()) return executeMacro(); + if (!cache.pauseMacro()) return executeMacro(); } function delay(ms) {