Ir ao conteúdo

Bat Linhas de código não são executadas


Ir à solução Resolvido por Um mero usuário,

Posts recomendados

Postado

Fiz meu código para criar um autoclicker para o minetest (para quem não sabe, é um clone do minecraft). Na dupla "select" e "case" (no case ch), quando escolho se irá ter troca de stack, não importa as condições, mas ele não executa nenhum deles. Já tentei colocar "echo"s para testar, mas nada funciona. Por que ele não entra?

 

#!/bin/bash

RED='\033[0;31m'
NC='\033[0m'

echo ""
echo "Tips:"
echo -e "${RED}NEVER${NC} use in animals."
echo -e "${RED}NEVER${NC} use the simple spam too many times in server if you aren't muted by admins or mods, or if you aren't alone."
echo -e "Before using the program, install ${RED}xdotool${NC} and ${RED}calc${NC}."
echo "The stack change has a mese mode, using the necessary time to reach in half bronze pick."
echo "You can use two picks for crafting a new one."
echo "Any ideas, tell NicolasB in RC."
echo "wait for the deactivate time, it will stop without external commands."
echo "You can use the sleep time for change the opened window or do anything before program. Your computer will be inoperant during the running time."
echo ""

echo "Mode:"
select funcao in click spam\ string /killme\ loop 
do
	break;
done

case $funcao in
	click)
		read -p "sleep how many seconds? " wait;
		echo "shift?"
		select funcao1 in yes no
		do
			break;
		done
		select botao in right left
		do
			break;
		done
		echo "jump?"
		select funcao2 in yes no
		do
			break;
		done
		echo "movement?"
		select move in w a s d Up Left Down Right no
		do
			break;
		done
		echo "stack change?"
		select ch in eating mese\ farming placing no
		do
			break;
		done
		read -p "work during how many seconds? " yey;
		sleep $wait
		((future = 0))
		((future = $(calc $(date +%s)+$yey)))
		((time = 0))
		while [ 1 = 1 ]
		do
			case ch in
				mese\ farming)
					if [  $time = 0 ]
					then
						((time = $(calc $(date +%s)+55)))
					fi
					if [ $time -le $(date +%s) ]
					then
						xdotool key n
					fi
					;;
				placing)
					if ([ $move != "no" ]&&[ $funcao1 = "yes" ])
					then
						if [  $time = 0 ]
					then
						((time = $(calc $(date +%s)+87)))
					fi
						if [ $time -le $(date +%s) ]
						then
							xdotool key n
						fi
					else
						if [  $time = 0 ]
					then
						((time = $(calc $(date +%s)+50)))
					fi
						if [ $time -le $(date +%s) ]
						then
							xdotool key n
						fi
					fi
					;;
				eating)
					if [  $time = 0 ]
					then
						((time = $(calc $(date +%s)+18)))
					fi
					if [ $time -le $(date +%s) ] 
					then
						xdotool key n
					fi
					;;
			esac
			if [ $funcao1 = "yes" ] 2> /dev/null
			then
				xdotool key Shift ; sleep 0.01 ; xdotool keydown Shift ; sleep 0.01
			fi
			if [ $funcao2 = "yes" ] 2> /dev/null
			then
				xdotool keydown space ; sleep 0.01
			fi
			if [ $move != "no" ] 2> /dev/null
			then
				xdotool keydown $move ; sleep 0.01
			fi
			if [ $botao = "right" ] 2> /dev/null
			then
				xdotool click 3 ; sleep 0.01 ; xdotool mousedown 3 ; sleep 0.01
			fi
			if [ $botao = "left" ] 2> /dev/null
			then
				xdotool click 1 ; sleep 0.01 ; xdotool mousedown 1 ; sleep 0.01
			fi
			
			if [ $future -le $(date +%s) ] 2> /dev/null
			then
				xdotool keyup w a s d n Shift space
				xdotool mouseup 1
				xdotool mouseup 3
				break
			fi
		done
		;;

	spam\ string)
		read -p "type a string here: " string;
		read -p "how many times? " loop;
		read -p "sleep how many seconds? " wait;
		sleep $wait
		((ciclo = 0))
		while [ $ciclo -lt $loop ]
			do
			xdotool key Return t
			sleep 0.25
			xdotool type $string
			sleep 0.25
			((ciclo = ciclo + 1))
			done
		;;

	/killme\ loop)
		read -p "how many times? " loop;
		read -p "sleep how many seconds? " wait;
		sleep $wait
		((ciclo = 0))
		while [ $ciclo -lt $loop ]
			do
			xdotool key Return
			sleep 0,25
			xdotool key Return t
			sleep 0.25
			xdotool type /killme
			sleep 0.25
			((ciclo = ciclo + 1))
			done
		;;

	*) echo "" ; echo -e "${RED}>:(${NC}";;
esac

 

Obs.: Algumas variáveis são bem confusas mesmo... ignorem

  • 3 semanas depois...

Crie uma conta ou entre para comentar

Você precisa ser um usuário para fazer um comentário

Criar uma conta

Crie uma nova conta em nossa comunidade. É fácil!

Crie uma nova conta

Entrar

Já tem uma conta? Faça o login.

Entrar agora

Sobre o Clube do Hardware

No ar desde 1996, o Clube do Hardware é uma das maiores, mais antigas e mais respeitadas comunidades sobre tecnologia do Brasil. Leia mais

Direitos autorais

Não permitimos a cópia ou reprodução do conteúdo do nosso site, fórum, newsletters e redes sociais, mesmo citando-se a fonte. Leia mais

×
×
  • Criar novo...