unsane

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

Dec 8th, 2017
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.38 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. ;!+1::Send {Enter}/invite WakaOctoCurse{Enter}
  159. ;!+2::Send {Enter}/invite DawnSunderer{Enter}
  160. ;!+3::Send {Enter}/invite IamBitter{Enter}
  161. ;!+4::Send {Enter}/invite QueueQueue_EDMoM{Enter}
  162.  
  163. ; The below overrides the normal PoE scrollwheel behavior. To temporarily use normal behavior, hold ctrl, alt or shift.
  164. WheelUp::SendInput {Left} ;mouse wheel up toggles stash tabs left
  165. WheelDown::SendInput {Right} ;mouse wheel down toggles stash tabs right
  166.  
  167.  
  168.  
  169. ; 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.
  170. TogglePoeLadder() {
  171. if !isActivePoeLadder {
  172. isActivePoeLadder := true
  173. 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"
  174. Sleep, 15000 ; was 20000+7000
  175. BlockInput On
  176. WinActivate Path of Exile Ladder
  177. Click 50, 125 ; Click Start on it
  178. BlockInput Off
  179. ; WinActivate, Path of Exile ahk_class POEWindowClass
  180. Sleep, 3000 ; was 7000
  181. ;orig/old WinMove, Path of Exile Ladder, , 755, 670 ; Move it to where i want it
  182. ; base window is 200x60 (poe-racing is 170x62)
  183. WinMove, Path of Exile Ladder, , 775, 661 ; Move it to where i want it
  184. }
  185. else {
  186. isActivePoeLadder := false
  187. IfWinExist, Path of Exile Ladder
  188. WinClose
  189. }
  190. return
  191. }
  192.  
  193.  
  194.  
  195. class WB_events {
  196. NavigateComplete2(wb, NewURL) {
  197. GuiControl,, URL, %URL%
  198. }
  199. }
  200.  
  201. TogglePoeRacing() {
  202. if !isActivePoeRacing {
  203. isActivePoeRacing := true
  204. Gui +LastFound +AlwaysOnTop -Caption -Border +ToolWindow +E0x20
  205. Gui, Color, FFFFFF
  206. Gui, Margin, 0, 0
  207. ;orig/old Gui Add, ActiveX, w170 h62 x0 y0 vWB, %URL%
  208. Gui Add, ActiveX, w200 h62 x0 y0 vWB, %URL%
  209. WinSet, TransColor, FFFFFF 200 ; Change 200 to a lower value if you want the tracker to be more transparent.
  210. ComObjConnect(WB, WB_events)
  211. ;orig/old Gui Show, x755 y670 NoActivate, Tracker
  212. Gui Show, x775 y660 NoActivate, Tracker
  213. WinSet AlwaysOnTop, On
  214. WB.Navigate(URL)
  215. }
  216. else {
  217. isActivePoeRacing := false
  218. Gui, Destroy
  219. }
  220. return
  221. }
  222.  
  223.  
  224.  
  225. AfterMap() {
  226. if WinActive("Path of Exile ahk_class POEWindowClass")
  227. {
  228. BlockInput On
  229. Send ^{Enter}After map. Negotiate/invite you at that time?{Enter}
  230. ; Send ^{Enter}After map. Am i not in a map? Then i'm busy and not trading.{Enter}
  231. ; Send ^{Enter}Speed levelling. 5c sale minimum.{Enter}
  232. BlockInput Off
  233. }
  234. return
  235. }
  236.  
  237.  
  238.  
  239. FastLogOut() {
  240. Critical
  241. Process Exist, PathOfExile.exe
  242. If ErrorLevel
  243. {
  244. ; Ensure you have cports.exe in the root POE-TradeMacro folder http://www.nirsoft.net/utils/cports.html
  245. Run, cports.exe /close * * * * PathOfExile.exe
  246. }
  247. Else
  248. {
  249. Process Exist, PathOfExile_x64.exe
  250. If ErrorLevel
  251. {
  252. ; The following is borrowed from the lutbot macro. See http://lutbot.com
  253. succ := logout("PathOfExile_x64.exe")
  254. if (succ == 0) {
  255. newSucc := logout("PathOfExile.exe")
  256. }
  257. }
  258. }
  259. return
  260. }
  261.  
  262.  
  263.  
  264. ; The following is borrowed from the lutbot macro. See http://lutbot.com
  265. logout(executable) {
  266. global GetTable, SetEntry, EnumProcesses, OpenProcessToken, LookupPrivilegeValue, AdjustTokenPrivileges, loadedPsapi
  267. Critical
  268.  
  269. poePID := Object()
  270. s := 4096
  271. Process, Exist
  272. h := DllCall("OpenProcess", "UInt", 0x0400, "Int", false, "UInt", ErrorLevel, "Ptr")
  273.  
  274. DllCall(OpenProcessToken, "Ptr", h, "UInt", 32, "PtrP", t)
  275. VarSetCapacity(ti, 16, 0)
  276. NumPut(1, ti, 0, "UInt")
  277.  
  278. DllCall(LookupPrivilegeValue, "Ptr", 0, "Str", "SeDebugPrivilege", "Int64P", luid)
  279. NumPut(luid, ti, 4, "Int64")
  280. NumPut(2, ti, 12, "UInt")
  281.  
  282. r := DllCall(AdjustTokenPrivileges, "Ptr", t, "Int", false, "Ptr", &ti, "UInt", 0, "Ptr", 0, "Ptr", 0)
  283. DllCall("CloseHandle", "Ptr", t)
  284. DllCall("CloseHandle", "Ptr", h)
  285.  
  286. s := VarSetCapacity(a, s)
  287. c := 0
  288. DllCall(EnumProcesses, "Ptr", &a, "UInt", s, "UIntP", r)
  289. Loop, % r // 4
  290. {
  291. id := NumGet(a, A_Index * 4, "UInt")
  292.  
  293. h := DllCall("OpenProcess", "UInt", 0x0010 | 0x0400, "Int", false, "UInt", id, "Ptr")
  294.  
  295. if !h
  296. continue
  297. VarSetCapacity(n, s, 0)
  298. e := DllCall("Psapi\GetModuleBaseName", "Ptr", h, "Ptr", 0, "Str", n, "UInt", A_IsUnicode ? s//2 : s)
  299. if !e
  300. if e := DllCall("Psapi\GetProcessImageFileName", "Ptr", h, "Str", n, "UInt", A_IsUnicode ? s//2 : s)
  301. SplitPath n, n
  302. DllCall("CloseHandle", "Ptr", h)
  303. if (n && e)
  304. if (n == executable) {
  305. poePID.Insert(id)
  306. }
  307. }
  308.  
  309. l := poePID.Length()
  310. if ( l = 0 ) {
  311. Process, wait, %executable%, 0.2
  312. if ( ErrorLevel > 0 ) {
  313. poePID.Insert(ErrorLevel)
  314. }
  315. }
  316.  
  317. VarSetCapacity(dwSize, 4, 0)
  318. result := DllCall(GetTable, UInt, &TcpTable, UInt, &dwSize, UInt, 0, UInt, 2, UInt, 5, UInt, 0)
  319. VarSetCapacity(TcpTable, NumGet(dwSize), 0)
  320.  
  321. result := DllCall(GetTable, UInt, &TcpTable, UInt, &dwSize, UInt, 0, UInt, 2, UInt, 5, UInt, 0)
  322.  
  323. num := NumGet(&TcpTable,0,"UInt")
  324.  
  325. out := 0
  326. Loop %num%
  327. {
  328. cutby := a_index - 1
  329. cutby *= 24
  330. ownerPID := NumGet(&TcpTable,cutby+24,"UInt")
  331. for index, element in poePID {
  332. if ( ownerPID = element )
  333. {
  334. VarSetCapacity(newEntry, 20, 0)
  335. NumPut(12,&newEntry,0,"UInt")
  336. NumPut(NumGet(&TcpTable,cutby+8,"UInt"),&newEntry,4,"UInt")
  337. NumPut(NumGet(&TcpTable,cutby+12,"UInt"),&newEntry,8,"UInt")
  338. NumPut(NumGet(&TcpTable,cutby+16,"UInt"),&newEntry,12,"UInt")
  339. NumPut(NumGet(&TcpTable,cutby+20,"UInt"),&newEntry,16,"UInt")
  340. result := DllCall(SetEntry, UInt, &newEntry)
  341. out++
  342. }
  343. }
  344. }
  345.  
  346. return True
  347. }
  348.  
  349.  
  350.  
  351. Played() {
  352. if WinActive("Path of Exile ahk_class POEWindowClass")
  353. {
  354. BlockInput On
  355. Send {Enter}/played{Enter}
  356. BlockInput Off
  357. }
  358. return
  359. }
  360.  
  361.  
  362.  
  363. Ladder() {
  364. if WinActive("Path of Exile ahk_class POEWindowClass")
  365. {
  366. BlockInput On
  367. Send {Enter}/ladder{Enter}
  368. BlockInput Off
  369. }
  370. return
  371. }
  372.  
  373.  
  374.  
  375. Invite() {
  376. if WinActive("Path of Exile ahk_class POEWindowClass")
  377. {
  378. BlockInput On
  379. Send ^{Enter}{Home}{Delete}/invite {Enter}
  380. BlockInput Off
  381. }
  382. return
  383. }
  384.  
  385.  
  386.  
  387. InviteX() {
  388. if WinActive("Path of Exile ahk_class POEWindowClass")
  389. {
  390. BlockInput On
  391. ;zzz
  392. Send {Enter}/invite WakaOctoCurse{Enter}
  393. BlockInput Off
  394. }
  395. return
  396. }
  397.  
  398.  
  399.  
  400. Whois() {
  401. if WinActive("Path of Exile ahk_class POEWindowClass")
  402. {
  403. BlockInput On
  404. Send {Enter}/whois %Clipboard%{Enter}
  405. BlockInput Off
  406. }
  407. return
  408. }
  409.  
  410.  
  411.  
  412. DND() {
  413. if WinActive("Path of Exile ahk_class POEWindowClass")
  414. {
  415. BlockInput On
  416. if (dndOn)
  417. Send {Enter}/dnd{Enter}
  418. else
  419. Send {Enter}/dnd Lab/racing/busy. /whois me and try again shortly.{Enter}
  420. BlockInput Off
  421. dndOn := !dndOn
  422. }
  423. return
  424. }
  425.  
  426.  
  427.  
  428. Hideout() {
  429. if WinActive("Path of Exile ahk_class POEWindowClass")
  430. {
  431. BlockInput On
  432. Send {Enter}/hideout{Enter}
  433. BlockInput Off
  434. }
  435. return
  436. }
  437.  
  438.  
  439.  
  440. Clear() {
  441. if WinActive("Path of Exile ahk_class POEWindowClass")
  442. {
  443. BlockInput On
  444. Send {Enter}/clear{Enter}
  445. BlockInput Off
  446. }
  447. return
  448. }
  449.  
  450.  
  451.  
  452. Ignore() {
  453. if WinActive("Path of Exile ahk_class POEWindowClass")
  454. {
  455. BlockInput On
  456. Send ^{Enter}{Home}{Delete}/ignore {Enter}
  457. BlockInput Off
  458. }
  459. return
  460. }
  461.  
  462.  
  463.  
  464. CommandList() {
  465. if WinActive("Path of Exile ahk_class POEWindowClass")
  466. {
  467. BlockInput On
  468.  
  469. 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}
  470.  
  471. 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}
  472.  
  473. ; Send {Enter}* Alt-1: BEARERS * Alt-2/3/4/5: invite friends *{Enter}
  474.  
  475. ; 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}
  476. 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}
  477.  
  478. BlockInput Off
  479. }
  480. return
  481. }
  482.  
  483.  
  484.  
  485. Cleanup() {
  486. IfWinExist, Path of Exile Ladder
  487. WinClose
  488.  
  489. ExitApp
  490. }
Advertisement
Add Comment
Please, Sign In to add comment