Advertisement
Karvarousku

TCP IP logout macro 26/5/2016

May 25th, 2016
344
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 37.22 KB | None | 0 0
  1. ; made by /u/lutcikaur
  2. ; As always, test the logout before you run into hardcore.
  3. ; If you find some errors, the list is at the bottom. Search for the error code.
  4. ; GUI's in use : 1, 2, 3, 4
  5.  
  6. #NoEnv
  7. #SingleInstance force
  8.  
  9. FileEncoding , UTF-8
  10. SendMode Input
  11. SetTitleMatchMode, 3
  12. macroVersion := 131
  13.  
  14. If (A_AhkVersion <= "1.1.23")
  15. {
  16. msgbox, You need AutoHotkey v1.1.23 or later to run this script. `n`nPlease go to http://ahkscript.org/download and download a recent version.
  17. ExitApp
  18. }
  19.  
  20. IfNotExist %A_MyDocuments%\AutoHotKey
  21. {
  22. FileCreateDir, %A_MyDocuments%\AutoHotKey
  23. }
  24.  
  25. SetWorkingDir %A_MyDocuments%\AutoHotKey
  26.  
  27. elog := A_Now . " " . A_AhkVersion . " " . macroVersion "`n"
  28. FileAppend, %elog% , error.txt, UTF-16
  29.  
  30. UrlDownloadToFile, http://lutbot.com/ahk/version.html, version.html
  31. if ErrorLevel
  32. error("ED06")
  33.  
  34. FileRead, newestVersion, version.html
  35.  
  36. if ( macroVersion < newestVersion ) {
  37. UrlDownloadToFile, http://lutbot.com/ahk/changelog.txt, changelog.txt
  38. if ErrorLevel
  39. error("ED08")
  40. Gui, 4:Add, Text,, Update Available.`nYoure running version %macroVersion%. The newest is version %newestVersion%`nI either messed something up in this version, or I added something new.`nCan I download it for you? It will only take a moment, and the script will automatically restart.
  41. FileRead, changelog, changelog.txt
  42. Gui, 4:Add, Edit, w600 h200 +ReadOnly, %changelog%
  43. Gui, 4:Add, Button, section default grunUpdate, Update
  44. Gui, 4:Add, Button, ys gdontUpdate, Skip Update
  45. Gui, 4:Show
  46. }
  47.  
  48. If !A_IsAdmin {
  49. Run *RunAs "%A_ScriptFullPath%"
  50. ExitApp
  51. }
  52.  
  53. GetTable := DllCall("GetProcAddress", Ptr, DllCall("LoadLibrary", Str, "Iphlpapi.dll", "Ptr"), Astr, "GetExtendedTcpTable", "Ptr")
  54. SetEntry := DllCall("GetProcAddress", Ptr, DllCall("LoadLibrary", Str, "Iphlpapi.dll", "Ptr"), Astr, "SetTcpEntry", "Ptr")
  55. EnumProcesses := DllCall("GetProcAddress", Ptr, DllCall("LoadLibrary", Str, "Psapi.dll", "Ptr"), Astr, "EnumProcesses", "Ptr")
  56. preloadPsapi := DllCall("LoadLibrary", "Str", "Psapi.dll", "Ptr")
  57. OpenProcessToken := DllCall("GetProcAddress", Ptr, DllCall("LoadLibrary", Str, "Advapi32.dll", "Ptr"), Astr, "OpenProcessToken", "Ptr")
  58. LookupPrivilegeValue := DllCall("GetProcAddress", Ptr, DllCall("LoadLibrary", Str, "Advapi32.dll", "Ptr"), Astr, "LookupPrivilegeValue", "Ptr")
  59. AdjustTokenPrivileges := DllCall("GetProcAddress", Ptr, DllCall("LoadLibrary", Str, "Advapi32.dll", "Ptr"), Astr, "AdjustTokenPrivileges", "Ptr")
  60.  
  61. IfNotExist, Lib
  62. {
  63. FileCreateDir, Lib
  64. }
  65.  
  66. FileDelete, Lib\QDL.ahk
  67. str := "#NoTrayIcon`nSetWorkingDir %A_MyDocuments%\AutoHotKey`nUrlDownloadToFile,%1%,%2%`nIfNotExist, %2%`n{`nFileAppend,ERROR,%2%`n}"
  68. FileAppend, %str%, Lib\QDL.ahk
  69.  
  70. IfNotExist, cports.exe
  71. {
  72. UrlDownloadToFile, http://lutbot.com/ahk/cports.exe, cports.exe
  73. if ErrorLevel
  74. msgbox, We couldn't download cports.exe, this is used as a fallback to the normal logout method. The logout functionality may not work until this is resolved. Please download cports.exe from http://lutbot.com/ahk/cports.exe and place it in %A_MyDocuments%\AutoHotKey.
  75. UrlDownloadToFile, http://lutbot.com/ahk/cports.chm, cports.chm
  76. if ErrorLevel
  77. error("ED03")
  78. UrlDownloadToFile, http://lutbot.com/ahk/readme.txt, readme.txt
  79. if ErrorLevel
  80. error("ED04")
  81. }
  82.  
  83. IfNotExist, settings.ini
  84. {
  85. defaultIni := "[variables]`n"
  86. defaultIni .= "CharacterName=BTOneMonthLut`n"
  87. defaultIni .= "League=standard`n"
  88. defaultIni .= "PoeSteam=0`n"
  89. defaultIni .= "UpdateTimer=1000`n"
  90. defaultIni .= "XOffset=0`n"
  91. defaultIni .= "YOffset=0`n"
  92. defaultIni .= "MonitorWhispers=0`n"
  93. defaultIni .= "MonitorWhispersDelay=10000`n"
  94. defaultIni .= "LogFileLocation=ERROR PLEASE SELECT LOG FILE`n"
  95. defaultIni .= "OverlayToggle=0`n"
  96. defaultIni .= "SoundSelector=*-1`n"
  97. defaultIni .= "Beta=1`n"
  98. defaultIni .= "Diablo2=0`n"
  99. defaultIni .= "[whisperMessages]`n"
  100. defaultIni .= "wm1=One moment, I'm in a map.`n"
  101. defaultIni .= "wm2=Sorry, That item has already been sold.`n"
  102. defaultIni .= "wm3=Type a sentence here`n"
  103. defaultIni .= "wm4=Type a sentence here`n"
  104. defaultIni .= "wm5=Type a sentence here`n"
  105. defaultIni .= "[partyMessages]`n"
  106. defaultIni .= "pm1=Watch for corrupting blood!`n"
  107. defaultIni .= "pm2=Type a sentence here`n"
  108. defaultIni .= "pm3=Dangerous exile!`n"
  109. defaultIni .= "pm4=Minion Instability / Iceblood!`n"
  110. defaultIni .= "pm5=Type a sentence here`n"
  111. defaultIni .= "[hotkeys]`n"
  112. defaultIni .= "logout=```n"
  113. defaultIni .= "superLogout=F12`n"
  114. defaultIni .= "oos=F2`n"
  115. defaultIni .= "remaining=F3`n"
  116. defaultIni .= "itemLevel=F4`n"
  117. defaultIni .= "hideout=F5`n"
  118. defaultIni .= "invite=F6`n"
  119. defaultIni .= "toggleOverlay=F9`n"
  120. defaultIni .= "options=F10`n"
  121. defaultIni .= "wm1=^1`n"
  122. defaultIni .= "wm2=^2`n"
  123. defaultIni .= "wm3=^3`n"
  124. defaultIni .= "wm4=^4`n"
  125. defaultIni .= "wm5=^5`n"
  126. defaultIni .= "pm1=!1`n"
  127. defaultIni .= "pm2=!2`n"
  128. defaultIni .= "pm3=!3`n"
  129. defaultIni .= "pm4=!4`n"
  130. defaultIni .= "pm5=!5"
  131.  
  132. FileAppend, %defaultIni%, settings.ini, UTF-16
  133. }
  134.  
  135. getLeagueListing()
  136.  
  137. readFromFile()
  138.  
  139. current := 0
  140. phase := 0
  141. lastWhisperTimeRecieved := 0
  142.  
  143. ;timers
  144. updateTrackingTimer := 5000 ; 5 seconds
  145. baseUpdateTrackingTimer := 300000 ; 5 minutes
  146. overlayTimer := 0
  147. baseOverlayTimer := sleepTime
  148. updateTrackingTimerActive := true
  149. overlayTimerActive := true
  150. lastUpdated := 1
  151. preloadCportsTimer := 0
  152. basePreloadCportsTimer := 180000 ; 3 minutes
  153. preloadCportsCall := "cports.exe /stext TEMP"
  154.  
  155. ;Ranking Overlay
  156. Gui, 1:+ToolWindow
  157. Gui, 1:Font, s8
  158. Gui, 1:Add, Text, x3 y2 vguiErr, Working
  159. Gui, 1:Add, Text, x3 y17, Settings:F10
  160. Gui, 1:Font, s14
  161. Gui, 1:Add, Text, x67 y4 w120 vguiRank, Rank: N/A
  162. Gui, 1:Add, Text, x175 y4 w55 vguiMovedRanks, N/A
  163. Gui, 1:Font, s7
  164. Gui, 1:Add, Text, x3 y32, Ranks, Class:
  165. Gui, 1:Add, Text, x72 y32 w33 vguiClassRank, N/A
  166. Gui, 1:Add, Text, x115 y32, Alive:
  167. Gui, 1:Add, Text, x145 y32 w33 vguiAliveRank, N/A
  168. Gui, 1:Add, Text, x3 y47, Exp Above :
  169. Gui, 1:Add, Text, x3 y62, Exp Below :
  170. Gui, 1:Add, Text, x66 y47 w66 vguiAbove1, N/A
  171. Gui, 1:Add, Text, x135 y47 w66 vguiAbove2, N/A
  172. Gui, 1:Add, Text, x66 y62 w66 vguiBelow1, N/A
  173. Gui, 1:Add, Text, x135 y62 w66 vguiBelow2, N/A
  174. Gui, 1:Font, s14
  175.  
  176. Gui, 1:Show, x0 y0 w225 h37, poeGUI
  177. Gui, 1:-Caption +AlwaysOnTop +Disabled +E0x20 +LastFound
  178. Winset,TransColor, 0xFFFFFF
  179.  
  180. ;Menu
  181. Gui, 2:Add, Text,, CharacterName:
  182. Gui, 2:Add, Text,, Char's League:
  183. Gui, 2:Add, Text,, Steam Client:
  184. Gui, 2:Add, Text,, UpdateTimer(ms):
  185. Gui, 2:Add, Text,, Overlay X Offset:
  186. Gui, 2:Add, Text,, Overlay Y Offset:
  187. Gui, 2:Add, Text,, Beta version:
  188. Gui, 2:Add, Text,h34, D2 logout?:
  189.  
  190. Gui, 2:Add, Text,, Logout:
  191. Gui, 2:Add, Text,, ForceLogout:
  192. Gui, 2:Add, Text,, /Oos:
  193. Gui, 2:Add, Text,, /Remaining :
  194. Gui, 2:Add, Text,, /ItemLevel :
  195. Gui, 2:Add, Text,, Travel to Hideout :
  196. Gui, 2:Add, Text,, Invite Player :
  197. Gui, 2:Add, Text,, Toggle Overlay Size:
  198. Gui, 2:Add, Text,, Options (This GUI) :
  199.  
  200.  
  201. Gui, 2:Add, Edit, vguiChar ym w100 h20, %charName%
  202. Gui, 2:Add, DropDownList, vguiLeague w100, %leagueString%
  203. ;GuiControl, 2:ChooseString, guiLeague, %league%
  204. Gui, 2:Add, Checkbox, vguiSteam w100 h20 Checked%steam%
  205. Gui, 2:Add, Edit, vguiUpdate w100 h20, %sleepTime%
  206. Gui, 2:Add, Edit, vguiXOffset w100 h20, %xOffset%
  207. Gui, 2:Add, Edit, vguiYOffset w100 h20, %yOffset%
  208. Gui, 2:Add, Checkbox, vguibeta h20 Checked%beta%
  209. Gui, 2:Add, Checkbox, vguidiablo2 h20 Checked%diablo2%
  210.  
  211. Gui, 2:Add, Text, w100 h20, Hotkey:
  212. Gui, 2:Add, Hotkey, w100 h20 vguihotkeyLogout , %hotkeyLogout%
  213. Gui, 2:Add, Hotkey, w100 h20 vguihotkeySuperLogout , %hotkeySuperLogout%
  214. Gui, 2:Add, Hotkey, w100 h20 vguihotkeyOos , %hotkeyOos%
  215. Gui, 2:Add, Hotkey, w100 h20 vguihotkeyRemaining , %hotkeyRemaining%
  216. Gui, 2:Add, Hotkey, w100 h20 vguihotkeyItemLevel , %hotkeyItemLevel%
  217. Gui, 2:Add, Hotkey, w100 h20 vguihotkeyHideout , %hotkeyHideout%
  218. Gui, 2:Add, Hotkey, w100 h20 vguihotkeyInvite , %hotkeyInvite%
  219. Gui, 2:Add, Hotkey, w100 h20 vguihotkeyToggleOverlay , %hotkeyToggleOverlay%
  220. Gui, 2:Add, Hotkey, w100 h20 vguihotkeyOptions , %hotkeyOptions%
  221.  
  222. Gui, 2:Add, Text, ym, Whisper Hotkey:
  223. Gui, 2:Add, Hotkey, vguihotkeywm1 w100 h20 , %hotkeywm1%
  224. Gui, 2:Add, Hotkey, vguihotkeywm2 w100 h20 , %hotkeywm2%
  225. Gui, 2:Add, Hotkey, vguihotkeywm3 w100 h20 , %hotkeywm3%
  226. Gui, 2:Add, Hotkey, vguihotkeywm4 w100 h20 , %hotkeywm4%
  227. Gui, 2:Add, Hotkey, vguihotkeywm5 w100 h20 , %hotkeywm5%
  228.  
  229. Gui, 2:Add, Text,, Party Hotkey:
  230. Gui, 2:Add, Hotkey, vguihotkeypm1 w100 h20 , %hotkeypm1%
  231. Gui, 2:Add, Hotkey, vguihotkeypm2 w100 h20 , %hotkeypm2%
  232. Gui, 2:Add, Hotkey, vguihotkeypm3 w100 h20 , %hotkeypm3%
  233. Gui, 2:Add, Hotkey, vguihotkeypm4 w100 h20 , %hotkeypm4%
  234. Gui, 2:Add, Hotkey, vguihotkeypm5 w100 h20 , %hotkeypm5%
  235. Gui, 2:Add, Text,, Questions? Comments?
  236.  
  237. Gui, 2:Add, Text, ym w200, Whisper Message Text:
  238. Gui, 2:Add, Edit, vguiwm1 w200 h20, %wm1%
  239. Gui, 2:Add, Edit, vguiwm2 w200 h20, %wm2%
  240. Gui, 2:Add, Edit, vguiwm3 w200 h20, %wm3%
  241. Gui, 2:Add, Edit, vguiwm4 w200 h20, %wm4%
  242. Gui, 2:Add, Edit, vguiwm5 w200 h20, %wm5%
  243.  
  244. Gui, 2:Add, Text, w200, Party Message Text:
  245. Gui, 2:Add, Edit, vguipm1 w200 h20, %pm1%
  246. Gui, 2:Add, Edit, vguipm2 w200 h20, %pm2%
  247. Gui, 2:Add, Edit, vguipm3 w200 h20, %pm3%
  248. Gui, 2:Add, Edit, vguipm4 w200 h20, %pm4%
  249. Gui, 2:Add, Edit, vguipm5 w200 h20, %pm5%
  250. Gui, 2:Add, Text,, @Lutcikaur ingame or /u/lutcikaur on reddit
  251.  
  252. Gui, 2:Add, Text,, Let me know if it errors
  253.  
  254. Gui, 2:Add, Text, xm section, Monitor Whispers:
  255. Gui, 2:Add, Checkbox, ys vguiMonitorWhispers h20 Checked%monitorWhispers%
  256. Gui, 2:Add, Text, ys, Check Delay (ms):
  257. Gui, 2:Add, Edit, ys vguiMonitorWhispersDelay w100 h20, %monitorWhispersDelay%
  258. Gui, 2:Add, Button, ys gchangelogGui, Changelog
  259. Gui, 2:Add, Button, ys default gupdateHotkeys, Okay
  260.  
  261. Gui, 2:Add, Button, section xm gbrowseForLogFile , Browse for Log File
  262. Gui, 2:Add, Text, ys, Whisper Notification Sound:
  263. Gui, 2:Add, DropDownList, ys vguiSoundSelector w50, None|*-1|*16|*32|*48|*64
  264. GuiControl, 2:ChooseString, guiSoundSelector, %soundSelector%
  265. Gui, 2:Add, Button, ys gplaySound, TestPlay Sound
  266. Gui, 2:Add, Text, w380 xs vguiLogFileLocation, %logFileLocation%
  267.  
  268. ; some fucking initializers. Put these together later.
  269. toggle--
  270. toggleOverlay()
  271.  
  272. ;start the main loop. Gotta be last
  273. loopTimers()
  274.  
  275. getLeagueListing() {
  276. global
  277. ;Get league listing
  278. SetTimer, loadLeague, 1000
  279. run "Lib\QDL.ahk" "http://api.exiletools.com/ladder?activeleagues=1" "leagues.json"
  280. return
  281. loadLeague:
  282. IfExist, leagues.json
  283. {
  284. SetTimer, loadLeague, off
  285. FileRead, leagues, leagues.json
  286. JSON_obj_leagues := json_toobj(leagues)
  287. leagueString := JSON_obj_leagues[0]
  288. while JSON_obj_leagues[a_index] != ""
  289. {
  290. leagueString .= "|" . JSON_obj_leagues[a_index]
  291. }
  292. leagueString .= "|SSF"
  293. GuiControl,2:, guiLeague, %leagueString%
  294. GuiControl,2:ChooseString, guiLeague, %league%
  295. }
  296. return
  297. }
  298.  
  299. superLogoutCommand(){
  300. superLogoutCommand:
  301. logoutCommand()
  302. return
  303. }
  304.  
  305. logoutCommand(){
  306. logoutCommand:
  307. logout()
  308. return
  309. }
  310.  
  311. cportsLogout(){
  312. global cportsCommand, lastlogout
  313. start := A_TickCount
  314. ltime := lastlogout + 1000
  315. if ( ltime < A_TickCount ) {
  316. RunWait, %cportsCommand%
  317. lastlogout := A_TickCount
  318. }
  319. Sleep 10
  320. error("nb:" . A_TickCount - start)
  321. return
  322. }
  323.  
  324. logout(){
  325. global executable, GetTable, SetEntry, EnumProcesses, OpenProcessToken, LookupPrivilegeValue, AdjustTokenPrivileges, loadedPsapi
  326. start := A_TickCount
  327. poePID := Object()
  328. s := 4096
  329. Process, Exist
  330. h := DllCall("OpenProcess", "UInt", 0x0400, "Int", false, "UInt", ErrorLevel, "Ptr")
  331.  
  332. DllCall(OpenProcessToken, "Ptr", h, "UInt", 32, "PtrP", t)
  333. VarSetCapacity(ti, 16, 0)
  334. NumPut(1, ti, 0, "UInt")
  335.  
  336. DllCall(LookupPrivilegeValue, "Ptr", 0, "Str", "SeDebugPrivilege", "Int64P", luid)
  337. NumPut(luid, ti, 4, "Int64")
  338. NumPut(2, ti, 12, "UInt")
  339.  
  340. r := DllCall(AdjustTokenPrivileges, "Ptr", t, "Int", false, "Ptr", &ti, "UInt", 0, "Ptr", 0, "Ptr", 0)
  341. DllCall("CloseHandle", "Ptr", t)
  342. DllCall("CloseHandle", "Ptr", h)
  343.  
  344. s := VarSetCapacity(a, s)
  345. c := 0
  346. DllCall(EnumProcesses, "Ptr", &a, "UInt", s, "UIntP", r)
  347. Loop, % r // 4
  348. {
  349. id := NumGet(a, A_Index * 4, "UInt")
  350.  
  351. h := DllCall("OpenProcess", "UInt", 0x0010 | 0x0400, "Int", false, "UInt", id, "Ptr")
  352.  
  353. if !h
  354. continue
  355. VarSetCapacity(n, s, 0)
  356. e := DllCall("Psapi\GetModuleBaseName", "Ptr", h, "Ptr", 0, "Str", n, "UInt", A_IsUnicode ? s//2 : s)
  357. if !e
  358. if e := DllCall("Psapi\GetProcessImageFileName", "Ptr", h, "Str", n, "UInt", A_IsUnicode ? s//2 : s)
  359. SplitPath n, n
  360. DllCall("CloseHandle", "Ptr", h)
  361. if (n && e)
  362. if (n == executable) {
  363. poePID.Insert(id)
  364. }
  365. }
  366.  
  367. l := poePID.Length()
  368. if ( l = 0 ) {
  369. Process, wait, %executable%, 0.2
  370. if ( ErrorLevel > 0 ) {
  371. poePID.Insert(ErrorLevel)
  372. }
  373. }
  374.  
  375. VarSetCapacity(dwSize, 4, 0)
  376. result := DllCall(GetTable, UInt, &TcpTable, UInt, &dwSize, UInt, 0, UInt, 2, UInt, 5, UInt, 0)
  377. VarSetCapacity(TcpTable, NumGet(dwSize), 0)
  378.  
  379. result := DllCall(GetTable, UInt, &TcpTable, UInt, &dwSize, UInt, 0, UInt, 2, UInt, 5, UInt, 0)
  380.  
  381. num := NumGet(&TcpTable,0,"UInt")
  382.  
  383. IfEqual, num, 0
  384. {
  385. cportsLogout()
  386. error("ED11",num,l,executable)
  387. return
  388. }
  389.  
  390. out := 0
  391. Loop %num%
  392. {
  393. cutby := a_index - 1
  394. cutby *= 24
  395. ownerPID := NumGet(&TcpTable,cutby+24,"UInt")
  396. for index, element in poePID {
  397. if ( ownerPID = element )
  398. {
  399. VarSetCapacity(newEntry, 20, 0)
  400. NumPut(12,&newEntry,0,"UInt")
  401. NumPut(NumGet(&TcpTable,cutby+8,"UInt"),&newEntry,4,"UInt")
  402. NumPut(NumGet(&TcpTable,cutby+12,"UInt"),&newEntry,8,"UInt")
  403. NumPut(NumGet(&TcpTable,cutby+16,"UInt"),&newEntry,12,"UInt")
  404. NumPut(NumGet(&TcpTable,cutby+20,"UInt"),&newEntry,16,"UInt")
  405. result := DllCall(SetEntry, UInt, &newEntry)
  406. IfNotEqual, result, 0
  407. {
  408. cportsLogout()
  409. error("TCP" . result,out,result,l,executable)
  410. return
  411. }
  412. out++
  413. }
  414. }
  415. }
  416. if ( out = 0 ) {
  417. cportsLogout()
  418. error("ED10",out,l,executable)
  419. } else {
  420. error(l . ":" . A_TickCount - start,out,l,executable)
  421. }
  422. return
  423. }
  424.  
  425. error(var,var2:="",var3:="",var4:="",var5:="",var6:="",var7:="") {
  426. GuiControl,1:, guiErr, %var%
  427. print := A_Now . "," . var . "," . var2 . "," . var3 . "," . var4 . "," . var5 . "," . var6 . "," . var7 . "`n"
  428. FileAppend, %print%, error.txt, UTF-16
  429. return
  430. }
  431.  
  432. invite(){
  433. inviteCommand:
  434. BlockInput On
  435. Send ^{Enter}{Home}{Delete}/invite {Enter}
  436. BlockInput Off
  437. return
  438. }
  439.  
  440. oosCommand(){
  441. oosCommand:
  442. BlockInput On
  443. SendInput, {enter}
  444. Sleep 2
  445. SendInput, {/}oos
  446. SendInput, {enter}
  447. BlockInput Off
  448. return
  449. }
  450.  
  451. remaining(){
  452. remainingCommand:
  453. BlockInput On
  454. SendInput, {enter}
  455. Sleep 2
  456. SendInput, {/}remaining
  457. SendInput, {enter}
  458. BlockInput Off
  459. return
  460. }
  461.  
  462. itemlevel(){
  463. itemLevelCommand:
  464. BlockInput On
  465. SendInput, {Enter}
  466. Sleep 2
  467. SendInput, {/}itemlevel
  468. SendInput, {Enter}
  469. Sleep 75
  470. BlockInput Off
  471. return
  472. }
  473.  
  474. hideout(){
  475. hideoutCommand:
  476. BlockInput On
  477. SendInput, {Enter}
  478. Sleep 2
  479. SendInput, {/}hideout
  480. SendInput, {Enter}
  481. BlockInput Off
  482. return
  483. }
  484.  
  485. whisperCommand1:
  486. BlockInput On
  487. Sleep 2
  488. SendInput ^{Enter}
  489. SendInput %wm1%
  490. SendInput {Enter}
  491. BlockInput Off
  492. return
  493. whisperCommand2:
  494. BlockInput On
  495. Sleep 2
  496. SendInput ^{Enter}
  497. SendInput %wm2%
  498. SendInput {Enter}
  499. BlockInput Off
  500. return
  501. whisperCommand3:
  502. BlockInput On
  503. Sleep 2
  504. SendInput ^{Enter}
  505. SendInput %wm3%
  506. SendInput {Enter}
  507. BlockInput Off
  508. return
  509. whisperCommand4:
  510. BlockInput On
  511. Sleep 2
  512. SendInput ^{Enter}
  513. SendInput %wm4%
  514. SendInput {Enter}
  515. BlockInput Off
  516. return
  517. whisperCommand5:
  518. BlockInput On
  519. Sleep 2
  520. SendInput ^{Enter}
  521. SendInput %wm5%
  522. SendInput {Enter}
  523. BlockInput Off
  524. return
  525. partyCommand1:
  526. BlockInput On
  527. Sleep 2
  528. SendInput {Enter}
  529. SendInput `%
  530. SendInput %pm1%
  531. SendInput {Enter}
  532. BlockInput Off
  533. return
  534. partyCommand2:
  535. BlockInput On
  536. Sleep 2
  537. SendInput {Enter}
  538. SendInput `%
  539. SendInput %pm2%
  540. SendInput {Enter}
  541. BlockInput Off
  542. return
  543. partyCommand3:
  544. BlockInput On
  545. Sleep 2
  546. SendInput {Enter}
  547. SendInput `%
  548. SendInput %pm3%
  549. SendInput {Enter}
  550. BlockInput Off
  551. return
  552. partyCommand4:
  553. BlockInput On
  554. Sleep 2
  555. SendInput {Enter}
  556. SendInput `%
  557. SendInput %pm4%
  558. SendInput {Enter}
  559. BlockInput Off
  560. return
  561. partyCommand5:
  562. BlockInput On
  563. Sleep 2
  564. SendInput {Enter}
  565. SendInput `%
  566. SendInput %pm5%
  567. SendInput {Enter}
  568. BlockInput Off
  569. return
  570.  
  571. browseForLogFile:
  572. FileSelectFile, logFileLocation,, , Navigate to C:\Program Files (x86)\Grinding Gear Games\Path of Exile\logs, Text Documents (*.txt; *.log)
  573. GuiControl,2:, guiLogFileLocation, %logFileLocation%
  574. return
  575.  
  576. changelogGui(){
  577. changelogGui:
  578. FileRead, changelog, changelog.txt
  579. Gui, 3:Add, Edit, w600 h200 +ReadOnly, %changelog%
  580. Gui, 3:Show
  581. return
  582. }
  583.  
  584. playSound:
  585. Gui, 2:Submit, nohide
  586. SoundPlay, %guiSoundSelector%
  587. return
  588.  
  589. toggleOverlay(){
  590. toggleOverlayCommand:
  591. global toggle
  592. toggle++
  593. if toggle > 1
  594. toggle := -1
  595. if toggle = -1
  596. {
  597. Gui, 1:Hide
  598. }
  599. if toggle = 0
  600. {
  601. Gui, 1:Show, h75 NA
  602. }
  603. if toggle = 1
  604. {
  605. Gui, 1:Show, h46 NA
  606. }
  607. return
  608. }
  609.  
  610. preloadCports(){
  611. global preloadCportsTimer, basePreloadCportsTimer, preloadCportsCall
  612. Run, %preloadCportsCall%
  613. preloadCportsTimer := basePreloadCportsTimer
  614. }
  615.  
  616. checkOverlay(){
  617. global overlayTimer, baseOverlayTimer, toggle, xOffset, yOffset
  618. if toggle != -1
  619. {
  620. IfWinActive Path of Exile
  621. {
  622. WinGetActiveStats,name,width,height,x,y
  623. width += x
  624. width += xOffset
  625. hh := y
  626. hh += yOffset
  627. if toggle = 2
  628. {
  629. width /= 2
  630. width -= 295
  631. height /= 2
  632. height -= 325
  633. Gui, 5:Show, y%height% x%width% NA
  634. }
  635. if ( toggle = 1 ) || ( toggle = 0 )
  636. {
  637. width -= 231
  638. Gui, 1:Show, y%hh% x%width% NA
  639. }
  640. } else {
  641. Gui, 1:Hide
  642. Gui, 5:Hide
  643. }
  644. }
  645. overlayTimer := baseOverlayTimer
  646. return
  647. }
  648.  
  649. runUpdate(){
  650. runUpdate:
  651. UrlDownloadToFile, http://lutbot.com/ahk/macro.ahk, %A_ScriptFullPath%
  652. if ErrorLevel
  653. error("ED07")
  654. else
  655. Run "%A_ScriptFullPath%"
  656. Sleep 5000 ;This shouldn't ever hit.
  657. dontUpdate:
  658. Gui, 4:Destroy
  659. return
  660. }
  661.  
  662. checkForWhispers(){
  663. global logFileLocation, lastWhisperTimeRecieved, monitorWhispersTimer, monitorWhispersDelay, soundSelector
  664. FileRead, BIGFILE, %logFileLocation%
  665. StringGetPos, last25Location, BIGFILE,`n, R75
  666. StringTrimLeft, smallfile, BIGFILE, %last25Location%
  667.  
  668. regexLocation := 1
  669. arrayCount := 0
  670. newStart := 0
  671.  
  672. While regexLocation
  673. {
  674. regexLocation := RegExMatch( smallfile, "(\d\d\d\d.\d\d.\d\d \d\d:\d\d:\d\d)(?:.*)\[INFO Client \d+\] \@(.*)", regexString, regexLocation+1)
  675. if regexLocation != 0
  676. {
  677. time%arrayCount% := regexString1
  678. s%arrayCount% := regexString2
  679. arrayCount++
  680. }
  681. }
  682.  
  683.  
  684. loopCounter := 0
  685. lnum := arrayCount-1
  686. displayStart := arrayCount
  687. d = :::
  688. while loopCounter < arrayCount
  689. {
  690. if ( time%loopCounter% > lastWhisperTimeRecieved )
  691. {
  692. displayStart := loopCounter
  693. goto breakWhisperTimes
  694. }
  695. loopCounter++
  696. }
  697. breakWhisperTimes:
  698. if( lnum < 0)
  699. lnum := 0
  700. lastWhisperTimeRecieved := time%lnum%
  701. displayString := ""
  702. iterations := arrayCount - displayStart
  703. loopCounter := arrayCount
  704.  
  705. while loopCounter > displayStart
  706. {
  707. loopCounter--
  708. displayString .= s%loopCounter% . "`n"
  709. }
  710.  
  711. IfWinNotActive Path of Exile
  712. if iterations > 0
  713. {
  714. TrayTip, New Messages: `(%iterations%`), %displayString%
  715. SoundPlay, %soundSelector%
  716. }
  717. monitorWhispersTimer := monitorWhispersDelay
  718. return
  719. }
  720.  
  721. loopTimers(){
  722. global
  723. Loop {
  724. if ( overlayTimerActive = true )
  725. overlayTimer -= sleepTime
  726. if ( updateTrackingTimerActive = true )
  727. updateTrackingTimer -= sleepTime
  728. if ( monitorWhispers )
  729. monitorWhispersTimer -= sleepTime
  730. if ( !beta )
  731. preloadCportsTimer -= sleepTime
  732.  
  733. if ( overlayTimer <= 0 ) && ( overlayTimerActive = true )
  734. {
  735. checkOverlay()
  736. }
  737.  
  738. if ( updateTrackingTimer <= 0 ) && ( updateTrackingTimerActive = true )
  739. {
  740. IfWinExist, Path of Exile
  741. updateTracking()
  742. else
  743. updateTrackingTimer := 60000
  744. }
  745.  
  746. if ( monitorWhispersTimer <= 0 ) && ( monitorWhispers )
  747. {
  748. IfWinExist, Path of Exile
  749. checkForWhispers()
  750. }
  751.  
  752. if ( preloadCportsTimer <= 0 )
  753. {
  754. IfWinExist, Path of Exile
  755. preloadCports()
  756. else
  757. preloadCportsTimer := basePreloadCportsTimer
  758. }
  759.  
  760.  
  761. Sleep sleepTime
  762. }
  763. return
  764. }
  765.  
  766. updateTracking(){
  767. global charName, league, updateTrackingTimer, baseUpdateTrackingTimer, lastUpdated
  768. updateTrackingTimer := baseUpdateTrackingTimer ; Wait the base time
  769. rank := "No Rank"
  770.  
  771. if ( league == "SSF" ) {
  772. url := "http://ssf.poeladder.com/players/" . charName . ""
  773. SetTimer, loadSSF, 1000
  774. FileDelete, ladder.json
  775. run "Lib\QDL.ahk" %url% "ladder.json"
  776. return
  777. loadSSF:
  778. IfExist, ladder.json
  779. {
  780. SetTimer, loadSSF, off
  781. FileRead, ladderString, ladder.json
  782. JSON_obj := json_toobj(ladderString)
  783. r := "rank"
  784. rank := JSON_obj[r]
  785. if ( rank == "" )
  786. {
  787. rank := "Rank: N/A"
  788. } else {
  789. rank := "Rank: " . rank
  790. }
  791. GuiControl,1:, guiRank, %rank%
  792. GuiControl,1:, guiMovedRanks
  793. return
  794. } else {
  795. return
  796. }
  797.  
  798. } else {
  799. url := "http://exiletools.com/api/ladder?league=" . league . "&char=" . charName . ""
  800. url2 := "http://api.exiletools.com/class-rank?league=" . league . "&char=" . charName . "&format=json"
  801.  
  802. SetTimer, loadLadder, 1000
  803. FileDelete, ladder.jsonFileDelete, classLadder.json
  804. run "Lib\QDL.ahk" %url% "ladder.json"
  805. run "Lib\QDL.ahk" %url2% "classLadder.json"
  806. return
  807. loadLadder:
  808. IfExist, ladder.json
  809. {
  810. IfExist, classLadder.json
  811. {
  812. SetTimer, loadLadder, off
  813. FileRead, ladderString, ladder.json
  814. JSON_obj := json_toobj(ladderString)
  815.  
  816. For key, value in JSON_obj
  817. combined := key
  818. updated := JSON_obj[combined].updated
  819. if ( updated = lastUpdated )
  820. {
  821. updateTrackingTimer := 60000 ; Wait one minute to check again
  822. return
  823. }
  824. lastUpdated := updated
  825. rank := JSON_obj[combined].rank
  826. if ( !rank ) {
  827. rank := "Min Lv:"
  828. FileDelete, league.json
  829. url := "http://exiletools.com/api/ladder?league=" . league . "&status=1"
  830. SetTimer, loadMin, 1000
  831. run "Lib\QDL.ahk" %url% "league.json"
  832. return
  833. loadMin:
  834. IfExist, league.json
  835. {
  836. SetTimer, loadMin, off
  837. FileRead, leagueString, league.json
  838. leagueObj := json_toobj(leagueString)
  839. movedRanks := leagueObj[league].toGetOnLadder.level
  840. above1 = N/A
  841. above2 = N/A
  842. below1 = N/A
  843. below2 = N/A
  844. GuiControl,1:,guiAbove1, %above1%
  845. GuiControl,1:,guiAbove2, %above2%
  846. GuiControl,1:,guiBelow1, %below1%
  847. GuiControl,1:,guiBelow2, %below2%
  848.  
  849. GuiControl,1:, guiRank, %rank%
  850. GuiControl,1:, guiMovedRanks, %movedRanks%
  851. return
  852. } else {
  853. return
  854. }
  855. } else {
  856. r2 := 0
  857. FileRead, classLadderString, classLadder.json
  858. ClassLadderJSON := json_toobj(classLadderString)
  859. for k, v in ClassLadderJSON {
  860. for k2, v2 in ClassLadderJSON[k] {
  861. if ( k2 = "total" ) {
  862. r2 = %v2%
  863. }
  864. }
  865. }
  866. movedRanks := JSON_obj[combined].movedRanks
  867. above1 := JSON_obj[combined].xp_to_rank_above[rank-1]
  868. above1 := RegExReplace(above1, "(\d)(?=(?:\d{3})+(?:\.|$))", "$1,")
  869. above2 := JSON_obj[combined].xp_to_rank_above[rank-2]
  870. above2 := RegExReplace(above2, "(\d)(?=(?:\d{3})+(?:\.|$))", "$1,")
  871. below1 := JSON_obj[combined].xp_to_rank_below[rank+1]
  872. below1 := RegExReplace(below1, "(\d)(?=(?:\d{3})+(?:\.|$))", "$1,")
  873. below2 := JSON_obj[combined].xp_to_rank_below[rank+2]
  874. below2 := RegExReplace(below2, "(\d)(?=(?:\d{3})+(?:\.|$))", "$1,")
  875. aliveRank := JSON_obj[combined].aliveRank
  876. rank := "Rank: " . rank
  877. if ( movedRanks < 0 ) {
  878. Gui, 1:Font, cRed
  879. GuiControl, 1:Font, guiMovedRanks
  880. }
  881. if ( movedRanks > 0 ) {
  882. Gui, 1:Font, cGreen
  883. GuiControl, 1:Font, guiMovedRanks
  884. }
  885. GuiControl,1:,guiAbove1, %above1%
  886. GuiControl,1:,guiAbove2, %above2%
  887. GuiControl,1:,guiBelow1, %below1%
  888. GuiControl,1:,guiBelow2, %below2%
  889.  
  890. GuiControl,1:, guiRank, %rank%
  891. GuiControl,1:, guiMovedRanks, %movedRanks%
  892. GuiControl,1:, guiAliveRank, %aliveRank%
  893. GuiControl,1:, guiClassRank, %r2%
  894. }
  895. return
  896. } else {
  897. return
  898. }
  899. } else {
  900. return
  901. }
  902. }
  903. return
  904. }
  905.  
  906. hotkeys(){
  907. optionsCommand:
  908. global
  909. Gui, 2:Show,, Macro Settings Version %macroVersion% :: AHK Version %A_AhkVersion%
  910. return
  911. }
  912.  
  913. submit(){
  914. updateHotkeys:
  915. global
  916. Gui, 2:Submit
  917. updsettings := "[variables]`n"
  918. updsettings .= "CharacterName=" . guiChar . "`n"
  919. updsettings .= "League=" . guiLeague . "`n"
  920. updsettings .= "PoeSteam=" . guiSteam . "`n"
  921. updsettings .= "UpdateTimer=" . guiUpdate . "`n"
  922. updsettings .= "XOffset=" . guiXOffset . "`n"
  923. updsettings .= "YOffset=" . guiYOffset . "`n"
  924. updsettings .= "MonitorWhispers=" . guiMonitorWhispers . "`n"
  925. updsettings .= "MonitorWhispersDelay=" . guiMonitorWhispersDelay . "`n"
  926. updsettings .= "LogFileLocation=" . logFileLocation . "`n"
  927. updsettings .= "OverlayToggle=" . toggle . "`n"
  928. updsettings .= "SoundSelector=" . guiSoundSelector . "`n"
  929. updsettings .= "Beta=" . guibeta . "`n"
  930. updsettings .= "Diablo2=" . guidiablo2 . "`n"
  931. updsettings .= "[whisperMessages]`n"
  932. updsettings .= "wm1=" . guiwm1 . "`n"
  933. updsettings .= "wm2=" . guiwm2 . "`n"
  934. updsettings .= "wm3=" . guiwm3 . "`n"
  935. updsettings .= "wm4=" . guiwm4 . "`n"
  936. updsettings .= "wm5=" . guiwm5 . "`n"
  937. updsettings .= "[partyMessages]`n"
  938. updsettings .= "pm1=" . guipm1 . "`n"
  939. updsettings .= "pm2=" . guipm2 . "`n"
  940. updsettings .= "pm3=" . guipm3 . "`n"
  941. updsettings .= "pm4=" . guipm4 . "`n"
  942. updsettings .= "pm5=" . guipm5 . "`n"
  943. updsettings .= "[hotkeys]`n"
  944. updsettings .= "logout=" . guihotkeyLogout . "`n"
  945. updsettings .= "superLogout=" . guihotkeySuperLogout . "`n"
  946. updsettings .= "oos=" . guihotkeyOos . "`n"
  947. updsettings .= "remaining=" . guihotkeyRemaining . "`n"
  948. updsettings .= "itemLevel=" . guihotkeyItemLevel . "`n"
  949. updsettings .= "hideout=" . guihotkeyHideout . "`n"
  950. updsettings .= "invite=" . guihotkeyInvite . "`n"
  951. updsettings .= "toggleOverlay=" . guihotkeyToggleOverlay . "`n"
  952. updsettings .= "options=" . guihotkeyOptions . "`n"
  953. updsettings .= "wm1=" . guihotkeywm1 . "`n"
  954. updsettings .= "wm2=" . guihotkeywm2 . "`n"
  955. updsettings .= "wm3=" . guihotkeywm3 . "`n"
  956. updsettings .= "wm4=" . guihotkeywm4 . "`n"
  957. updsettings .= "wm5=" . guihotkeywm5 . "`n"
  958. updsettings .= "pm1=" . guihotkeypm1 . "`n"
  959. updsettings .= "pm2=" . guihotkeypm2 . "`n"
  960. updsettings .= "pm3=" . guihotkeypm3 . "`n"
  961. updsettings .= "pm4=" . guihotkeypm4 . "`n"
  962. updsettings .= "pm5=" . guihotkeypm5
  963.  
  964. FileDelete settings.ini
  965. FileAppend, %updsettings%, settings.ini, UTF-16
  966.  
  967. readFromFile()
  968.  
  969. return
  970. }
  971.  
  972. updateFiles(){
  973.  
  974. }
  975.  
  976. readFromFile(){
  977. global
  978. ;reset hotkeys ughh.
  979. Hotkey, IfWinActive, Path of Exile
  980. If hotkeyLogout
  981. Hotkey,% hotkeyLogout, logoutCommand, Off
  982. If hotkeyOos
  983. Hotkey,% hotkeyOos, oosCommand, Off
  984. If hotkeyRemaining
  985. Hotkey,% hotkeyRemaining, remainingCommand, Off
  986. If hotkeyItemLevel
  987. Hotkey,% hotkeyItemLevel, itemLevelCommand, Off
  988. If hotkeyHideout
  989. Hotkey,% hotkeyHideout, hideoutCommand, Off
  990. If hotkeyInvite
  991. Hotkey,% hotkeyInvite, inviteCommand, Off
  992. If hotkeyToggleOverlay
  993. Hotkey,% hotkeyToggleOverlay, toggleOverlayCommand, Off
  994. If hotkeywm1
  995. Hotkey,% hotkeywm1, whisperCommand1, Off
  996. If hotkeywm2
  997. Hotkey,% hotkeywm2, whisperCommand1, Off
  998. If hotkeywm3
  999. Hotkey,% hotkeywm3, whisperCommand1, Off
  1000. If hotkeywm4
  1001. Hotkey,% hotkeywm4, whisperCommand1, Off
  1002. If hotkeywm5
  1003. Hotkey,% hotkeywm5, whisperCommand1, Off
  1004. If hotkeypm1
  1005. Hotkey,% hotkeypm1, partyCommand1, Off
  1006. If hotkeypm2
  1007. Hotkey,% hotkeypm2, partyCommand2, Off
  1008. If hotkeypm3
  1009. Hotkey,% hotkeypm3, partyCommand3, Off
  1010. If hotkeypm4
  1011. Hotkey,% hotkeypm4, partyCommand4, Off
  1012. If hotkeypm5
  1013. Hotkey,% hotkeypm5, partyCommand5, Off
  1014.  
  1015. Hotkey, IfWinActive
  1016. If hotkeyOptions
  1017. Hotkey,% hotkeyOptions, optionsCommand, Off
  1018. If hotkeySuperLogout
  1019. Hotkey,% hotkeySuperLogout, superLogoutCommand, Off
  1020. Hotkey, IfWinActive, Path of Exile
  1021.  
  1022. ; variables
  1023. IniRead, charName, settings.ini, variables, CharacterName
  1024. IniRead, league, settings.ini, variables, League
  1025. IniRead, steam, settings.ini, variables, PoeSteam
  1026. IniRead, sleepTime, settings.ini, variables, UpdateTimer
  1027. IniRead, xOffset, settings.ini, variables, XOffset
  1028. IniRead, yOffset, settings.ini, variables, YOffset
  1029. IniRead, monitorWhispers, settings.ini, variables, MonitorWhispers
  1030. IniRead, monitorWhispersDelay, settings.ini, variables, MonitorWhispersDelay
  1031. IniRead, logFileLocation, settings.ini, variables, LogFileLocation
  1032. IniRead, toggle, settings.ini, variables, OverlayToggle
  1033. IniRead, soundSelector, settings.ini, variables, SoundSelector
  1034. IniRead, beta, settings.ini, variables, Beta
  1035. IniRead, diablo2, settings.ini, variables, Diablo2
  1036. ; whisper messages
  1037. IniRead, wm1, settings.ini, whisperMessages, wm1
  1038. IniRead, wm2, settings.ini, whisperMessages, wm2
  1039. IniRead, wm3, settings.ini, whisperMessages, wm3
  1040. IniRead, wm4, settings.ini, whisperMessages, wm4
  1041. IniRead, wm5, settings.ini, whisperMessages, wm5
  1042. ;party messages
  1043. IniRead, pm1, settings.ini, partyMessages, pm1
  1044. IniRead, pm2, settings.ini, partyMessages, pm2
  1045. IniRead, pm3, settings.ini, partyMessages, pm3
  1046. IniRead, pm4, settings.ini, partyMessages, pm4
  1047. IniRead, pm5, settings.ini, partyMessages, pm5
  1048. ;hotkeys
  1049. IniRead, hotkeyLogout, settings.ini, hotkeys, logout, %A_Space%
  1050. IniRead, hotkeySuperLogout, settings.ini, hotkeys, superLogout, %A_Space%
  1051. IniRead, hotkeyOos, settings.ini, hotkeys, oos, %A_Space%
  1052. IniRead, hotkeyRemaining, settings.ini, hotkeys, remaining, %A_Space%
  1053. IniRead, hotkeyItemLevel, settings.ini, hotkeys, itemLevel, %A_Space%
  1054. IniRead, hotkeyHideout, settings.ini, hotkeys, hideout, %A_Space%
  1055. IniRead, hotkeyInvite, settings.ini, hotkeys, invite, %A_Space%
  1056. IniRead, hotkeyToggleOverlay, settings.ini, hotkeys, toggleOverlay, %A_Space%
  1057. IniRead, hotkeyOptions, settings.ini, hotkeys, options, %A_Space%
  1058. IniRead, hotkeywm1, settings.ini, hotkeys, wm1, %A_Space%
  1059. IniRead, hotkeywm2, settings.ini, hotkeys, wm2, %A_Space%
  1060. IniRead, hotkeywm3, settings.ini, hotkeys, wm3, %A_Space%
  1061. IniRead, hotkeywm4, settings.ini, hotkeys, wm4, %A_Space%
  1062. IniRead, hotkeywm5, settings.ini, hotkeys, wm5, %A_Space%
  1063. IniRead, hotkeypm1, settings.ini, hotkeys, pm1, %A_Space%
  1064. IniRead, hotkeypm2, settings.ini, hotkeys, pm2, %A_Space%
  1065. IniRead, hotkeypm3, settings.ini, hotkeys, pm3, %A_Space%
  1066. IniRead, hotkeypm4, settings.ini, hotkeys, pm4, %A_Space%
  1067. IniRead, hotkeypm5, settings.ini, hotkeys, pm5, %A_Space%
  1068.  
  1069. Hotkey, IfWinActive, Path of Exile
  1070. If hotkeyLogout
  1071. Hotkey,% hotkeyLogout, logoutCommand, On
  1072. If hotkeyOos
  1073. Hotkey,% hotkeyOos, oosCommand, On
  1074. If hotkeyRemaining
  1075. Hotkey,% hotkeyRemaining, remainingCommand, On
  1076. If hotkeyItemLevel
  1077. Hotkey,% hotkeyItemLevel, itemLevelCommand, On
  1078. If hotkeyHideout
  1079. Hotkey,% hotkeyHideout, hideoutCommand, On
  1080. If hotkeyInvite
  1081. Hotkey,% hotkeyInvite, inviteCommand, On
  1082. If hotkeyToggleOverlay
  1083. Hotkey,% hotkeyToggleOverlay, toggleOverlayCommand, On
  1084. If hotkeywm1
  1085. Hotkey,% hotkeywm1, whisperCommand1, On
  1086. If hotkeywm2
  1087. Hotkey,% hotkeywm2, whisperCommand2, On
  1088. If hotkeywm3
  1089. Hotkey,% hotkeywm3, whisperCommand3, On
  1090. If hotkeywm4
  1091. Hotkey,% hotkeywm4, whisperCommand4, On
  1092. If hotkeywm5
  1093. Hotkey,% hotkeywm5, whisperCommand5, On
  1094. If hotkeypm1
  1095. Hotkey,% hotkeypm1, partyCommand1, On
  1096. If hotkeypm2
  1097. Hotkey,% hotkeypm2, partyCommand2, On
  1098. If hotkeypm3
  1099. Hotkey,% hotkeypm3, partyCommand3, On
  1100. If hotkeypm4
  1101. Hotkey,% hotkeypm4, partyCommand4, On
  1102. If hotkeypm5
  1103. Hotkey,% hotkeypm5, partyCommand5, On
  1104.  
  1105. Hotkey, IfWinActive
  1106. If hotkeyOptions
  1107. Hotkey,% hotkeyOptions, optionsCommand, On
  1108. else {
  1109. Hotkey,F10, optionsCommand, On
  1110. msgbox You dont have some hotkeys set!`nPlease hit F10 to open up your config prompt and please configure your hotkeys (Path of Exile has to be in focus).`nThe way you configure hotkeys is now in the GUI (default F10). Otherwise, you didn't put a hotkey for the options menu. You need that silly.
  1111. }
  1112. If hotkeySuperLogout
  1113. Hotkey,% hotkeySuperLogout, superLogoutCommand, On
  1114. Hotkey, IfWinActive, Path of Exile
  1115.  
  1116. ; extra checks
  1117.  
  1118. if monitorWhispers = ERROR
  1119. monitorWhispers := 0
  1120. if monitorWhispersDelay = ERROR
  1121. monitorWhispersDelay := 10000
  1122. if monitorWhispersDelay < 10000
  1123. monitorWhispersDelay := 10000
  1124. if beta = ERROR
  1125. beta = 0
  1126. if diablo2 = ERROR
  1127. diablo2 = 0
  1128.  
  1129. if ( steam ) {
  1130. cportsCommand := "cports.exe /close * * * * PathOfExileSteam.exe"
  1131. executable := "PathOfExileSteam.exe"
  1132. } else {
  1133. cportsCommand := "cports.exe /close * * * * PathOfExile.exe"
  1134. executable := "PathOfExile.exe"
  1135. }
  1136.  
  1137. if ( diablo2 ) {
  1138. cportsCommand := "cports.exe /close * * * * Game.exe"
  1139. executable := "Game.exe"
  1140. }
  1141.  
  1142. updateTrackingTimer := 5000
  1143. monitorWhispersTimer := monitorWhispersDelay
  1144. }
  1145.  
  1146. ; ; ERROR LIST
  1147. ; min lv = null : you typed in the league name wrong.
  1148. ; ED01 : Error downloading rank from http://exiletools.com/ , their server might be unavailible.
  1149. ; ED02 -> ED04 : Error downloading currports from my website. http://www.nirsoft.net/utils/cports.html holds the original file.
  1150. ; ED05 : Error downloading ladder stats from http://exiletools.com/ , their server might be unavailible.
  1151. ; ED06 : Error checking for new version.
  1152. ; ED07 : Error downloading newest version of ahk script.
  1153. ; ED08 : Error downloading newest changelog.
  1154. ; ED09 : Error downloading list of active leagues
  1155. ; ED10 : Logged out with cports No process
  1156. ; ED11 : Logged out with cports TcpTable Failure
  1157.  
  1158.  
  1159. ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; JSON -> AHK Obj parser by VxE ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1160.  
  1161. ; Copyright © 2013 VxE. All rights reserved.
  1162.  
  1163. ; Uses a two-pass iterative approach to deserialize a json string
  1164. json_toobj( str ) {
  1165.  
  1166. quot := """" ; firmcoded specifically for readability. Hardcode for (minor) performance gain
  1167. ws := "`t`n`r " Chr(160) ; whitespace plus NBSP. This gets trimmed from the markup
  1168. obj := {} ; dummy object
  1169. objs := [] ; stack
  1170. keys := [] ; stack
  1171. isarrays := [] ; stack
  1172. literals := [] ; queue
  1173. y := nest := 0
  1174.  
  1175. ; First pass swaps out literal strings so we can parse the markup easily
  1176. StringGetPos, z, str, %quot% ; initial seek
  1177. while !ErrorLevel
  1178. {
  1179. ; Look for the non-literal quote that ends this string. Encode literal backslashes as '\u005C' because the
  1180. ; '\u..' entities are decoded last and that prevents literal backslashes from borking normal characters
  1181. StringGetPos, x, str, %quot%,, % z + 1
  1182. while !ErrorLevel
  1183. {
  1184. StringMid, key, str, z + 2, x - z - 1
  1185. StringReplace, key, key, \\, \u005C, A
  1186. If SubStr( key, 0 ) != "\"
  1187. Break
  1188. StringGetPos, x, str, %quot%,, % x + 1
  1189. }
  1190. ; StringReplace, str, str, %quot%%t%%quot%, %quot% ; this might corrupt the string
  1191. str := ( z ? SubStr( str, 1, z ) : "" ) quot SubStr( str, x + 2 ) ; this won't
  1192.  
  1193. ; Decode entities
  1194. StringReplace, key, key, \%quot%, %quot%, A
  1195. StringReplace, key, key, \b, % Chr(08), A
  1196. StringReplace, key, key, \t, % A_Tab, A
  1197. StringReplace, key, key, \n, `n, A
  1198. StringReplace, key, key, \f, % Chr(12), A
  1199. StringReplace, key, key, \r, `r, A
  1200. StringReplace, key, key, \/, /, A
  1201. while y := InStr( key, "\u", 0, y + 1 )
  1202. if ( A_IsUnicode || Abs( "0x" SubStr( key, y + 2, 4 ) ) < 0x100 )
  1203. key := ( y = 1 ? "" : SubStr( key, 1, y - 1 ) ) Chr( "0x" SubStr( key, y + 2, 4 ) ) SubStr( key, y + 6 )
  1204.  
  1205. literals.insert(key)
  1206.  
  1207. StringGetPos, z, str, %quot%,, % z + 1 ; seek
  1208. }
  1209.  
  1210. ; Second pass parses the markup and builds the object iteratively, swapping placeholders as they are encountered
  1211. key := isarray := 1
  1212.  
  1213. ; The outer loop splits the blob into paths at markers where nest level decreases
  1214. Loop Parse, str, % "]}"
  1215. {
  1216. StringReplace, str, A_LoopField, [, [], A ; mark any array open-brackets
  1217.  
  1218. ; This inner loop splits the path into segments at markers that signal nest level increases
  1219. Loop Parse, str, % "[{"
  1220. {
  1221. ; The first segment might contain members that belong to the previous object
  1222. ; Otherwise, push the previous object and key to their stacks and start a new object
  1223. if ( A_Index != 1 )
  1224. {
  1225. objs.insert( obj )
  1226. isarrays.insert( isarray )
  1227. keys.insert( key )
  1228. obj := {}
  1229. isarray := key := Asc( A_LoopField ) = 93
  1230. }
  1231.  
  1232. ; arrrrays are made by pirates and they have index keys
  1233. if ( isarray )
  1234. {
  1235. Loop Parse, A_LoopField, `,, % ws "]"
  1236. if ( A_LoopField != "" )
  1237. obj[key++] := A_LoopField = quot ? literals.remove(1) : A_LoopField
  1238. }
  1239. ; otherwise, parse the segment as key/value pairs
  1240. else
  1241. {
  1242. Loop Parse, A_LoopField, `,
  1243. Loop Parse, A_LoopField, :, % ws
  1244. if ( A_Index = 1 )
  1245. key := A_LoopField = quot ? literals.remove(1) : A_LoopField
  1246. else if ( A_Index = 2 && A_LoopField != "" )
  1247. obj[key] := A_LoopField = quot ? literals.remove(1) : A_LoopField
  1248. }
  1249. nest += A_Index > 1
  1250. } ; Loop Parse, str, % "[{"
  1251.  
  1252. If !--nest
  1253. Break
  1254.  
  1255. ; Insert the newly closed object into the one on top of the stack, then pop the stack
  1256. pbj := obj
  1257. obj := objs.remove()
  1258. obj[key := keys.remove()] := pbj
  1259. If ( isarray := isarrays.remove() )
  1260. key++
  1261.  
  1262. } ; Loop Parse, str, % "]}"
  1263.  
  1264. Return obj
  1265. } ; json_toobj( str )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement