-
Notifications
You must be signed in to change notification settings - Fork 0
/
autocraft
executable file
·174 lines (154 loc) · 4.96 KB
/
autocraft
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
#! /bin/bash
# _____________ __ _____ __ ___ __ ____________ __________ ___ ____________
# / ____/ ____| |/ // _| | / / / | / / / /_ __/ __ \/ ____/ __ \/ | / ____/_ __/
# / /_ / /_ | / / / | | / / / /| |/ / / / / / / / / / / / /_/ / /| | / /_ / /
# / __/ / __/ / |_/ / | |/ / / ___ / /_/ / / / / /_/ / /___/ _, _/ ___ |/ __/ / /
# /_/ /_/ /_/|_/___/ |___/ /_/ |_\____/ /_/ \____/\____/_/ |_/_/ |_/_/ /_/
#
# A bash script that inputs macro keys after a specific duration focused on the final fantasy window.
# in order for it to work, ensure you have the materials and have clicked on the item you want to craft in the menu.
# Works amazingly for the firnament
# Author: Brigdan
#TODO
# Implement dependency checking
# Write small install script
# Write Helpdoc
# auto install dependencies
# open link to ffxiv autocrafter to for easy access to creating new macros
# implementing a pause feature
function displayHelp() {
echo """
FFXIV Autocraft
-------
An autocrafting script which navigates the menu and presses your crafting macros
Setup
-------
set your OK key from NUM_0 to PG_DOWN ingame. Put your macro on either r or set the keys
using -k. Open the crafting menu and select the item you want autocrafted by clicking the item.
You should not press the synthesise key, just leave it on the menu.
Paramaters
-------
-c | --crafts <amount of crafts>
Specify amount of crafting attempts if you do not want the program to loop infinitely.
Default is infinite.
-d | --duration <sec>
Specify the duration the program should wait before craft, 45 is the safe amount for most crafts
however 35 seems to work much faster, adjust as needed
-k | --keys <key>
Specify which macro keys you want to be pressed, refer to the xdotool key list for examples of
available keys. Supports 2 keys too for long macros.
-h | --help
Display this text and exit.
Limitations
-------
Unfortunately this program will steal focus and the script is semi relaible
due to the limitations of not reading game memory it is unavoidable and you
do have to leave your keyboard alone every time you get a notification or hear the sound
"""
}
#Handling paramaters given to the script during exectuion
while :; do
case $1 in
-h | --help | \?)
displayHelp # still need to write the help doc
exit
;;
-d | --duration)
if [ "$2" ]; then
duration=$2
echo "Duration set to $duration seconds."
shift
else
echo "Please enter a duration in seconds."
exit
fi
;;
-k | --keys)
if [ "$3" ]; then #if user gives 2 paramaters
keys=() # create an empty list
keys[0]=$2 #append key values, theres probably a better way of doing this but whatever
keys[1]=$3
twokey=true #set for displaying output properly
shift
shift
shift #Move $3 back to $1 for the next paramater
echo "${keys[0]} and ${keys[1]} loaded as keys."
elif [ "$2" ]; then
keys=$2 #set to a single key otherwise
twokey = false
shift
echo "$keys loaded as key."
else
echo "Please enter a valid key combination (1 or 2 keys)"
exit
fi
;;
*) #unknown option
break
;;
esac
done
function main() {
if test -z $keys; then
keys=r # set default key value if the user just runs the program
fi
craftAmount=0
gaps=${duration:=45} #Set to the default value if duration is not set
displayMenu
while true; do
craft
displayMenu
done
}
function getWindowID() {
# Get window ID for ffxiv to focus whenever a craft runs
PID=$(xdotool search --name "Final Fantasy XIV")
}
function craft() {
echo "Craft Initiated!"
sleep 2
xdotool windowactivate ${PID}
sleep 0.5
xdotool key Page_Down
sleep 0.5
xdotool key Page_Down
xdotool key Page_Down
sleep 0.4
sleep 0.4
xdotool key Page_Down
sleep 0.4
xdotool key Page_Down
sleep 1
xdotool key Page_Down
sleep 1
if [ "$twokey" == true ]; then
xdotool key ${keys[0]}
sleep ${gaps}
xdotool key ${keys[1]}
else
xdotool key ${keys}
fi
sleep ${gaps}
i=$((i+1))
craftAmount=$((craftAmount+1)) #for output of total craftss
}
function displayMenu() {
clear
sleep 0.5 && echo "---------------------------------"
sleep 0.5 && echo "FFXIV Automator by Kazpa "
sleep 0.5 && echo "---------------------------------"
sleep 0.5 && echo "Duration between crafts (Default: 45 seconds): ${duration}"
sleep 0.5 && getWindowID && echo "Window ID:" ${PID}
if [ "$twokey" == true ]; then
echo "Macro Keys: ${keys[0]} and ${keys[1]}"
else
sleep 0.5 && echo "Macro Keys: $keys"
fi
sleep 0.5 && echo "---------------------------------"
sleep 0.5 && echo "Crafts Complete: $craftAmount"
sleep 0.5 && echo "---------------------------------"
sleep 0.5
echo "Please use CTRL + C to stop the script when you want to stop crafting."
sleep 3
}
main