Guest User

Untitled

a guest
Jun 10th, 2020
687
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ; This script uses Path of Exile Weapon DPS Calculator
  2. ; (https://pdejan.github.io/poe_wdps/)
  3. ; This script uses Aeons PoEDisplay.ahk
  4. ; https://gist.github.com/aeons/7432713
  5.  
  6. #NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
  7. #Persistent ; Stay open in background
  8. SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
  9. StringCaseSense, On ; Match strings with case.
  10.  
  11. ; Options
  12. ; Pixels mouse must move to auto-dismiss tooltip
  13. MouseMoveThreshold := 40
  14. ; Menu tooltip
  15. Menu, tray, Tip, PoE DPS Display (by dilof and Mih0l)
  16.  
  17. FindItemStats()
  18. {
  19.  
  20.     NameIsDone := False
  21.     IsWeapon := False
  22.     Level := 0
  23.     PhysLo := 0
  24.     PhysHi := 0
  25.     ChaosLo :=0
  26.     ChaosHi :=0
  27.     Quality := 0
  28.     AttackSpeed := 0
  29.     PhysMult := 0
  30.    
  31.     Loop, Parse, Clipboard, `n, `r
  32.     {
  33.  
  34.         ; Clipboard must have "Rarity:" in the first line
  35.         If A_Index = 1
  36.         {
  37.             IfNotInString, A_LoopField, Rarity:
  38.             {
  39.                 Exit
  40.                    
  41.             }
  42.             Else
  43.             {
  44.                 Continue
  45.                        
  46.             }
  47.         }
  48.        
  49.         ; Get item influence Elder
  50.         IfInString, A_LoopField, Elder Item
  51.         {
  52.             itemInfluence = Elder Item
  53.             Continue
  54.         }  
  55.        
  56.         ; Get item influence Shaper
  57.         IfInString, A_LoopField, Shaper Item
  58.         {
  59.             itemInfluence = Shaper Item
  60.             Continue
  61.         }  
  62.        
  63.         ; Get item influence Redeemer
  64.         IfInString, A_LoopField, Redeemer Item
  65.         {
  66.             itemInfluence = Redeemer Item
  67.             Continue
  68.         }  
  69.        
  70.         ; Get item influence Warlord
  71.         IfInString, A_LoopField, Warlord Item
  72.         {
  73.             itemInfluence = Warlord Item
  74.             Continue
  75.         }  
  76.        
  77.         ; Get item influence Crusader
  78.         IfInString, A_LoopField, Crusader Item
  79.         {
  80.             itemInfluence = Crusader Item
  81.             Continue
  82.         }  
  83.        
  84.         ; Get item influence Hunter
  85.         IfInString, A_LoopField, Hunter Item
  86.         {
  87.             itemInfluence = Hunter Item
  88.             Continue
  89.         }  
  90.        
  91.         ; Get item influence Synthesised
  92.         IfInString, A_LoopField, Synthesised Item
  93.         {
  94.             itemInfluence = Synthesised Item
  95.             Continue
  96.         }  
  97.  
  98.         ; Get quality
  99.         IfInString, A_LoopField, Quality:
  100.        {
  101.             StringSplit, Arr,  A_LoopField, %A_Space%, +`%
  102.             Quality := Arr2
  103.             Continue
  104.         }
  105.  
  106.         ; Get total chaos damage
  107.         IfInString, A_LoopField, Chaos Damage:
  108.        {
  109.             IsWeapon = True
  110.             StringSplit, Arr, A_LoopField, %A_Space%
  111.             StringSplit, Arr, Arr3, -
  112.             ChaosLo := Arr1
  113.             ChaosHi := Arr2
  114.             Continue
  115.         }
  116.        
  117.         ; Get total physical damage
  118.         IfInString, A_LoopField, Physical Damage:
  119.        {
  120.             IsWeapon = True
  121.             StringSplit, Arr, A_LoopField, %A_Space%
  122.             StringSplit, Arr, Arr3, -
  123.             PhysLo := Arr1
  124.             PhysHi := Arr2
  125.             Continue
  126.         }
  127.        
  128.         ; These only make sense for weapons
  129.         If IsWeapon
  130.         {
  131.             ; Get attack speed
  132.             IfInString, A_LoopField, Attacks per Second:
  133.            {
  134.                 StringSplit, Arr, A_LoopField, %A_Space%
  135.                 AttackSpeed := Arr4
  136.                 Continue
  137.             }
  138.         }
  139.     }
  140.    
  141.     global X
  142.     global Y
  143.     MouseGetPos, X, Y
  144.  
  145.     wb := ComObjCreate("InternetExplorer.Application")  ;// Create an IE object
  146.     wb.Visible := false                                  ;// Make the IE object visible
  147.     wb.Navigate("https://pdejan.github.io/poe_wdps/")                   ;// Navigate to a webpage
  148.     while wb.busy or wb.ReadyState != 4
  149.        Sleep 10
  150.     wb.document.querySelector("textarea").value := Clipboard
  151.     wb.document.getElementsByClassName("btn")[0].click()
  152.    
  153.     phydps := wb.document.getElementById("phydps").innerText
  154.     eledps := wb.document.getElementById("eledps").innerText
  155.     totaldps := wb.document.getElementById("totaldps").innerText
  156.     chaosdps := ((ChaosLo + ChaosHi ) / 2) * AttackSpeed   
  157.     phydps := format("{:0.2f}", phydps)
  158.     eledps := format("{:0.2f}", eledps)
  159.     totaldps := format("{:0.2f}", totaldps)
  160.     chaosdps := format("{:0.2f}", chaosdps)
  161.    
  162.     ;Q20 calculations
  163.     if (Quality < 20)
  164.     {
  165.         PhysBaseCurrent := ((PhysLo + PhysHi) / 2)
  166.         PhysBase := PhysBaseCurrent * 100 / (100 + Quality)
  167.         Q20Phys := PhysBase * 1.2
  168.         Q20PhysLo := Q20Phys - (PhysBase * 0.25)
  169.         Q20PhysLo := format("{:0.1f}", Q20PhysLo)
  170.         Q20PhysHi := Q20Phys + (PhysBase * 0.25)
  171.         Q20PhysHi := format("{:0.1f}", Q20PhysHi)
  172.         StringRight, Q20PhysLoEnds, Q20PhysLo, 1
  173.         StringRight, Q20PhysHiEnds, Q20PhysHi, 1
  174.         AddEnds := Q20PhysLoEnds + Q20PhysHiEnds
  175.             if (AddEnds >= 10)
  176.             {
  177.                 Q20PhysLo := ceil(Q20PhysLo)
  178.                 Q20PhysHigh := ceil(Q20PhysHigh)
  179.             }
  180.         ClipboardQ20 := Clipboard
  181.         Loop, Parse, ClipboardQ20, `n, `r
  182.         {
  183.             IfInString, A_LoopField, Quality:
  184.             {
  185.                 StringReplace, ClipboardQ20, ClipboardQ20, %Quality%, 20
  186.             }  
  187.             IfInString, A_LoopField, Physical Damage:
  188.             {
  189.                 StringReplace, ClipboardQ20, ClipboardQ20, %PhysLo%, %Q20PhysLo%
  190.                 StringReplace, ClipboardQ20, ClipboardQ20, %PhysHi%, %Q20PhysHi%
  191.             }  
  192.         }
  193.         wb.document.querySelector("textarea").value := ClipboardQ20
  194.         wb.document.getElementsByClassName("btn")[0].click()
  195.    
  196.         Q20phydps := wb.document.getElementById("phydps").innerText
  197.         Q20totaldps := wb.document.getElementById("totaldps").innerText
  198.         Q20phydps := format("{:0.2f}", Q20phydps)
  199.         Q20totaldps := format("{:0.2f}", Q20totaldps)
  200.        
  201.     }
  202.    
  203.     if (phydps < 0) || (eledps < 0) || (totaldps < 0)
  204.     {
  205.         phydps := 0
  206.         eledps := 0
  207.         totaldps := 0
  208.     }  
  209.  
  210.     wb.quit
  211.  
  212.         if IsWeapon ; Show tooltip only if it's a weapon
  213.         {
  214.             if (itemInfluence = null) ; influence = 0 / dont show influence
  215.             {
  216.                 if (Quality < 20) ; Quality < 20 - show quality DPS
  217.                 {
  218.                     TT = Phys DPS: %phydps%`nElem DPS: %eledps%`nChaos DPS: %chaosdps%`nTotal DPS: %totaldps%`nQ20 DPS: %Q20totaldps%
  219.                 }
  220.                 else
  221.                 {
  222.                     TT = Phys DPS: %phydps%`nElem DPS: %eledps%`nChaos DPS: %chaosdps%`nTotal DPS: %totaldps%
  223.                 }
  224.             }
  225.             else ; If item has influence
  226.             {
  227.                 if (Quality < 20)
  228.                 {
  229.                     TT = Phys DPS: %phydps%`nElem DPS: %eledps%`nChaos DPS: %chaosdps%`nTotal DPS: %totaldps%`nQ20 DPS: %Q20totaldps%`n%itemInfluence%
  230.                 }
  231.                 else
  232.                 {
  233.                     TT = Phys DPS: %phydps%`nElem DPS: %eledps%`nChaos DPS: %chaosdps%`nTotal DPS: %totaldps%`n%itemInfluence%     
  234.                 }
  235.             }
  236.         }
  237.             else ; Anything else other than weapon
  238.             {
  239.            
  240.                 return ; Don't display
  241.             }
  242. customTooltip(TT)
  243. SetTimer, ToolTipTimer, 100
  244. }
  245.  
  246. customTooltip(TT)
  247. {
  248.     Gui, +AlwaysOnTop -Border -SysMenu +Owner -Caption +ToolWindow
  249.     Gui, Color, 111111
  250.     lines := StrSplit(TT, "`n")
  251.     Y := 8
  252.     Loop % lines.length()
  253.     {
  254.         line++
  255.         currentLine = % lines[A_Index]
  256.         If InStr(currentLine, "Total DPS:") || InStr(currentLine, "Elder Item") || InStr(currentLine, "Shaper Item") || InStr(currentLine, "Redeemer Item") || InStr(currentLine, "Warlord Item") || InStr(currentLine, "Hunter Item") || InStr(currentLine, "Crusader Item") || InStr(currentLine, "Synthesised Item") ||
  257.         {
  258.             If InStr(currentLine, "Elder Item")
  259.             {
  260.                 Gui, Font, s10 , Comic Sans MS
  261.                 Gui, Add, text, x8 c591f82, %currentLine%
  262.             }
  263.                 else If InStr(currentLine, "Redeemer Item")
  264.                 {
  265.                     Gui, Font, s10 , Comic Sans MS
  266.                     Gui, Add, text, x8 c336291, %currentLine%
  267.                 }
  268.                 else If InStr(currentLine, "Warlord Item")
  269.                 {
  270.                     Gui, Font, s10 , Comic Sans MS
  271.                     Gui, Add, text, x8 c8f5004, %currentLine%
  272.                 }
  273.                 else If InStr(currentLine, "Hunter Item")
  274.                 {
  275.                     Gui, Font, s10 , Comic Sans MS
  276.                     Gui, Add, text, x8 c365c1d, %currentLine%
  277.                 }
  278.                 else If InStr(currentLine, "Crusader Item")
  279.                 {
  280.                     Gui, Font, s10 , Comic Sans MS
  281.                     Gui, Add, text, x8 c349191, %currentLine%
  282.                 }
  283.                 else If InStr(currentLine, "Synthesised Item")
  284.                 {
  285.                     Gui, Font, s10 , Comic Sans MS
  286.                     Gui, Add, text, x8 c5d8194, %currentLine%
  287.                 }
  288.                 else If InStr(currentLine, "Shaper Item")
  289.                 {
  290.                     Gui, Font, s10 , Comic Sans MS
  291.                     Gui, Add, text, x8 c30455c, %currentLine%
  292.                 }
  293.                 else If InStr(currentLine, "Total DPS:")
  294.                 {
  295.                     Gui, Add, text, x8 c751a1a, %currentLine%
  296.                 }
  297.         }
  298.         else
  299.         {
  300.             Gui, Font, s9
  301.             Gui, Add, text, x8 cWhite, %currentLine%
  302.         }
  303.         Y := Y + 15
  304.     }
  305.     MouseGetPos, X, Y
  306.     X := X + 20 ; X tooltip position from mouse
  307.     Y := Y + 20 ; Y tooltip position from mouse
  308.     Gui, Show, NoActivate x%X% y%Y%, tooltipToggle
  309.     WinSet, Transparent, 230, ahk_class AutoHotkeyGUI ; Set window transparency
  310. }
  311.  
  312. ; Tick every 100 ms
  313. ; Remove tooltip if mouse is moved
  314. ToolTipTimer:
  315. ToolTipTimeout += 1
  316. MouseGetPos, CurrX, CurrY
  317. MouseMoved := (CurrX - X)**2 + (CurrY - Y)**2 > MouseMoveThreshold**2
  318. If (MouseMoved or ToolTipTimeout >= 100) ; 10 seconds to remove the tooltip if mouse hasn't been moved
  319. {
  320.     SetTimer, ToolTipTimer, Off
  321.     ToolTipTimeout := 0
  322.     Gui, Destroy
  323. }
  324. return
  325.  
  326. OnClipBoardChange:
  327. FindItemStats()
Add Comment
Please, Sign In to add comment