Sunday, September 16, 2012

Script auto click for linux

#!/bin/bash

# optional ##########################################
#MOZWIN=$(xdotool search --title "Mozilla Firefox")
#MOZDESKTOP=$(xdotool get_desktop_for_window $MOZWIN)
#xdotool set_desktop $MOZDESKTOP
#xdotool windowactivate $MOZWIN
#####################################################

FARMROWS=12
CLICK_INTERVAL=0.1

# start position, starting in the most left square
X=350
Y=510

# square jump distance
XDIS=25
YDIS=12

for((i=0;$i<=$(($FARMROWS-1));i=$(($i+1))));do

    for((j=0;$j<=$(($FARMROWS-1));j=$(($j+1))));do

        x=$(($X+(($j*$XDIS))))
        y=$(($Y-(($j*$YDIS))))

        xdotool mousemove $x $y && xdotool click 1
        echo "$x $y  i=$i  j=$j"

        sleep $CLICK_INTERVAL;
    done

         X=$(($X+$XDIS))
         Y=$(($Y+$YDIS))

done

No comments: