Guest User

autopot.ahk

a guest
Nov 18th, 2018
312
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.55 KB | None | 0 0
  1. #NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
  2. ; #Warn ; Enable warnings to assist with detecting common errors.
  3. SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
  4. SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
  5.  
  6. #IfWinActive, Path of Exile ;check if a window with title "Path of Exile", casesensitive
  7.  
  8.  
  9. Menu, Tray, Icon, Images\Off.ico ;get a icon image
  10. Menu, Tray, Tip, Antyradio.pl ;tool tip when mouse over icon
  11. Menu, Tray, Add ;creates a separator line
  12. Menu, Tray, Add, Windowed (Borders), Border ; create a new menu item
  13. Menu, Tray, Add, Windowed (Borderless), Borderless
  14. Menu, Tray, Add, How To Use, HowToUse
  15.  
  16. ;load border information from ini file
  17. toggle = 0
  18. IniRead, bl, setting.ini, border, borderleft
  19. IniRead, br, setting.ini, border, borderright
  20. IniRead, bt, setting.ini, border, bordertop
  21. IniRead, bd, setting.ini, border, borderdown
  22. IniRead, bd, setting.ini, border, borderdown
  23.  
  24.  
  25. ;load potion information from ini file
  26.  
  27. ;high HP
  28. IniRead, usepotionhphigh, setting.ini, potion_high, hpremain
  29. IniRead, usepotionflaskindex1, setting.ini, potion_high, flask
  30.  
  31. ;low HP
  32. IniRead, usepotionhplow, setting.ini, potion_low, hpremain
  33. IniRead, usepotionflaskindex2, setting.ini, potion_low, flask
  34.  
  35.  
  36. ;load defensive potion information from ini file
  37. IniRead, usepotiondefensive, setting.ini, defensive_potion, hpremain
  38. IniRead, usedefensivepotionflaskindex, setting.ini, defensive_potion, flask
  39. IniRead, usedefcd, setting.ini, defensive_potion, defcd
  40.  
  41. ;load mana potion information from ini file
  42. IniRead, usepotionmp, setting.ini, mana_potion, mpremain
  43. IniRead, usemanapotionflaskindex, setting.ini, mana_potion, flask
  44.  
  45. ;load quicksilver potion information from ini file
  46. IniRead, usepotionquick, setting.ini, quicksilver, timeleft
  47. IniRead, usequickpotionflaskindex, setting.ini, quicksilver, flask
  48. IniRead, usequickcd, setting.ini, quicksilver, quickcd
  49.  
  50. ;load logout information from ini file
  51. IniRead, logouthp, setting.ini, logout, hpremain
  52. IniRead, logoutflaskindex, setting.ini, logout, flask
  53.  
  54. ;load anchor information from ini file
  55. IniRead, defaultLogoutX, setting.ini, anchor, logoutbtnx
  56. IniRead, defaultLogoutY, setting.ini, anchor, logoutbtny
  57.  
  58. IniRead, defaultWindowWidth, setting.ini, anchor, windoww
  59. IniRead, defaultWindowHeight, setting.ini, anchor, windowh
  60.  
  61. IniRead, defaultHPMiddleX, setting.ini, anchor, hpmiddlex
  62. IniRead, defaultHPMiddleY, setting.ini, anchor, hpmiddley
  63. IniRead, defaultHPTopY, setting.ini, anchor, hptopy
  64.  
  65. IniRead, defaultMPMiddleX, setting.ini, anchor, mpmiddlex
  66. IniRead, defaultMPMiddleY, setting.ini, anchor, mpmiddley
  67. IniRead, defaultMPTopY, setting.ini, anchor, mptopy
  68.  
  69. IniRead, defaultChatX, setting.ini, anchor, chaticonx
  70. IniRead, defaultChatY, setting.ini, anchor, chaticony
  71.  
  72. IniRead, defaultHideX, setting.ini, anchor, hideiconx
  73. IniRead, defaultHideY, setting.ini, anchor, hideicony
  74.  
  75. IniRead, defaultMovX, setting.ini, anchor, movposx
  76. IniRead, defaultMovY, setting.ini, anchor, movposy
  77.  
  78.  
  79.  
  80. ;load other information from ini file
  81. IniRead, mousespeed, setting.ini, other, mousespeed ;0~100(instant~slow)
  82. IniRead, checkdelay, setting.ini, other, checkdelay
  83.  
  84. ;HP-Potion
  85. defaultUsePotion1HPY := defaultHPTopY + (defaultWindowHeight-defaultHPTopY-bd) * (100-usepotionhphigh) / 100
  86.  
  87. defaultUsePotion2HPY := defaultHPTopY + (defaultWindowHeight-defaultHPTopY-bd) * (100-usepotionhplow) / 100
  88.  
  89. ;Def-Potion
  90. defaultUseDefensivePotionHPY := defaultHPTopY + (defaultWindowHeight-defaultHPTopY-bd) * (100-usepotiondefensive) / 100
  91.  
  92. ;MP-Potion
  93. defaultUseManaPotionMPY := defaultMPTopY + (defaultWindowHeight-defaultMPTopY-bd) * (100-usepotionmp) / 100
  94.  
  95. defaultLogoutHPY := defaultHPTopY + (defaultWindowHeight-defaultHPTopY-bd) * (100-logouthp) / 100
  96.  
  97. adjustLogout_X := 0
  98. adjustLogout_Y := 0
  99. return
  100.  
  101.  
  102. ;debug
  103. `::
  104. MouseGetPos, xpos, ypos
  105. MsgBox, The cursor is at X%xpos% Y%ypos%.
  106. return
  107.  
  108.  
  109. ;`::
  110. ;run, cports.exe /close * * * * PathofExile_x64.exe
  111. ;return
  112.  
  113. F3::
  114. WinGetPos,,, w, h, A
  115. heightResizeRatio := (h-bt-bd)/(defaultWindowHeight-bt-bd)
  116. ; calculate log out button position
  117. if (adjustLogout_X == 0 && adjustLogout_Y == 0)
  118. {
  119. adjustLogout_X := w/2
  120. ;adjustLogout_Y := (defaultLogoutY-bt)*heightResizeRatio+bt
  121. adjustLogout_Y := defaultLogoutY
  122. }
  123.  
  124. ; calculate HP center position and chat icon position
  125. HX := defaultHPMiddleX
  126. HY := defaultHPMiddleY
  127. MX := defaultMPMiddleX
  128. MY := defaultMPMiddleY
  129. CX := defaultChatX
  130. CY := defaultChatY
  131. HIX:= defaultHideX
  132. HIY:= defaultHideY
  133. MOX:= defaultMovX
  134. MOY:= defaultMovY
  135.  
  136.  
  137. ;use this to check if the position is correct
  138. MouseMove HX, HY
  139. ;MouseMove MX, MY
  140. ;MouseMove CX, CY
  141.  
  142. ; calculate use potion and logout HP Y
  143. adjustUsePotion1HPY := defaultUsePotion1HPY
  144. adjustUsePotion2HPY := defaultUsePotion2HPY
  145. adjustUseDefensivePotionHPY := defaultUseDefensivePotionHPY
  146. adjustUseManaPotionMPY := defaultUseManaPotionMPY
  147. adjustLogoutHPY := defaultLogoutHPY
  148.  
  149. ;use this to check if the position is correct
  150. ;MouseMove HX, adjustUsePotion1HPY
  151. ;MouseMove HX, adjustUsePotion2HPY
  152. ;MouseMove HX, adjustUseDefensivePotionHPY
  153. MouseMove MX, adjustUseManaPotionMPY
  154. ;MouseMove HX, adjustLogoutHPY
  155.  
  156.  
  157. ;calculate chat icon search region, top left:(chatX1, chatY1), buttom right:(chatX2, chatY2)
  158. chatX1 := CX-7
  159. chatX2 := CX+7
  160. chatY1 := CY-7
  161. chatY2 := CY+7
  162.  
  163. ;calculate hideout icon search region, top left:(hiX1, hiY1), buttom right:(hiX2, hiY2)
  164. hiX1 := HIX
  165. hiX2 := HIX
  166. hiY1 := HIY
  167. hiY2 := HIY
  168.  
  169. ;calculate use potion hp search region, top left:(hp1_X1, hp1_Y1), buttom right:(hp1_X2, hp1_Y2)
  170. hp1_X1 := HX-7
  171. hp1_X2 := HX+7
  172. hp1_Y1 := adjustUsePotion1HPY-7
  173. hp1_Y2 := adjustUsePotion1HPY+7
  174. hp5_Y1 := adjustUsePotion2HPY-7
  175. hp5_Y2 := adjustUsePotion2HPY+7
  176.  
  177.  
  178. ;calculate use defensive potion hp search region, top left:(hp3_X1, hp3_Y1), buttom right:(hp3_X2, hp3_Y2)
  179. hp3_X1 := HX-7
  180. hp3_X2 := HX+7
  181. hp3_Y1 := adjustUseDefensivePotionHPY-7
  182. hp3_Y2 := adjustUseDefensivePotionHPY+7
  183.  
  184. ;calculate use mana potion mp search region, top left:(mp1_X1, mp1_Y1), buttom right:(mp1_X2, mp1_Y2)
  185. mp1_X1 := MX-7
  186. mp1_X2 := MX+7
  187. mp1_Y1 := adjustUseManaPotionMPY-7
  188. mp1_Y2 := adjustUseManaPotionMPY+7
  189.  
  190. ;calculate log out hp search region, top left:(hp2_X1, hp2_Y1), buttom right:(hp2_X2, hp2_Y2)
  191. hp2_X1 := HX-7
  192. hp2_X2 := HX+7
  193. hp2_Y1 := adjustLogoutHPY-7
  194. hp2_Y2 := adjustLogoutHPY+7
  195.  
  196. ;calculate movearea search region, top left:(movX1, movY1), buttom right:(movX2, movY2)
  197. movX1 := MOX
  198. movX2 := MOX
  199. movY1 := MOY
  200. movY2 := MOY
  201.  
  202. ;get hp center color and chat icon color used for pixel search later
  203. PixelGetColor, hpcolor1 , %HX%, %adjustUsePotion1HPY% ; get color GRB
  204. PixelGetColor, hpcolor1rgb , %HX%, %adjustUsePotion1HPY%, RGB ; get color RGB
  205.  
  206. PixelGetColor, hpcolor5 , %HX%, %adjustUsePotion2HPY% ; get color GRB
  207. PixelGetColor, hpcolor5rgb , %HX%, %adjustUsePotion2HPY%, RGB ; get color RGB
  208.  
  209. PixelGetColor, hpcolor2 , %HX%, %adjustLogoutHPY% ; get color GRB
  210. PixelGetColor, hpcolor2rgb , %HX%, %adjustLogoutHPY%, RGB ; get color RGB
  211.  
  212. PixelGetColor, hpcolor3 , %HX%, %adjustUseDefensivePotionHPY% ; get color GRB
  213. PixelGetColor, hpcolor3rgb , %HX%, %adjustUseDefensivePotionHPY%, RGB ; get color RGB
  214.  
  215. PixelGetColor, mpcolor1 , %MX%, %adjustUseManaPotionMPY% ; get color GRB
  216. PixelGetColor, mpcolor1rgb , %MX%, %adjustUseManaPotionMPY%, RGB ; get color RGB
  217.  
  218. PixelGetColor, chaticoncolor , %CX%, %CY%
  219. PixelGetColor, chaticoncolorrgb , %CX%, %CY%, RGB
  220.  
  221. PixelGetColor, HOcolor , %HIX%, %HIY%
  222. PixelGetColor, HOcolorrgb , %HIX%, %HIY%, RGB
  223.  
  224. ;HOcolor:= put here your Pixelcolor
  225. ;HOcolorrgb := put here your RGB Pixelcolor
  226.  
  227. PixelGetColor, MoveColor , %MOX%, %MOY%
  228. PixelGetColor, MoveColorrgb , %MOX%, %MOY%, RGB
  229.  
  230.  
  231.  
  232. ;pop up a gui showing the finding color for user to double check
  233. gui, new
  234. gui, Default
  235. gui, +LastFound ; make the GUI window the last found window for use by the line below.
  236. gui, add, groupbox, w205 h200, Colors found:
  237. gui, add, text, yp+25 xp+10, Chat Icon Color:
  238. gui, add, Progress, xp+80 yp-5 w100 h20 c%chaticoncolorrgb%,100
  239. gui, add, text, yp+25 xp-80, HP-High Potion:
  240. gui, add, Progress, xp+80 yp-5 w100 h20 c%hpcolor1rgb%,100
  241. gui, add, text, yp+25 xp-80, HP-Low Potion:
  242. gui, add, Progress, xp+80 yp-5 w100 h20 c%hpcolor5rgb%,100
  243. gui, add, text, yp+25 xp-80, Logout Color:
  244. gui, add, Progress, xp+80 yp-5 w100 h20 c%hpcolor2rgb%,100
  245. gui, add, text, yp+25 xp-80, Def. Potion Color:
  246. gui, add, Progress, xp+80 yp-5 w100 h20 c%hpcolor3rgb%,100
  247. gui, add, text, yp+25 xp-80, Mana Color:
  248. gui, add, Progress, xp+80 yp-5 w100 h20 c%mpcolor1rgb%,100
  249. gui, add, button, xp-80 yp+25 w25 h25 gDone, OK
  250. gui, show, ,Activated
  251. Menu, Tray, Icon, Images\On.ico
  252.  
  253.  
  254. ; Functions
  255. RandomSleep(min,max){
  256. Random, r, %min%, %max%
  257. r:=floor(r/Speed)
  258. Sleep %r%
  259. return
  260. }
  261.  
  262. AutoClicks(){
  263. BlockInput On
  264. Send {blind}{Lbutton down}{Lbutton up}
  265. BlockInput Off
  266. }
  267.  
  268.  
  269. ;start searching (render a frame takes 0.03 sec in 30FPS, so we set the search time to 0.1 sec to make sure it won't search the same frame twice)
  270. Loop
  271. {
  272. IfWinActive, Path of Exile
  273. {
  274. ;find the orange chat Icon (makes sure you are on a character)
  275. ;variable ErrorLevel is set to 0 if the color was found in the specified region, 1 if it was not found,
  276. ; or 2 if there was a problem that prevented the command from conducting the search.
  277. PixelSearch, FoundoX, FoundoY, %chatX1%, %chatY1%, %chatX2%, %chatY2%, %chaticoncolor%, 5, Fast
  278. if ErrorLevel = 0
  279. {
  280. ;use potion when HP-High reaches the ratio user set
  281. PixelSearch, FoundhX, FoundhY, %hp1_X1%, %hp1_Y1%, %hp1_X2%, %hp1_Y2%, %hpcolor1%, 5, Fast
  282. if ErrorLevel = 1
  283. {
  284. SendInput, %usepotionflaskindex1%
  285. RandomSleep(89,128)
  286. }
  287.  
  288. ;use potion when HP-Low reaches the ratio user set
  289. PixelSearch, FoundhX, FoundhY, %hp1_X1%, %hp5_Y1%, %hp1_X2%, %hp5_Y2%, %hpcolor5%, 5, Fast
  290. if ErrorLevel = 1
  291. {
  292. SendInput, %usepotionflaskindex2%
  293. RandomSleep(89,128)
  294. }
  295.  
  296. ;use defensive potion when HP reaches the ratio user set
  297. PixelSearch, FoundhX, FoundhY, %hp3_X1%, %hp3_Y1%, %hp3_X2%, %hp3_Y2%, %hpcolor3%, 5, Fast
  298. if ErrorLevel = 1
  299. {
  300. if (A_TickCount > defcdnext)
  301. {
  302. SendInput, %usedefensivepotionflaskindex%
  303. defcdnext:= A_TickCount + usedefcd - 200
  304. }
  305. }
  306.  
  307. ;use mana potion when MP reaches the ratio user set
  308. PixelSearch, FoundhX, FoundhY, %mp1_X1%, %mp1_Y1%, %mp1_X2%, %mp1_Y2%, %mpcolor1%, 5, Fast
  309. if ErrorLevel = 1
  310. {
  311. SendInput, %usemanapotionflaskindex%
  312. RandomSleep(89,128)
  313. }
  314.  
  315.  
  316. ;Quicksilver
  317. PixelSearch, FoundhX, FoundhY, %hiX1%, %hiY1%, %hiX2%, %hiY2%, %HOcolor%, 1, Fast
  318. if ErrorLevel = 1
  319. {
  320. if (A_TickCount > tlast)
  321. {
  322. PixelSearch, FoundhX, FoundhY, %movX1%, %movY1%, %movX2%, %movY2%,%MoveColor%, 10, Fast
  323. if ErrorLevel = 1
  324. {
  325. PixelGetColor, MoveColor , %MOX%, %MOY%
  326. PixelGetColor, MoveColorrgb , %MOX%, %MOY%, RGB
  327. tlast:= A_TickCount
  328. RandomSleep(89,128)
  329. PixelSearch, FoundhX, FoundhY, %movX1%, %movY1%, %movX2%, %movY2%, %MoveColor%, 10, Fast
  330. if ErrorLevel = 1
  331. {
  332. SendInput, %usequickpotionflaskindex%
  333. tlast := (A_TickCount + usequickcd - 100)
  334. Goto, JumpToEnd
  335. }
  336. tlast:= A_TickCount + usepotionquick
  337. PixelGetColor, MoveColor , %MOX%, %MOY%
  338. PixelGetColor, MoveColorrgb , %MOX%, %MOY%, RGB
  339. JumpToEnd:
  340. }
  341. }
  342. }
  343.  
  344. ;log out when HP reaches the ratio user set
  345. PixelSearch, FoundhX, FoundhY, %hp2_X1%, %hp2_Y1%, %hp2_X2%, %hp2_Y2%, %hpcolor2%, 5, Fast
  346. if ErrorLevel = 1
  347. {
  348. SendInput, %logoutflaskindex%
  349. RandomSleep(89,128)
  350. ; run, cports.exe /close * * * * PathofExile_x64.exe
  351. }
  352.  
  353. }
  354. }
  355. Sleep, checkdelay
  356. }
  357. return
  358.  
  359. Border:
  360. MsgBox, Windowed (Borders all around)
  361. ;For Windowed (with Borders all round)
  362. bl = 0
  363. br = 0
  364. bt = 29
  365. bd = 0
  366. IniWrite, %bl%, setting.ini, border, borderleft
  367. IniWrite, %br%, setting.ini, border, borderright
  368. IniWrite, %bt%, setting.ini, border, bordertop
  369. IniWrite, %bd%, setting.ini, border, borderdown1212
  370. return
  371.  
  372. Borderless:
  373. MsgBox, Borderless (No Borders)
  374. ;For Fullscreen Borderless
  375. bl = 0
  376. br = 0
  377. bt = 0
  378. bd = 0
  379. IniWrite, %bl%, setting.ini, border, borderleft
  380. IniWrite, %br%, setting.ini, border, borderright
  381. IniWrite, %bt%, setting.ini, border, bordertop
  382. IniWrite, %bd%, setting.ini, border, borderdown
  383. return
  384.  
  385. Done:
  386. gui, submit, nohide
  387. gui, destroy
  388. return
  389.  
  390. HowToUse:
  391. MsgBox, `: Instant Logout`nF3: Activate`nF4: Reload`nF12: Exit`nCtrl+X: resync
  392. return
  393.  
  394. ^x::
  395. SendInput, {Enter}
  396. sleep, 20
  397. SendInput, {/}oos
  398. SendInput, {Enter}
  399. return
  400.  
  401. F4::Reload
  402. F12::ExitApp
  403.  
  404. ;debug
  405. ~::
  406. MouseGetPos, xpos, ypos
  407. MsgBox, The cursor is at X%xpos% Y%ypos%.
  408. return
  409.  
  410. ; KEY Binding
  411. ; Legend: ! = Alt ^ = Ctrl + = Shift
  412. ; -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  413. !WheelDown::Send {Right} ; ALT+WheelDown: Stash scroll
  414. return
  415. !WheelUp::Send {Left} ; ALT+WheelUp: Stash scroll
  416. return
  417. ^WheelDown::AutoClicks() ; CTRL+WheelDown -> Spam CTRL+CLICK
  418. return
  419. +WheelDown::AutoClicks() ; SHIFT+WheelDown -> Spam SHIFT+CLICK
  420. return
  421. ; -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  422. $!H::Send {Enter} /hideout {Enter} ; ALT+H
  423. return
  424. $!R::Send {Enter} /remaining {Enter} ; ALT+R
  425. return
Advertisement
Add Comment
Please, Sign In to add comment