var move = { left: 'a', right: 'd', mine: 'c', duration: 3000 }; var cmd = { list: ['x/napraw kilof','x/repair'], duration: 8000 } var eat = { hotkey: 2, hotkeyPickAxe: 1, key: 'v', time: 2000, duration: 4000, } var status = false var countCommand = 0; var countEat = 0; var power = true function mine() { if(status) { execute(move.left + '.down.w' + move.duration + ' ' + move.left+'.up') execute(move.mine + '.down.w' + move.duration + ' ' + move.mine+'.up') } else {1 execute(move.right + '.down.w' + move.duration + ' ' + move.right+'.up') execute(move.mine + '.down.w' + move.duration + ' ' + move.mine+'.up') } status = !status; countCommand++ countEat++ if(power) { setTimeout(commanding,move.duration) } } function commanding() { if(countCommand == Number(cmd.duration / move.duration).toFixed()) {1 countCommand = 0 cmd.list.forEach((el,i)=>{ setTimeout(()=>{ execute('t.w150 ' + el.split('').join(' ').replace('/','SLASH') + '.w250 ENTER.w150') },(i+1) * 550) }) setTimeout(eating,cmd.list.length*800); } else { eating() } } function eating() { if(countEat == Number(eat.duration / move.duration).toFixed()) { countEat = 0; let template = eat.hotkey + '.w150 ' + eat.key+'.down.w' + eat.time + ' ' + eat.key+'.up.w150 '+eat.hotkeyPickAxe+'.w150' execute(template) setTimeout(mine,eat.time+1500); } else { mine() } } function execute(temp) { console.log(temp) exec('java -jar '+currentPath+'\\resources\\app\\app\\key-sender.jar '+temp) } setTimeout(()=>{ mainWindow.minimize(); mine() },2000)