Skip to content

Commit

Permalink
BETA-1.3.2
Browse files Browse the repository at this point in the history
Added int validation to the macro coordinates
  • Loading branch information
YuriXbr committed May 2, 2024
1 parent 5ee8c09 commit c04b07a
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 10 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "LeagueClicker",
"version": "1.3.1",
"version": "1.3.2",
"description": "League Auto Clicker",
"main": "index.js",
"scripts": {
Expand Down
29 changes: 22 additions & 7 deletions src/utils/mouseManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit c04b07a

Please sign in to comment.