-
Notifications
You must be signed in to change notification settings - Fork 0
/
Minecraft-Hotkeys.ahk
executable file
·266 lines (247 loc) · 7.47 KB
/
Minecraft-Hotkeys.ahk
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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
; Minecraft-Hotkeys by Github@Scripter17
; Version 0.5.0-pre
; Original concept stolen from https://github.com/monpjc/XAHK
#SingleInstance, force
version:="v0.5.0-pre"
date:="2021-06-01"
; Initialize the GUI
; The 4 AFK hotkeys
; TODO: Maybe a for loop?
; TODO: Contribute to AHK V2's source code to ensure for loops don't suck nearly as much ass in the future
Gui, Add, Link, x10 y10 w110 h20, AFK <a href="https://www.youtube.com/watch?v=-wKW0OovGK4">Fishing</a>:
Gui, Add, Text, x120 y10 w30 h20, Alt+F
Gui, Add, Slider, x150 y10 w60 h20 ToolTip Range100-1000 TickInterval225 vFishingInterval
Gui, Add, Text, x10 y30 w110 h20, AFK Mob Grinding:
Gui, Add, Text, x120 y30 w30 h20, Alt+G
Gui, Add, Checkbox, x10 y50 vDoSwapping gSwapToggle, Swap?
; I have to do 3 separate passes to make the checkboxes and radio buttons not break
For slot in [1,2,3,4,5,6,7,8,9]
Gui, Add, Text, % "x" . (slot*25+43) . " y50", % slot
Gui, Add, Text, x10 y70, Slots
For slot in [1,2,3,4,5,6,7,8,9]
Gui, Add, Checkbox, % "vSwapSlot" . slot . " x" . (slot*25+40) . " y70 disabled", % chr(8203)
Gui, Add, Text, x10 y90, Weapon
For slot in [1,2,3,4,5,6,7,8,9]
Gui, Add, Radio, % "vWeaponSlot" . slot . " x" . (slot*25+40) . " y90 gSetWeapon disabled", % chr(8203)
Gui, Add, Text, x10 y110 w110 h20, AFK Cobblestone:
Gui, Add, Text, x120 y110 w30 h20, Alt+M
Gui, Add, Checkbox, x160 y110 vSkyblockMode gSubmit, Hotbar full of stone picks
Gui, Add, Text, x10 y130 w110 h20, Quick concrete:
Gui, Add, Text, x120 y130 w30 h20, Alt+C
; Jump flying with an elytra and rocket
Gui, Add, Text, x10 y150 w110 h20, Elytra take off:
Gui, Add, Text, x120 y150 w80 h20, Alt+Space
; Holding MButton and L/RButton spamclicks L/Rbutton
Gui, Add, Checkbox, x10 y170 w110 h20 vMiddleSpam, Autoclick
Gui, Add, Text, x120 y170 w100 h20, Middle+L/R mouse
Gui, Add, Slider, x220 y170 w60 h20 vSpamInterval Range100-1000 TickInterval225 ToolTip
;Gui, Add, Text, x280 y150, ms
; Current action (only applies to the first 4)
Gui, Add, Text, x10 y200 w90 h20, Stop action:
Gui, Add, Text, x100 y200 w90 h20, Alt+S
Gui, Add, Text, x10 y220 w90 h20, Current action:
Gui, Add, Text, x100 y220 w90 h20 vCurrentAction, None
; Current window data
Gui, Add, Text, x10 y240 w90 h20, Set window:
Gui, Add, Text, x100 y240 w90 h20, Alt+W
Gui, Add, Text, x10 y260 w90 h20, Current Window:
Gui, Add, Text, x100 y260 w200 h30 vCurrentWindow, None
; Credits
Gui, Add, Link, x240 y200 w70 h20, <a href="https://github.com/Scripter17/Minecraft-Hotkeys">Scripter17</a>
Gui, Add, Text, x240 y220 w70 , %version%
Gui, Add, Text, x240 y240 w70 h20, %date%
; Generated using SmartGUI Creator 4.0
; https://autohotkey.com/board/topic/738-smartgui-creator
Gui, Show, h290 w320, Minecraft hotkeys %version%
Return
GuiClose:
ExitApp
SetWeapon:
for slot in [1,2,3,4,5,6,7,8,9]
GuiControl, Enable, SwapSlot%slot%
newWeaponSlot:=SubStr(A_GuiControl, 0)
Gui, Submit, NoHide
GuiControl, Disable, SwapSlot%newWeaponSlot%
return
Submit:
Gui, Submit, NoHide
return
SwapToggle:
Gui, Submit, NoHide
if (DoSwapping){
; No idea why I need to do 2 loops here
for slot in [1,2,3,4,5,6,7,8,9]
GuiControl, Enable, SwapSlot%slot%
for slot in [1,2,3,4,5,6,7,8,9]
GuiControl, Enable, WeaponSlot%slot%
} else {
for slot in [1,2,3,4,5,6,7,8,9]
GuiControl, Disable, SwapSlot%slot%
for slot in [1,2,3,4,5,6,7,8,9]
GuiControl, Disable, WeaponSlot%slot%
}
return
stopCurrent:=False
isDoigngSomething:=False
; Set the window
; This is disabled while a hotkey is running to ensure the user doesn't accidentally change it when doing other stuff
!W::
WinGet, WindowPID, PID, A
WinGetTitle, WindowName, A ; Why isn't this a part of WinGet?
GuiControl, , CurrentWindow, %WindowName% (%WindowPID%) ; Set the text of the "Current Window" line
Return
; Stop the currently active hotkey
; This only works while the currently selected window is active or if it doesn't exsist anymore
#If WinActive("ahk_pid " . WindowPID) || !WinExist("ahk_pid" . WindowPID)
!S::
Suspend, Permit
if (isDoingSomething=True){
stopCurrent:=True
GuiControl, , CurrentAction, None
isDoingSomething:=False
}
Return
#If
#If WinActive("ahk_pid " . WindowPID)
; Fishing
!F::
GuiControl, , CurrentAction, Fishing
GuiControlGet, FishingInterval
Suspend, On ; Disable any hotkey that isn't marke with "Suspend, Permit"
isDoingSomething:=True
while (!stopCurrent){ ; TODO: Figure out why =False doesn't work but <>True does
ControlClick, , ahk_pid %WindowPID%, , Right, , NAD
Sleep, 100
ControlClick, , ahk_pid %WindowPID%, , Right, , NAU
Sleep, %FishingInterval%
}
stopCurrent:=False
Suspend, Off ; Re-enable the suspended hotkeys
Return
; Mob grinding
!G::
GuiControl, , CurrentAction, Grinding
Suspend, On
Gui, Submit, NoHide
isDoingSomething:=True
weaponSlot:=-1
if (DoSwapping){
for slot in [1,2,3,4,5,6,7,8,9]
if (weaponSlot%slot%){
weaponSlot:=slot
}
}
WinGet, aaa, PID, ahk_pid %WindowPID%
GMainLoop:
while (!stopCurrent){
if (DoSwapping && weaponSlot<>-1){
SetKeyDelay, 50, 10
for slot in [1,2,3,4,5,6,7,8,9]
if (SwapSlot%slot% && slot<>weaponSlot){
ControlSend, , %slot%f%weaponSlot%
Loop 10 {
; This makes sure you can CTRL+C out of the script in a timely manner
Sleep, 162
if (stopCurrent){
;ControlSend, , %slot%f%weaponSlot%
break, GMainLoop ; Jank BS
}
}
;ControlClick, , ahk_pid %WindowPID%, , Left, , NA
ControlSend, , %slot%f%weaponSlot%
}
} else {
ControlClick, , ahk_pid %WindowPID%, , Left, , NA
Sleep, 50
ControlClick, , ahk_pid %WindowPID%, , Right, , NAD
Loop 10 {
Sleep, 162
if (stopCurrent){
break, GMainLoop
}
}
Sleep, 50
}
}
ControlClick, , ahk_pid %WindowPID%, , Right, , NAU
stopCurrent:=False
Suspend, Off
Return
; Cobblestone generator
!M::
GuiControl, , CurrentAction, Cobblestone
Suspend, On
isDoingSomething:=True
while (stopCurrent<>True){
Sleep, 1000
ControlClick, , ahk_pid %WindowPID%, , Left, , NAD
Sleep, 1000
ControlClick, , ahk_pid %WindowPID%, , Left, , NAU
if (SkyblockMode){
Send, {WheelDown}
}
Sleep, 2000
}
ControlClick, , ahk_pid %WindowPID%, , Left, , NAU
stopCurrent:=False
Suspend, Off
Return
; Concrete
; I don't intend to use this, I just want to do everything XAHK does and more
!C::
GuiControl, , CurrentAction, Concrete
Suspend, On
isDoingSomething:=True
ControlClick, , ahk_pid %WindowPID%, , Right, , NAD
Sleep, 50
ControlClick, , ahk_pid %WindowPID%, , Left, , NAD
while (stopCurrent<>True){
Sleep, 50
}
ControlClick, , ahk_pid %WindowPID%, , Left, , NAU
Sleep, 50
ControlClick, , ahk_pid %WindowPID%, , Right, , NAU
stopCurrent:=False
Suspend, Off
Return
; Elytra take off
!Space::
Suspend, Permit
; Why exactly I need to do it like this is anyone's guess
Send {Space down}
Sleep 75
Send {Space up}
Sleep 200
Send {Space down}
Sleep 75
Send {Space up}
Sleep 50
Click, Right
Return
; Autoclicking
~MButton & LButton::
Suspend, Permit
guicontrolget, MiddleSpam
if (MiddleSpam=1){
while (getKeyState("LButton", "P")){
Click
Sleep % SpamInterval
}
}
Return
~MButton & RButton::
Suspend, Permit
guicontrolget, MiddleSpam
if (MiddleSpam=1){
while (getKeyState("RButton", "P")){
Click, Right
Sleep % SpamInterval
}
}
Return
#If
!+^#esc::
; Just trust me on this
ExitApp
return
; todo: look at https://www.autohotkey.com/boards/viewtopic.php?t=122278