Paradox
©
Fisana

Jump to content


Photo

My auto click script for Linux xdotool


  • Please log in to reply
3 replies to this topic

#1 cynixx3

cynixx3

    Thor

  • Administrators
  • 59 posts
  • LocationReno
  • Minecraft Name:cYnIxX3
  • Pure Money:$500.00

Posted 08 June 2017 - 10:57 PM

Well this is my click script. Its mostly done but I still have some ideas to improve upon it. Anyways I'm going to release it now because it was inquired about.

#!/bin/bash

# This script requires the xdotool
if [[ `dpkg-query -W -f='${Status}\n' xdotool` =~ "install ok installed" ]];then
# dependencies=`rpm -qa | grep xdotool
# if [[ `rpm -q xdotool` =~ "package xdotool is installed" ]];then

# ---------- FARM CONFIGURATION SECTION ----------
# Display options
farmoptions="\e[4mA\e[24mttack, \e[4mS\e[24muper, \e[4mD\e[24mig, \e[4mP\e[24mlace, \e[4mF\e[24marm"

# $mousebutton variables
# Left mouse button = 1 // middle = 2 // Right = 3
# Configure Mouse Actions
config_mouse() {
  if [[ $farm =~ [Aa] ]]
    then mousebutton=1 clickvar=1 time="0.1" display="Attack"
  elif [[ $farm =~ [Ss] ]]
    then mousebutton=1 clickvar=1 time="0.2" display="SuperPick"
  elif [[ $farm =~ [Dd] ]]
    then mousebutton=1 clickvar=0 time="0.2" display="Dig"
  elif [[ $farm =~ [Ff] ]]
    then mousebutton=3 clickvar=0 time="0.2" display="Farm and Feed"
  elif [[ $farm =~ [Pp] ]]
    then mousebutton=3 clickvar=1 time="0.3" display="Place"
  elif [[ $farm =~ [QqYyXx] && $run == "yes" ]]
    # Loop Exit
    then run="no"
    break
  elif [[ $farm != [AaSsDdFfPpQqYyXx] && -z $run ]]
   then mousebutton=1 clickvar=1 time="0.1" display="Attack"
   echo "Bad answer defaulting to Attack"
  fi
}
# ---------- END FARM CONFIGURATION SECTION ----------

# Get state of Caps lock key (currenty the only trigger)
get_state() {
state=$(xset -q | grep Caps | awk '{print $4}')
}

# Lets get this party started
# Format the window
clear
printf '\e[8;5;80t'
printf '\e[3;0;0t'

echo -en "What do we want to automate today? ($farmoptions) "; read farm

config_mouse

sleep 3

# Start run loop
run="yes"
while [ $run =  "yes" ]; do

# Setup echo text
if [ $mousebutton = 1 ]
  then button="Left"
elif [ $mousebutton = 2 ]
  then button="Middle"
elif [ $mousebutton = 3 ]
  then button="Right"
else 
  button="Error" echo "Error"
fi
if [ $clickvar = 0 ]
  then action="hold"
elif [ $clickvar = 1 ]
  then action="click"
else
  action="Error" echo "Error"
fi

echo "$button $action active."

get_state

# Click Loop
  while [ $clickvar = 1 ] && [ $state = "on" ]; do
    xdotool click $mousebutton &
    sleep $time
    get_state
  done
# End Click Loop

# Hold loop
  while [ $clickvar = 0 ] && [ $state = "on" ]; do
   # If on mouse button down
    xdotool mousedown $mousebutton &
     # Check state while mouse is down 
      while [ $state = "on" ];do
        sleep $time
        get_state
      done
     # When state is off mouse goes up
    xdotool mouseup $mousebutton &
  done 
# End Hold Loop

# Curiosity section
  while [ $state = "off" ]; do
    clear
    echo "Ready to $display. Would you like to change actions? "
    echo -e "($farmoptions, \e[31m\e[4mQ\e[24muit\e[0m) " ; read -rt 1 farm

    config_mouse

    # If no answer in curiosity section recheck the state of the Caps lock key to see if that loop should stop
    get_state

  done 
# End Curiosity Loop
done
# End Run Loop
# Party is over, Return Screen to usable size
printf '\e[8;56;212t'

clear
echo -e "Exiting hope you had fun today. \e[33m:D\e[0m"

# Exit if dependencies do not exist
else 
echo "Can not start script, dependencies missing"
echo "Please install xdotool. \"sudo apt-get install xdotool\""
exit 1
fi

call the file what ever you like (ie click.sh) and don't forget to make it executable (chmod u+x click.sh)

 

once you start it ./click.sh you tell it what your doing:

Attack - auto left click

Super - auto left click speed limited

Dig - left hold

Place - Right Hold

Farm - Right Hold

Quit - Exit script

 

use the underlined letter to choose that option and hit enter. Next go back to minecraft and get ready to do what you want then activate Caps Lock. When Caps Lock is on the script auto runs, when Caps  Lock is off you turn off the script and it will allow you to choose a new action. 



#2 Batman

Batman

    Advanced Member

  • Moderators
  • 123 posts
  • LocationTexas
  • Minecraft Name:murdock1262

Posted 09 June 2017 - 06:11 AM

For Windows people, if you set your use key to a number then hold the number while pressing num lock (to turn it off) windows will think you still have the number key pressed.  This is very useful in that situation as well.



#3 Masci

Masci

    Newbie

  • Members
  • Pip
  • 2 posts
  • LocationUnited States
  • Minecraft Name:Masci

Posted 09 June 2017 - 06:59 AM

For windows you can also use the F11 key to switch between full screen and windowed mode. If you're holding a mouse button during that switch (and release said button right as the switch occurs) the game continues to register the button being held. I often do this when harvesting obsidian. Though I imagine this "feature" will eventually be removed.



#4 lifesgood123

lifesgood123

    Newbie

  • Members
  • Pip
  • 2 posts
  • Minecraft Name:lifesgood123

Posted 11 June 2017 - 03:10 PM

#!/bin/bash
c=xdotool
mod=Super_R 
echo "
1: Xp
2: Cobble
3: Fish
"
echo -n "?:"
read choice
echo -n "shutdown when finished?: "
read shut
case $choice in
1) 
# set n to 1
n=1
 
$c key $mod+0
sleep 1
$c key Escape
while [ $n -le 750 ]
do
echo "clicked $n times."
n=$(( n+1 )) # increments $n
$c click 1
sleep 5
done  
;;
2)
c=xdotool
mod=Super_R
x=1
$c key $mod+0
sleep 1
$c key Escape
sleep 1
while [ $x -lt 10 ]
do
$c key $x
$c mousedown 1
sleep 210
x=$(( x+1 ))
$c mouseup 1
echo "done with pickaxe $x"
sleep 0.2
done
;;
3)
p=1
c=xdotool
mod=Super_R
$c key $mod+0
sleep 1
$c key Escape
while [ $p -le 600 ]
do
echo "$n seconds"
p=$(( p+1 )) # increments $p
$c mousedown 3
sleep 1
done
$c mouseup 3
;;
*) 
echo "?????????????????????????????????????????????????????????????????????????????????????????????????????"
esac
case $shut in
yes)
shutdown now
;;
*) 
exit
;;
esac





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users