Guest User

Untitled

a guest
Sep 19th, 2014
278
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.79 KB | None | 0 0
  1. ; POE Simple Price Check
  2. ; Version: 2 (2014/08/13)
  3. ;
  4. ; Written by Pete Waterman aka trackpete on reddit, pwx* in game
  5. ; email: [email protected] | personal website: whoispete.com
  6. ;
  7. ; The latest version of this can always be found here:
  8. ;
  9. ; http://poe.pwx.me
  10. ;
  11. ; Author's Note: I'm not an AHK programmer, I learned everything on the fly. There is a
  12. ; good chance this code will look sloppy to experienced AHK programmers, if you have any
  13. ; advice or would like to re-write it, please feel free and let me know.
  14. ;
  15. ; USAGE NOTE: This requires your Path of Exile to be in Windowed (or Windowed Full Screen)
  16. ; to work properly, otherwise the popup will just show in the background and you won't
  17. ; see it.
  18. ;
  19. ; CONFIGURATION NOTE: You must configure the LeagueName properly.
  20. ;
  21. ; Huge thanks to poe.xyz.is for allowing this to use their service
  22.  
  23. ; == Startup Options ===========================================
  24. #SingleInstance force
  25. #NoEnv
  26. #Persistent ; Stay open in background
  27. SendMode Input
  28. StringCaseSense, On ; Match strings with case.
  29. Menu, tray, Tip, POE Simple Price Check
  30.  
  31. ; == Variables and Options and Stuff ===========================
  32. ; Option for League from poe.xyz.is, set appropriately! The available
  33. ; Leagues at time of release are included, uncomment the one you want
  34. ; and comment out the others
  35. ;
  36. ; YOU MUST SET THIS TO THE PROPER LEAGUE YOU WANT TO PLAY OR IT WILL
  37. ; USE A DEFAULT! (sorry for shouting)
  38.  
  39. LeagueName = Rampage
  40. ;LeagueName = Hardcore
  41.  
  42.  
  43. ; This variable indicates how many results to show for each amount in a currency type.
  44. ; For example, if there are 15 different amounts listed for chaos (1c, 3c, 5c, 10c, 15c, etc.),
  45. ; the default will only show the cheapest 3 amounts (1c, 3c, 5c). You can increase this to
  46. ; whatever you'd like, but it may get unwieldy
  47. Show = 3
  48.  
  49. ; Decoder URL - No need to change this! This is a development option.
  50. ; Instead of doing all the processing in AHK, this script simply sends basic
  51. ; item information to a decoder service I run. The decoder service then checks
  52. ; that item information on poe.xyz.is (with permission). It also caches duplicate
  53. ; lookups to reduce load on poe.xyz.is system, any duplicate lookup in a ~30min
  54. ; period will hit the cache instead.
  55. Global URL = "http://poe.pwx.me/cgi-bin/poe-decode-text?v=2&show= " . Show . "league=" . LeagueName . "&s="
  56.  
  57. ; How much the mouse needs to move before the hotkey goes away, not a big deal, change to whatever
  58. MouseMoveThreshold := 40
  59.  
  60. ; There are multiple hotkeys to run this script now, defaults set as follows:
  61. ; ^p (CTRL-p) - Performs a price check based on item name only
  62. ; ^+p (CTRL-SHIFT-P) - Performs a price check, using quality and level filters automatically on gems
  63. ; ^o (CTRL-o) - On-line Sellers Only - performs a price check based on item name only
  64. ; ^+o (CTRL-SHIFT-O) - On-line Sellers Only - performs a price check, using quality and level filters automatically on gems
  65. ;
  66. ; To modify these, you will need to modify the function call headers below
  67. ; see http://www.autohotkey.com/docs/Hotkeys.htm for hotkey options
  68.  
  69.  
  70. ; Price check w/ auto filters
  71. ^+p::
  72. ; Send a ^C to copy the item information to the clipboard
  73. Send ^c
  74. ; Wait 250ms - without this the item information doesn't get to the clipboard in time
  75. Sleep 250
  76. FunctionProcessItemInfo("yes","no")
  77. return
  78.  
  79. ; Price check w/o auto filters
  80. ^p::
  81. ; Send a ^C to copy the item information to the clipboard
  82. Send ^c
  83. ; Wait 250ms - without this the item information doesn't get to the clipboard in time
  84. Sleep 250
  85. FunctionProcessItemInfo("no","no")
  86. return
  87.  
  88. ; Online Only Price check w/ auto filters
  89. ^+o::
  90. ; Send a ^C to copy the item information to the clipboard
  91. Send ^c
  92. ; Wait 250ms - without this the item information doesn't get to the clipboard in time
  93. Sleep 250
  94. FunctionProcessItemInfo("yes","yes")
  95. return
  96.  
  97. ; Online Only Price check w/o auto filters
  98. ^o::
  99. ; Send a ^C to copy the item information to the clipboard
  100. Send ^c
  101. ; Wait 250ms - without this the item information doesn't get to the clipboard in time
  102. Sleep 250
  103. FunctionProcessItemInfo("no","yes")
  104. return
  105. ; == Function Stuff =======================================
  106.  
  107. FunctionFetchURL(FetchURL,oo)
  108. {
  109. ; If online only is set, then add that parameter to FetchURL
  110. ifInString, oo, yes
  111. {
  112. FetchURL = %FetchURL%&oo=1
  113. }
  114.  
  115. ; This is for debug purposes, it should be commented out in normal use
  116. ;MsgBox, %FetchURL%
  117.  
  118. ; Create a web request for the content. I assume since it's WinHttp it only works in Windows. Sorry.
  119. whr := ComObjCreate("WinHttp.WinHttpRequest.5.1")
  120. whr.Open("GET", FetchUrl)
  121. whr.Send()
  122. responsecontent := whr.ResponseText
  123. FunctionShowToolTip(responsecontent)
  124.  
  125. ; Get poe.xyz.is URL and put it into clipboard, this is really cheesy and assumes the
  126. ; content will return > before the URL
  127. StringSplit, poexyzurl, responsecontent,>
  128. clipboard = %poexyzurl2%
  129.  
  130. }
  131.  
  132. ; This is for the tooltip, so it shows it and starts a timer that watches mouse movement.
  133. ; I imagine there's a better way of doing this.
  134. FunctionShowToolTip(responsecontent)
  135. {
  136. ; Get position of mouse cursor
  137. Global X
  138. Global Y
  139. MouseGetPos, X, Y
  140. ToolTip, %responsecontent%, X - 135, Y + 30
  141. SetTimer, SubWatchCursor, 100
  142. }
  143.  
  144. ; == The Goods =====================================
  145.  
  146. ; Watches the mouse cursor to get rid of the tooltip after too much movement
  147. SubWatchCursor:
  148. MouseGetPos, CurrX, CurrY
  149. MouseMoved := (CurrX - X)**2 + (CurrY - Y)**2 > MouseMoveThreshold**2
  150. If (MouseMoved)
  151. {
  152. SetTimer, SubWatchCursor, Off
  153. ToolTip
  154. }
  155. return
  156.  
  157.  
  158. FunctionProcessItemInfo(filter,oo) {
  159. ; Only does anything if POE is the window with focus
  160. IfWinActive, Path of Exile ahk_class Direct3DWindowClass
  161. {
  162. ClipBoardData = %clipboard%
  163. StringSplit, data, ClipBoardData, `n, `r
  164.  
  165. ; Okay, basically what's happening here is a sort of lame double checking of the clipboard contents.
  166. ; We split the clipboard into an array based on newlines, then check the first line of each array
  167. ; to get an idea what is inside it.
  168.  
  169. ; If the first line contains "Rarity: Unique" then we can do a lookup, using the name generated from
  170. ; the second and third line of the content.
  171. IfInString, data1, Rarity: Unique
  172. {
  173. ItemName = %data2%
  174. ItemType = %data3%
  175. FetchURL = %URL%%ItemName% %ItemType%
  176. FunctionFetchURL(FetchURL,oo)
  177.  
  178. ; If the first line contains "Rarity: Gem" then we do a lookup using the name from the second line only
  179. } else IfInString, data1, Rarity: Gem
  180. {
  181. ItemName = %data2%
  182.  
  183. ; Include Level and/or Quality information if filters are enabled
  184. IfInString, filter, yes
  185. {
  186.  
  187. ; Make another copy of clipboard data to manipulate, then remove spaces from it
  188. StringReplace,MyClipBoardData,ClipBoardData,%A_Space%,,All
  189.  
  190.  
  191. ; Loop through clipboard data to find the quality of the gem, this is required
  192. ; because it can be on different lines
  193. Loop,Parse,MyClipBoardData, `n, `r
  194. {
  195. ; Split each line into data based on :
  196. StringSplit, ThisField, A_LoopField,:
  197. IfInString, ThisField1, Quality
  198. {
  199. ;Just get the number from the quality field
  200. StringSplit, Quality, ThisField2,`%
  201. } else IfInString, ThisField1, Level
  202. {
  203. ; Set ItemLevel variable
  204. ItemLevel = %ThisField2%
  205. } else IfInString, ThisField1,Requirements
  206. {
  207. ; stop processing if we're down to Requirements
  208. break
  209. }
  210. }
  211. FetchURL = %URL%%ItemName%&type=Gem&lvl=%ItemLevel%&qual=%Quality1%
  212. } else {
  213. FetchURL = %URL%%ItemName%&type=Gem
  214. }
  215. FunctionFetchURL(FetchURL,oo)
  216. } else IfInString, data2, Map
  217. {
  218. ; Make another copy of clipboard data to manipulate, then remove spaces from it
  219. StringReplace,MyClipBoardData,ClipBoardData,%A_Space%,,All
  220.  
  221. ; Loop through clipboard data to find the level of the map, this is required
  222. ; because it can be on different lines
  223. Loop,Parse,MyClipBoardData, `n, `r
  224. {
  225. ; Split each line into data based on :
  226. StringSplit, ThisField, A_LoopField,:
  227. ; If we find the MapLevel let's track it!
  228. IfInString, ThisField1, MapLevel
  229. {
  230. ; oh shit son it's a map! with a level! let's show prices for those level maps
  231. FetchURL = %URL%%data2%&type=Map&lvl=%ThisField2%
  232. FunctionFetchURL(FetchURL,oo)
  233. ; stop processing
  234. break
  235. }
  236. }
  237. }
  238. ; If the first line contains "Rarity: Currency" then we might try to do a currency lookup, but this
  239. ; is really inconsistent and doesn't seem to work often. So I'm disabling this for now. Sorry.
  240. ;} else IfInString, data1, Rarity: Currency
  241. ;{
  242. ; ItemName = %data2%
  243. ; FetchURL = %URL%%ItemName%
  244. ; FunctionFetchURL(FetchURL,oo)
  245. ;}
  246. }
  247. }
Advertisement
Add Comment
Please, Sign In to add comment