Advertisement
Guest User

ahk_flask_script

a guest
Apr 16th, 2020
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.10 KB | None | 0 0
  1. ;----------------------------------------------------------------------
  2. ; PoE Flasks macro for AutoHotKey
  3. ;
  4. ; Keys used and monitored:
  5. ; alt+f12 - activate automatic flask usage
  6. ; right mouse button - primary attack skills
  7. ; 1-5 - number keys to manually use a specific flask
  8. ; ` (backtick) - use all flasks, now
  9. ; "e" and "r" for casting buffs
  10. ; Note - the inventory buttons assume a starting location based on screen
  11. ; resolution - you'll need to update some locations, see below.
  12. ; Alt+c to Ctrl-Click every location in the (I)nventory screen.
  13. ; Alt+m - Allow setting stash tab size as normal (12x12) or large (24x24)
  14. ; Alt+g - Get the current screen coordinates of the mouse pointer.
  15. ; Alt+s - Swap a skill gem with an alternate.
  16. ;----------------------------------------------------------------------
  17. #IfWinActive Path of Exile
  18. #SingleInstance force
  19. #NoEnv
  20. #Warn
  21. #Persistent
  22.  
  23. FlaskDurationInit := []
  24. ;----------------------------------------------------------------------
  25. ; Set the duration of each flask, in ms, below. For example, if the
  26. ; flask in slot 3 has a duration of "Lasts 4.80 Seconds", then use:
  27. ; FlaskDurationInit[3] := 4800
  28. ;
  29. ; To disable a particular flask, set it's duration to 0
  30. ;
  31. ; Note: Delete the last line (["e"]), or set value to 0, if you don't use a buff skill
  32. ;----------------------------------------------------------------------
  33. FlaskDurationInit[1] := 0
  34. FlaskDurationInit[2] := 4600
  35. FlaskDurationInit[3] := 4800
  36. FlaskDurationInit[4] := 8000
  37. FlaskDurationInit[5] := 4800
  38. FlaskDurationInit["w"] := 8000 ; I use Steelskin here
  39. FlaskDurationInit["r"] := 0 ; I use Molten Shell here
  40. FlaskDurationInit["t"] := 0
  41. FlaskDurationInit["e"] := 2000
  42.  
  43. FlaskDuration := []
  44. FlaskLastUsed := []
  45. UseFlasks := false
  46. HoldRightClick := false
  47. LastRightClick := 0
  48.  
  49. ;----------------------------------------------------------------------
  50. ; The following are used for fast ctrl-click from the Inventory screen
  51. ; using alt-c. The coordinates for ix,iy come from MouseGetPos (Alt+g)
  52. ; of the top left location in the inventory screen. The delta is the
  53. ; pixel change to the next box, either down or right.
  54. ;
  55. ; To get the correct values for use below, do the following:
  56. ; 1. Load the macro into AutoHotKey
  57. ; 2. open Inventory screen (I) and place the mouse cursor in the
  58. ; middle of the top left inventory box.
  59. ; 3. Press Alt+g and note the coordinates displayed by the mouse.
  60. ; 4. Replace the coordinates below.
  61. ; 5. To get the "delta", do the same for the next inventory box down
  62. ; and note the difference
  63. ;----------------------------------------------------------------------
  64. ix := 1730
  65. iy := 818
  66. delta := 70
  67.  
  68. ;----------------------------------------------------------------------
  69. ; The following are used for fast ctrl-click from Stash tabs into the
  70. ; inventory screen, using alt-m.
  71. ; Stash top left and delta for 12x12 and 24x24 stash are defined here.
  72. ; As above, you'll use Alt+g to determine the actual values needed.
  73. ;
  74. ; To get these values, follow the instructions for the Inventory screen
  75. ; except use the stash tab boxes, instead. Note, the first COLUMN is
  76. ; for the 12x12 stash and the second COLUMN is for the 24x24 "Quad" stash.
  77. ;----------------------------------------------------------------------
  78. StashX := [ 60, 40]
  79. StashY := [253, 234]
  80. StashD := [ 70, 35]
  81. StashSize := [ 12, 24]
  82.  
  83. ;----------------------------------------------------------------------
  84. ; The following are used for gem swapping. Useful
  85. ; when you use one skill for clearing and another for bossing.
  86. ; Put the coordinates of your primary attack skill in PrimX, PrimY
  87. ; Put the coordinates of alternate attack skill in AltX, AltY
  88. ; WeaponSwap determines if alt gem is in inventory or alternate weapon.
  89. ;----------------------------------------------------------------------
  90. PrimX := 2080
  91. PrimY := 334
  92. AltX := 2505
  93. AltY := 820
  94. WeaponSwap := False
  95.  
  96. ;----------------------------------------------------------------------
  97. ; Main program loop - basics are that we use flasks whenever flask
  98. ; usage is enabled via hotkey (default is F12), and we've attacked
  99. ; within the last 0.5 second (or are channeling/continuous attacking.
  100. ;----------------------------------------------------------------------
  101. Loop {
  102. if (UseFlasks) {
  103. ; have we attacked in the last 0.5 seconds?
  104. if ((A_TickCount - LastRightClick) < 500) {
  105. Gosub, CycleAllFlasksWhenReady
  106. } else {
  107. ; We haven't attacked recently, but are we channeling/continuous?
  108. if (HoldRightClick) {
  109. Gosub, CycleAllFlasksWhenReady
  110. }
  111. }
  112. }
  113. }
  114.  
  115. !F12::
  116. UseFlasks := not UseFlasks
  117. if UseFlasks {
  118. ; initialize start of auto-flask use
  119. ToolTip, UseFlasks On
  120.  
  121. ; reset usage timers for all flasks
  122. for i in FlaskDurationInit {
  123. FlaskLastUsed[i] := 0
  124. FlaskDuration[i] := FlaskDurationInit[i]
  125. }
  126. } else {
  127. ToolTip, UseFlasks Off
  128. }
  129. return
  130.  
  131. ;----------------------------------------------------------------------
  132. ; To use a different moust button (default is right click), change the
  133. ; "RButton" to:
  134. ; RButton - to use the {default} right mouse button
  135. ; MButton - to use the {default} middle mouse button (wheel)
  136. ; LButton - to use the {default} Left mouse button
  137. ;
  138. ; Make the change in both places, below (the first is click,
  139. ; 2nd is release of button}
  140. ;----------------------------------------------------------------------
  141. ~RButton::
  142. ; pass-thru and capture when the last attack (Right click) was done
  143. ; we also track if the mouse button is being held down for continuous attack(s) and/or channelling skills
  144. HoldRightClick := true
  145. LastRightClick := A_TickCount
  146. return
  147.  
  148. ~RButton up::
  149. ; pass-thru and release the right mouse button
  150. HoldRightClick := false
  151. return
  152.  
  153. ;----------------------------------------------------------------------
  154. ; The following 5 hotkeys allow for manual use of flasks while still
  155. ; tracking optimal recast times.
  156. ;----------------------------------------------------------------------
  157. ~1::
  158. ; pass-thru and start timer for flask 1
  159. FlaskLastUsed[1] := A_TickCount
  160. Random, VariableDelay, -99, 99
  161. FlaskDuration[1] := FlaskDurationInit[1] + VariableDelay ; randomize duration to simulate human
  162. return
  163.  
  164. ~2::
  165. ; pass-thru and start timer for flask 2
  166. FlaskLastUsed[2] := A_TickCount
  167. Random, VariableDelay, -99, 99
  168. FlaskDuration[2] := FlaskDurationInit[2] + VariableDelay ; randomize duration to simulate human
  169. return
  170.  
  171. ~3::
  172. ; pass-thru and start timer for flask 3
  173. FlaskLastUsed[3] := A_TickCount
  174. Random, VariableDelay, -99, 99
  175. FlaskDuration[3] := FlaskDurationInit[3] + VariableDelay ; randomize duration to simulate human
  176. return
  177.  
  178. ~4::
  179. ; pass-thru and start timer for flask 4
  180. FlaskLastUsed[4] := A_TickCount
  181. Random, VariableDelay, -99, 99
  182. FlaskDuration[4] := FlaskDurationInit[4] + VariableDelay ; randomize duration to simulate human
  183. return
  184.  
  185. ~5::
  186. ; pass-thru and start timer for flask 5
  187. FlaskLastUsed[5] := A_TickCount
  188. Random, VariableDelay, -99, 99
  189. FlaskDuration[5] := FlaskDurationInit[5] + VariableDelay ; randomize duration to simulate human
  190. return
  191.  
  192. ~r::
  193. ; pass-thru and start timer for flask 5
  194. FlaskLastUsed["r"] := A_TickCount
  195. Random, VariableDelay, -99, 99
  196. FlaskDuration[5] := FlaskDurationInit[5] + VariableDelay ; randomize duration to simulate human
  197. return
  198.  
  199. ~e::
  200. ; pass-thru and start timer for flask 5
  201. FlaskLastUsed["e"] := A_TickCount
  202. Random, VariableDelay, -99, 99
  203. FlaskDuration[5] := FlaskDurationInit[5] + VariableDelay ; randomize duration to simulate human
  204. return
  205.  
  206. ;----------------------------------------------------------------------
  207. ; Use all flasks, now. A variable delay is included between flasks
  208. ; NOTE: this will use all flasks, even those with a FlaskDurationInit of 0
  209. ;----------------------------------------------------------------------
  210. `::
  211. if UseFlasks {
  212. Send 1
  213. Random, VariableDelay, -99, 99
  214. Sleep, %VariableDelay%
  215. Send 2
  216. Random, VariableDelay, -99, 99
  217. Sleep, %VariableDelay%
  218. Send 3
  219. Random, VariableDelay, -99, 99
  220. Sleep, %VariableDelay%
  221. Send 4
  222. Random, VariableDelay, -99, 99
  223. Sleep, %VariableDelay%
  224. Send 5
  225. Random, VariableDelay, -99, 99
  226. Sleep, %VariableDelay%
  227. Send e
  228. Random, VariableDelay, -99, 99
  229. Sleep, %VariableDelay%
  230. Send r
  231. }
  232. return
  233.  
  234. CycleAllFlasksWhenReady:
  235. for flask, duration in FlaskDuration {
  236. ; skip flasks with 0 duration and skip flasks that are still active
  237. if ((duration > 0) & (duration < A_TickCount - FlaskLastUsed[flask])) {
  238. Send %flask%
  239. FlaskLastUsed[flask] := A_TickCount
  240. Random, VariableDelay, -99, 99
  241. FlaskDuration[flask] := FlaskDurationInit[flask] + VariableDelay ; randomize duration to simulate human
  242. sleep, %VariableDelay%
  243. }
  244. }
  245. return
  246.  
  247. ;----------------------------------------------------------------------
  248. ; Alt+c to Ctrl-Click every location in the (I)nventory screen.
  249. ;----------------------------------------------------------------------
  250. !c::
  251. Loop, 12 {
  252. col := ix + (A_Index - 1) * delta
  253. Loop, 5 {
  254. row := iy + (A_Index - 1) * delta
  255. Send ^{Click, %col%, %row%}
  256. }
  257. }
  258. return
  259.  
  260. ;----------------------------------------------------------------------
  261. ; Alt+m - Allow setting stash tab size as normal (12x12) or large (24x24)
  262. ;
  263. ; vMouseRow := 1 (default) means starting in row 1 of stash tab
  264. ; always place mouse pointer in starting box
  265. ;
  266. ; ItemsToMove := 50 (default) is how many items to move to Inventory
  267. ;----------------------------------------------------------------------
  268. !m::
  269. Gui, Add, Radio, vSelStash checked, Norm Stash Tab (12x12)
  270. Gui, Add, Radio,, Quad Stash Tab (24x24)
  271. Gui, Add, Text,, &Clicks:
  272. Gui, Add, Edit, w50
  273. Gui, Add, UpDown, vClicks Range1-50, 50
  274. Gui, Add, Text,, Mouse is in &Row:
  275. Gui, Add, Edit, w50
  276. Gui, Add, UpDown, vStartRow Range1-24, 1
  277. Gui, Add, Button, default, OK
  278. Gui, Show
  279. return
  280.  
  281. ButtonOK:
  282. GuiClose:
  283. GuiEscape:
  284. Gui, Submit ; Save each control's contents to its associated variable.
  285. MouseGetPos, x, y ; start from current mouse pos
  286. ClickCt := 0
  287. Loop {
  288. Send ^{Click, %x%, %y%}
  289. if (++ClickCt > StashSize[SelStash] - StartRow) {
  290. StartRow := 1
  291. x := x + StashD[SelStash]
  292. y := StashY[SelStash]
  293. ClickCt := 0
  294. } else {
  295. y := y + StashD[SelStash]
  296. }
  297. } until (--Clicks <= 0)
  298. Gui, Destroy
  299. return
  300.  
  301. ;----------------------------------------------------------------------
  302. ; Alt+g - Get the current screen coordinates of the mouse pointer.
  303. ;----------------------------------------------------------------------
  304. !g::
  305. MouseGetPos, x, y
  306. ToolTip, %x% %y%
  307. return
  308.  
  309. ;----------------------------------------------------------------------
  310. ; Alt+s - Swap a skill gem with an alternate. Gems must be same color if alt
  311. ; weapon slot is used for holding gems.
  312. ;----------------------------------------------------------------------
  313. !s::
  314. MouseGetPos, x, y ; Save the current mouse position
  315. Send i
  316. Sleep 100
  317. Send {Click Right, %PrimX%, %PrimY%}
  318. Sleep 100
  319. if (WeaponSwap) {
  320. Send {x}
  321. Sleep 100
  322. }
  323. Send {Click %AltX%, %AltY%}
  324. Sleep 100
  325. if (WeaponSwap) {
  326. Send {x}
  327. Sleep 100
  328. }
  329. Send {Click %PrimX%, %PrimY%}
  330. Sleep 100
  331. Send i
  332. Sleep 100
  333. MouseMove, x, y
  334. Return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement