unsane

twitch.tv/unsane - Path of Exile Macros - 3.1 Abyss

Dec 8th, 2017
359
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.48 KB | None | 0 0
  1. ; twitch.tv/unsane
  2. ; Updated for 3.1 Abyss.
  3. ; Copy and paste this text into unsane.ahk. POE-TradeMacro is required: https://github.com/PoE-TradeMacro/POE-TradeMacro/releases. Put unsane.ahk (and cports.exe) in the root folder of POE-TradeMacro, and launch ONLY unsane.ahk to launch everything (PoE, POE-TradeMacro, the macros in this file, POELadder, poe-racing ladder).
  4. ; This is my personal file with a bunch of custom stuff tailored to my setup. You will need to go through and edit file locations, screen coordinates, and preferred shortcut keys.
  5.  
  6. #NoEnv ; good to use until it's default in ahkV2
  7. #SingleInstance force
  8. #Persistent ; Stay open in background
  9. SendMode Input
  10.  
  11. full_command_line := DllCall("GetCommandLine", "str")
  12. if not (A_IsAdmin or RegExMatch(full_command_line, " /restart(?!\S)")) {
  13. try {
  14. Run *RunAs "%A_AhkPath%" /restart "%A_ScriptFullPath%"
  15. }
  16. ExitApp
  17. }
  18.  
  19. ; The following is borrowed from the lutbot macro. See http://lutbot.com
  20. GetTable := DllCall("GetProcAddress", Ptr, DllCall("LoadLibrary", Str, "Iphlpapi.dll", "Ptr"), Astr, "GetExtendedTcpTable", "Ptr")
  21. SetEntry := DllCall("GetProcAddress", Ptr, DllCall("LoadLibrary", Str, "Iphlpapi.dll", "Ptr"), Astr, "SetTcpEntry", "Ptr")
  22. EnumProcesses := DllCall("GetProcAddress", Ptr, DllCall("LoadLibrary", Str, "Psapi.dll", "Ptr"), Astr, "EnumProcesses", "Ptr")
  23. preloadPsapi := DllCall("LoadLibrary", "Str", "Psapi.dll", "Ptr")
  24. OpenProcessToken := DllCall("GetProcAddress", Ptr, DllCall("LoadLibrary", Str, "Advapi32.dll", "Ptr"), Astr, "OpenProcessToken", "Ptr")
  25. LookupPrivilegeValue := DllCall("GetProcAddress", Ptr, DllCall("LoadLibrary", Str, "Advapi32.dll", "Ptr"), Astr, "LookupPrivilegeValue", "Ptr")
  26. AdjustTokenPrivileges := DllCall("GetProcAddress", Ptr, DllCall("LoadLibrary", Str, "Advapi32.dll", "Ptr"), Astr, "AdjustTokenPrivileges", "Ptr")
  27.  
  28. global dndOn := false
  29. global isActivePoeLadder := 0
  30. global isActivePoeRacing := 0
  31. ; Put the event name and your char name here. Can get event at http://poe-racing.com etc.
  32. global URL = "http://poe-racing.com/?event=10 Day Mayhem HC (ORE005)&name=unsaneTakeTwo&size=1"
  33. global WB
  34.  
  35. OnExit("Cleanup")
  36.  
  37. ; This timer is used to check whether PoE is open, every 60 seconds. If it's not it closes the macros and POELadder.
  38. SetTimer process_watcher, 60000
  39.  
  40. Process Exist, PathOfExile_x64.exe
  41. If ErrorLevel = 0
  42. {
  43. Process Exist, PathOfExile.exe
  44. If ErrorLevel = 0
  45. {
  46. ;--noasync (iirc preloads assets when zoning in rather than on the fly) --waitforpreload
  47. Run cmd.exe /c start "" /high /d "C:\Program Files (x86)\Path of Exile" "C:\Program Files (x86)\Path of Exile\Client.exe"
  48. }
  49. }
  50.  
  51. ; The following is to launch POE-TradeMacro, which i run in parallel.
  52. Run %A_ScriptDir%\Run_TradeMacro.ahk -nosplash
  53.  
  54. ; launch these manually. can make automatic here if i'm on a long-term character:
  55. TogglePoeLadder()
  56. ;TogglePoeRacing()
  57.  
  58.  
  59. ; disable click-dragging live POELadder
  60. $LButton::
  61. if(!isActivePoeLadder) {
  62. Send {LButton Down}
  63. KeyWait LButton
  64. Send {LButton Up}
  65. }
  66. else {
  67. MouseGetPos, , , Win
  68. WinGetTitle, Title, ahk_id %Win%
  69. if(Title!="Path of Exile Ladder") {
  70. Send {LButton Down}
  71. KeyWait LButton
  72. Send {LButton Up}
  73. }
  74. else {
  75. WinGetPos, , , , Height, Path of Exile Ladder ; input window: 279, fetching window: 120
  76. if(Height > 200) {
  77. Send {LButton Down}
  78. KeyWait LButton
  79. Send {LButton Up}
  80. }
  81. ;else
  82. ;disabled the click
  83. }
  84. }
  85. return
  86.  
  87.  
  88. ; Check every 60 seconds whether PoE is closed, if yes, close POELadder and macro processes
  89. process_watcher:
  90. Process Exist, PathOfExile.exe
  91. If ErrorLevel = 0
  92. {
  93. Process Exist, PathOfExile_x64.exe
  94. If ErrorLevel = 0
  95. {
  96. IfWinExist, Path of Exile Ladder
  97. WinClose
  98.  
  99. ; Run,%ComSpec% /c Taskkill -f -im autohotkey.exe,%A_ScriptDir%,Hide
  100. DetectHiddenWindows, On
  101. WinGet, List, List, ahk_class AutoHotkey
  102.  
  103. Loop %List% {
  104. WinGet, PID, PID, % "ahk_id " List%A_Index%
  105. If ( PID <> DllCall("GetCurrentProcessId") )
  106. PostMessage,0x111,65405,0,, % "ahk_id " List%A_Index%
  107. }
  108.  
  109. SetTitleMatchMode 1
  110. Exitapp
  111. }
  112. }
  113. return
  114.  
  115. ; hotkey command list:
  116.  
  117. F4::FastLogOut() ; keep this outside #ifwinactive so it's active everywhere in case of popups
  118.  
  119. #IfWinActive Path of Exile ahk_class POEWindowClass
  120. !Enter::return ; block alt+enter key combinations from going to/alternating windowed/fullscreen
  121. !NumpadEnter::return ; block alt+enter key combinations from going to/alternating windowed/fullscreen
  122. #=::return ; block winkey+= magnifier
  123. #NumpadAdd::return ; block winkey++ magnifier
  124. ;CapsLock::` ; reassign capslock for use with discord push-to-talk
  125. ;#L::return ; block winkey+L (didn't work as is)
  126.  
  127. ^+p::TogglePoeRacing() ; ctrl+shift+p Toggle the poe-racing ladder display on/off. Use when placed #1-2500.
  128. ^+o::TogglePoeLadder() ; ctrl+shift+o Toggle the poe-ladder display on/off. Use when placed #2501-15000.
  129.  
  130. ;F1 = fps ; in-game shortcut
  131. F2::Hideout()
  132. F3::Ignore()
  133. F5::AfterMap()
  134. F6::Played()
  135. ;F7::Whois() ; probly dont need this anymore now that ctrl+alt+r. first candidate for deletion. commented out, see if i miss it
  136. F7::InviteX()
  137. F8::Invite()
  138. F9::DND()
  139. F10::Ladder()
  140. ;F11 = screenshot ; in-game shortcut
  141. F12::CommandList()
  142. ;ctrl+c POE-TradeMacro: See item info (via PoE-ItemInfo).
  143. ;ctrl+alt+c POE-TradeMacro AdditionalMacro: Opens an item on pathof.info for an advanced affix breakdown
  144. ;ctrl+d POE-TradeMacro: Search item on poe.trade.
  145. ;ctrl+alt+d POE-TradeMacro: Advanced item search for uniques.
  146. ;ctrl+e POE-TradeMacro: Show item age (own listed items).
  147. ;ctrl+f POE-TradeMacro AdditionalMacro: Fills stash/vendor search with itemname/info you're hovering
  148. ;ctrl+alt+f POE-TradeMacro AdditionalMacro: Much broader search terms
  149. ;ctrl+i POE-TradeMacro: Opens a text input where you can type an item name to search for.
  150. ;ctrl+l POE-TradeMacro: Change league.
  151. ;ctrl+m POE-TradeMacro AdditionalMacro: Open poeaffix.net w/ item you're hovering
  152. ;ctrl+q POE-TradeMacro: Open the item search on poe.trade instead of showing a tooltip with results.
  153. ;ctrl+alt+r POE-TradeMacro AdditionalMacro: Sends "/whois lastWhisperCharacterName".
  154. ;ctrl+w POE-TradeMacro: Open the items wiki page.
  155. ;alt-1 [old, not yet reimplemented] "BEARERS BEARERS BEARERS!!!"
  156. ;alt-2 [old, not yet reimplemented] "Watch for corrupting blood!"
  157. ;alt-3 [old, not yet reimplemented] "Dangerous exile!"
  158. ;zzz
  159. !1::Send {Enter}/invite Wakazashi{Enter} ; CT
  160. !2::Send {Enter}/invite DawnSunderer{Enter} ; SB
  161. !3::Send {Enter}/invite IamBitter{Enter} ; RK
  162. !4::Send {Enter}/invite QueueQueue_EDMoM{Enter} ; TM
  163. !5::Send {Enter}/invite rexiwexid{Enter} ; W
  164.  
  165. ; The below overrides the normal PoE scrollwheel behavior. To temporarily use normal behavior, hold ctrl, alt or shift.
  166. WheelUp::SendInput {Left} ;mouse wheel up toggles stash tabs left
  167. WheelDown::SendInput {Right} ;mouse wheel down toggles stash tabs right
  168.  
  169.  
  170.  
  171. ; The following is to launch and set up POELadder, which i run in parallel. Launch it, click start, and move it. Download https://github.com/CNParent/poe-ladder/releases and put it somewhere.
  172. TogglePoeLadder() {
  173. if !isActivePoeLadder {
  174. isActivePoeLadder := true
  175. Run cmd.exe /c start "" /high /d "C:\Program Files (no registry)\poe-ladder-win32-x64" "C:\Program Files (no registry)\poe-ladder-win32-x64\poe-ladder.exe"
  176. Sleep, 15000 ; was 20000+7000
  177. BlockInput On
  178. WinActivate Path of Exile Ladder
  179. Click 50, 125 ; Click Start on it
  180. BlockInput Off
  181. ; WinActivate, Path of Exile ahk_class POEWindowClass
  182. Sleep, 3000 ; was 7000
  183. ;orig/old WinMove, Path of Exile Ladder, , 755, 670 ; Move it to where i want it
  184. ; base window is 200x60 (poe-racing is 170x62)
  185. WinMove, Path of Exile Ladder, , 775, 661 ; Move it to where i want it
  186. }
  187. else {
  188. isActivePoeLadder := false
  189. IfWinExist, Path of Exile Ladder
  190. WinClose
  191. }
  192. return
  193. }
  194.  
  195.  
  196.  
  197. class WB_events {
  198. NavigateComplete2(wb, NewURL) {
  199. GuiControl,, URL, %URL%
  200. }
  201. }
  202.  
  203. TogglePoeRacing() {
  204. if !isActivePoeRacing {
  205. isActivePoeRacing := true
  206. Gui +LastFound +AlwaysOnTop -Caption -Border +ToolWindow +E0x20
  207. Gui, Color, FFFFFF
  208. Gui, Margin, 0, 0
  209. ;orig/old Gui Add, ActiveX, w170 h62 x0 y0 vWB, %URL%
  210. Gui Add, ActiveX, w200 h62 x0 y0 vWB, %URL%
  211. WinSet, TransColor, FFFFFF 200 ; Change 200 to a lower value if you want the tracker to be more transparent.
  212. ComObjConnect(WB, WB_events)
  213. ;orig/old Gui Show, x755 y670 NoActivate, Tracker
  214. Gui Show, x775 y660 NoActivate, Tracker
  215. WinSet AlwaysOnTop, On
  216. WB.Navigate(URL)
  217. }
  218. else {
  219. isActivePoeRacing := false
  220. Gui, Destroy
  221. }
  222. return
  223. }
  224.  
  225.  
  226.  
  227. AfterMap() {
  228. if WinActive("Path of Exile ahk_class POEWindowClass")
  229. {
  230. BlockInput On
  231. Send ^{Enter}After map. Negotiate/invite you at that time?{Enter}
  232. ; Send ^{Enter}After map. Am i not in a map? Then i'm busy and not trading.{Enter}
  233. ; Send ^{Enter}Speed levelling. 5c sale minimum.{Enter}
  234. BlockInput Off
  235. }
  236. return
  237. }
  238.  
  239.  
  240.  
  241. FastLogOut() {
  242. Critical
  243. Process Exist, PathOfExile.exe
  244. If ErrorLevel
  245. {
  246. ; Ensure you have cports.exe in the root POE-TradeMacro folder http://www.nirsoft.net/utils/cports.html
  247. Run, cports.exe /close * * * * PathOfExile.exe
  248. }
  249. Else
  250. {
  251. Process Exist, PathOfExile_x64.exe
  252. If ErrorLevel
  253. {
  254. ; The following is borrowed from the lutbot macro. See http://lutbot.com
  255. succ := logout("PathOfExile_x64.exe")
  256. if (succ == 0) {
  257. newSucc := logout("PathOfExile.exe")
  258. }
  259. }
  260. }
  261. return
  262. }
  263.  
  264.  
  265.  
  266. ; The following is borrowed from the lutbot macro. See http://lutbot.com
  267. logout(executable) {
  268. global GetTable, SetEntry, EnumProcesses, OpenProcessToken, LookupPrivilegeValue, AdjustTokenPrivileges, loadedPsapi
  269. Critical
  270.  
  271. poePID := Object()
  272. s := 4096
  273. Process, Exist
  274. h := DllCall("OpenProcess", "UInt", 0x0400, "Int", false, "UInt", ErrorLevel, "Ptr")
  275.  
  276. DllCall(OpenProcessToken, "Ptr", h, "UInt", 32, "PtrP", t)
  277. VarSetCapacity(ti, 16, 0)
  278. NumPut(1, ti, 0, "UInt")
  279.  
  280. DllCall(LookupPrivilegeValue, "Ptr", 0, "Str", "SeDebugPrivilege", "Int64P", luid)
  281. NumPut(luid, ti, 4, "Int64")
  282. NumPut(2, ti, 12, "UInt")
  283.  
  284. r := DllCall(AdjustTokenPrivileges, "Ptr", t, "Int", false, "Ptr", &ti, "UInt", 0, "Ptr", 0, "Ptr", 0)
  285. DllCall("CloseHandle", "Ptr", t)
  286. DllCall("CloseHandle", "Ptr", h)
  287.  
  288. s := VarSetCapacity(a, s)
  289. c := 0
  290. DllCall(EnumProcesses, "Ptr", &a, "UInt", s, "UIntP", r)
  291. Loop, % r // 4
  292. {
  293. id := NumGet(a, A_Index * 4, "UInt")
  294.  
  295. h := DllCall("OpenProcess", "UInt", 0x0010 | 0x0400, "Int", false, "UInt", id, "Ptr")
  296.  
  297. if !h
  298. continue
  299. VarSetCapacity(n, s, 0)
  300. e := DllCall("Psapi\GetModuleBaseName", "Ptr", h, "Ptr", 0, "Str", n, "UInt", A_IsUnicode ? s//2 : s)
  301. if !e
  302. if e := DllCall("Psapi\GetProcessImageFileName", "Ptr", h, "Str", n, "UInt", A_IsUnicode ? s//2 : s)
  303. SplitPath n, n
  304. DllCall("CloseHandle", "Ptr", h)
  305. if (n && e)
  306. if (n == executable) {
  307. poePID.Insert(id)
  308. }
  309. }
  310.  
  311. l := poePID.Length()
  312. if ( l = 0 ) {
  313. Process, wait, %executable%, 0.2
  314. if ( ErrorLevel > 0 ) {
  315. poePID.Insert(ErrorLevel)
  316. }
  317. }
  318.  
  319. VarSetCapacity(dwSize, 4, 0)
  320. result := DllCall(GetTable, UInt, &TcpTable, UInt, &dwSize, UInt, 0, UInt, 2, UInt, 5, UInt, 0)
  321. VarSetCapacity(TcpTable, NumGet(dwSize), 0)
  322.  
  323. result := DllCall(GetTable, UInt, &TcpTable, UInt, &dwSize, UInt, 0, UInt, 2, UInt, 5, UInt, 0)
  324.  
  325. num := NumGet(&TcpTable,0,"UInt")
  326.  
  327. out := 0
  328. Loop %num%
  329. {
  330. cutby := a_index - 1
  331. cutby *= 24
  332. ownerPID := NumGet(&TcpTable,cutby+24,"UInt")
  333. for index, element in poePID {
  334. if ( ownerPID = element )
  335. {
  336. VarSetCapacity(newEntry, 20, 0)
  337. NumPut(12,&newEntry,0,"UInt")
  338. NumPut(NumGet(&TcpTable,cutby+8,"UInt"),&newEntry,4,"UInt")
  339. NumPut(NumGet(&TcpTable,cutby+12,"UInt"),&newEntry,8,"UInt")
  340. NumPut(NumGet(&TcpTable,cutby+16,"UInt"),&newEntry,12,"UInt")
  341. NumPut(NumGet(&TcpTable,cutby+20,"UInt"),&newEntry,16,"UInt")
  342. result := DllCall(SetEntry, UInt, &newEntry)
  343. out++
  344. }
  345. }
  346. }
  347.  
  348. return True
  349. }
  350.  
  351.  
  352.  
  353. Played() {
  354. if WinActive("Path of Exile ahk_class POEWindowClass")
  355. {
  356. BlockInput On
  357. Send {Enter}/played{Enter}
  358. BlockInput Off
  359. }
  360. return
  361. }
  362.  
  363.  
  364.  
  365. Ladder() {
  366. if WinActive("Path of Exile ahk_class POEWindowClass")
  367. {
  368. BlockInput On
  369. Send {Enter}/ladder{Enter}
  370. BlockInput Off
  371. }
  372. return
  373. }
  374.  
  375.  
  376.  
  377. Invite() {
  378. if WinActive("Path of Exile ahk_class POEWindowClass")
  379. {
  380. BlockInput On
  381. Send ^{Enter}{Home}{Delete}/invite {Enter}
  382. BlockInput Off
  383. }
  384. return
  385. }
  386.  
  387.  
  388.  
  389. InviteX() {
  390. if WinActive("Path of Exile ahk_class POEWindowClass")
  391. {
  392. BlockInput On
  393. ;zzz
  394. Send {Enter}/invite WakaOctoCurse{Enter}
  395. Send {Enter}/invite WakaOcto{Enter}
  396. BlockInput Off
  397. }
  398. return
  399. }
  400.  
  401.  
  402.  
  403. Whois() {
  404. if WinActive("Path of Exile ahk_class POEWindowClass")
  405. {
  406. BlockInput On
  407. Send {Enter}/whois %Clipboard%{Enter}
  408. BlockInput Off
  409. }
  410. return
  411. }
  412.  
  413.  
  414.  
  415. DND() {
  416. if WinActive("Path of Exile ahk_class POEWindowClass")
  417. {
  418. BlockInput On
  419. if (dndOn)
  420. Send {Enter}/dnd{Enter}
  421. else
  422. Send {Enter}/dnd Lab/racing/busy. /whois me and try again shortly.{Enter}
  423. BlockInput Off
  424. dndOn := !dndOn
  425. }
  426. return
  427. }
  428.  
  429.  
  430.  
  431. Hideout() {
  432. if WinActive("Path of Exile ahk_class POEWindowClass")
  433. {
  434. BlockInput On
  435. Send {Enter}/hideout{Enter}
  436. BlockInput Off
  437. }
  438. return
  439. }
  440.  
  441.  
  442.  
  443. Clear() {
  444. if WinActive("Path of Exile ahk_class POEWindowClass")
  445. {
  446. BlockInput On
  447. Send {Enter}/clear{Enter}
  448. BlockInput Off
  449. }
  450. return
  451. }
  452.  
  453.  
  454.  
  455. Ignore() {
  456. if WinActive("Path of Exile ahk_class POEWindowClass")
  457. {
  458. BlockInput On
  459. Send ^{Enter}{Home}{Delete}/ignore {Enter}
  460. BlockInput Off
  461. }
  462. return
  463. }
  464.  
  465.  
  466.  
  467. CommandList() {
  468. if WinActive("Path of Exile ahk_class POEWindowClass")
  469. {
  470. BlockInput On
  471.  
  472. Send {Enter}+{Home}{Delete}F1=fps/ping, F2=/hideout, F3=/ignore, F4=exit, F5=AfterMap, F6=/played, F7=/whois, F8=/invite, F9=/dnd, F10=/ladder, F11=screenshot, F12=ThisList.{Enter}
  473.  
  474. Send {Enter}* Ctrl-C: iinfo * Ctrl-D: TradeValue * Ctrl-Alt-D: advanced Uniq search * Ctrl-I: iname poetrade search * Ctrl-W: iwiki * Ctrl-Q: ipoetrade * Ctrl-E: iage * Ctrl-L: chg league *{Enter}
  475.  
  476. ; Send {Enter}* Alt-1: BEARERS * Alt-2/3/4/5: invite friends *{Enter}
  477.  
  478. ; Send {Enter}* Ctrl-F: Search with hover item * Ctrl-Alt-F: Search much broader * Ctrl-M: poeaffix * Ctrl-Alt-C: pathof.info * Ctrl-Alt-R: /whois *{Enter}
  479. Send {Enter}* Ctrl-M: poeaffix * Ctrl-Alt-C: pathof.info * Ctrl-Alt-R: /whois * Ctrl-Shift-O: Toggle poe-ladder * Ctrl-Shift-P: Toggle poe-racing ladder *{Enter}
  480.  
  481. BlockInput Off
  482. }
  483. return
  484. }
  485.  
  486.  
  487.  
  488. Cleanup() {
  489. IfWinExist, Path of Exile Ladder
  490. WinClose
  491.  
  492. ExitApp
  493. }
Advertisement
Add Comment
Please, Sign In to add comment