Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; POE Simple Price Check
- ; Version: 2 (2014/08/13)
- ;
- ; Written by Pete Waterman aka trackpete on reddit, pwx* in game
- ; email: [email protected] | personal website: whoispete.com
- ;
- ; The latest version of this can always be found here:
- ;
- ; http://poe.pwx.me
- ;
- ; Author's Note: I'm not an AHK programmer, I learned everything on the fly. There is a
- ; good chance this code will look sloppy to experienced AHK programmers, if you have any
- ; advice or would like to re-write it, please feel free and let me know.
- ;
- ; USAGE NOTE: This requires your Path of Exile to be in Windowed (or Windowed Full Screen)
- ; to work properly, otherwise the popup will just show in the background and you won't
- ; see it.
- ;
- ; CONFIGURATION NOTE: You must configure the LeagueName properly.
- ;
- ; Huge thanks to poe.xyz.is for allowing this to use their service
- ; == Startup Options ===========================================
- #SingleInstance force
- #NoEnv
- #Persistent ; Stay open in background
- SendMode Input
- StringCaseSense, On ; Match strings with case.
- Menu, tray, Tip, POE Simple Price Check
- ; == Variables and Options and Stuff ===========================
- ; Option for League from poe.xyz.is, set appropriately! The available
- ; Leagues at time of release are included, uncomment the one you want
- ; and comment out the others
- ;
- ; YOU MUST SET THIS TO THE PROPER LEAGUE YOU WANT TO PLAY OR IT WILL
- ; USE A DEFAULT! (sorry for shouting)
- LeagueName = Rampage
- ;LeagueName = Hardcore
- ; This variable indicates how many results to show for each amount in a currency type.
- ; For example, if there are 15 different amounts listed for chaos (1c, 3c, 5c, 10c, 15c, etc.),
- ; the default will only show the cheapest 3 amounts (1c, 3c, 5c). You can increase this to
- ; whatever you'd like, but it may get unwieldy
- Show = 3
- ; Decoder URL - No need to change this! This is a development option.
- ; Instead of doing all the processing in AHK, this script simply sends basic
- ; item information to a decoder service I run. The decoder service then checks
- ; that item information on poe.xyz.is (with permission). It also caches duplicate
- ; lookups to reduce load on poe.xyz.is system, any duplicate lookup in a ~30min
- ; period will hit the cache instead.
- Global URL = "http://poe.pwx.me/cgi-bin/poe-decode-text?v=2&show= " . Show . "league=" . LeagueName . "&s="
- ; How much the mouse needs to move before the hotkey goes away, not a big deal, change to whatever
- MouseMoveThreshold := 40
- ; There are multiple hotkeys to run this script now, defaults set as follows:
- ; ^p (CTRL-p) - Performs a price check based on item name only
- ; ^+p (CTRL-SHIFT-P) - Performs a price check, using quality and level filters automatically on gems
- ; ^o (CTRL-o) - On-line Sellers Only - performs a price check based on item name only
- ; ^+o (CTRL-SHIFT-O) - On-line Sellers Only - performs a price check, using quality and level filters automatically on gems
- ;
- ; To modify these, you will need to modify the function call headers below
- ; see http://www.autohotkey.com/docs/Hotkeys.htm for hotkey options
- ; Price check w/ auto filters
- ^+p::
- ; Send a ^C to copy the item information to the clipboard
- Send ^c
- ; Wait 250ms - without this the item information doesn't get to the clipboard in time
- Sleep 250
- FunctionProcessItemInfo("yes","no")
- return
- ; Price check w/o auto filters
- ^p::
- ; Send a ^C to copy the item information to the clipboard
- Send ^c
- ; Wait 250ms - without this the item information doesn't get to the clipboard in time
- Sleep 250
- FunctionProcessItemInfo("no","no")
- return
- ; Online Only Price check w/ auto filters
- ^+o::
- ; Send a ^C to copy the item information to the clipboard
- Send ^c
- ; Wait 250ms - without this the item information doesn't get to the clipboard in time
- Sleep 250
- FunctionProcessItemInfo("yes","yes")
- return
- ; Online Only Price check w/o auto filters
- ^o::
- ; Send a ^C to copy the item information to the clipboard
- Send ^c
- ; Wait 250ms - without this the item information doesn't get to the clipboard in time
- Sleep 250
- FunctionProcessItemInfo("no","yes")
- return
- ; == Function Stuff =======================================
- FunctionFetchURL(FetchURL,oo)
- {
- ; If online only is set, then add that parameter to FetchURL
- ifInString, oo, yes
- {
- FetchURL = %FetchURL%&oo=1
- }
- ; This is for debug purposes, it should be commented out in normal use
- ;MsgBox, %FetchURL%
- ; Create a web request for the content. I assume since it's WinHttp it only works in Windows. Sorry.
- whr := ComObjCreate("WinHttp.WinHttpRequest.5.1")
- whr.Open("GET", FetchUrl)
- whr.Send()
- responsecontent := whr.ResponseText
- FunctionShowToolTip(responsecontent)
- ; Get poe.xyz.is URL and put it into clipboard, this is really cheesy and assumes the
- ; content will return > before the URL
- StringSplit, poexyzurl, responsecontent,>
- clipboard = %poexyzurl2%
- }
- ; This is for the tooltip, so it shows it and starts a timer that watches mouse movement.
- ; I imagine there's a better way of doing this.
- FunctionShowToolTip(responsecontent)
- {
- ; Get position of mouse cursor
- Global X
- Global Y
- MouseGetPos, X, Y
- ToolTip, %responsecontent%, X - 135, Y + 30
- SetTimer, SubWatchCursor, 100
- }
- ; == The Goods =====================================
- ; Watches the mouse cursor to get rid of the tooltip after too much movement
- SubWatchCursor:
- MouseGetPos, CurrX, CurrY
- MouseMoved := (CurrX - X)**2 + (CurrY - Y)**2 > MouseMoveThreshold**2
- If (MouseMoved)
- {
- SetTimer, SubWatchCursor, Off
- ToolTip
- }
- return
- FunctionProcessItemInfo(filter,oo) {
- ; Only does anything if POE is the window with focus
- IfWinActive, Path of Exile ahk_class Direct3DWindowClass
- {
- ClipBoardData = %clipboard%
- StringSplit, data, ClipBoardData, `n, `r
- ; Okay, basically what's happening here is a sort of lame double checking of the clipboard contents.
- ; We split the clipboard into an array based on newlines, then check the first line of each array
- ; to get an idea what is inside it.
- ; If the first line contains "Rarity: Unique" then we can do a lookup, using the name generated from
- ; the second and third line of the content.
- IfInString, data1, Rarity: Unique
- {
- ItemName = %data2%
- ItemType = %data3%
- FetchURL = %URL%%ItemName% %ItemType%
- FunctionFetchURL(FetchURL,oo)
- ; If the first line contains "Rarity: Gem" then we do a lookup using the name from the second line only
- } else IfInString, data1, Rarity: Gem
- {
- ItemName = %data2%
- ; Include Level and/or Quality information if filters are enabled
- IfInString, filter, yes
- {
- ; Make another copy of clipboard data to manipulate, then remove spaces from it
- StringReplace,MyClipBoardData,ClipBoardData,%A_Space%,,All
- ; Loop through clipboard data to find the quality of the gem, this is required
- ; because it can be on different lines
- Loop,Parse,MyClipBoardData, `n, `r
- {
- ; Split each line into data based on :
- StringSplit, ThisField, A_LoopField,:
- IfInString, ThisField1, Quality
- {
- ;Just get the number from the quality field
- StringSplit, Quality, ThisField2,`%
- } else IfInString, ThisField1, Level
- {
- ; Set ItemLevel variable
- ItemLevel = %ThisField2%
- } else IfInString, ThisField1,Requirements
- {
- ; stop processing if we're down to Requirements
- break
- }
- }
- FetchURL = %URL%%ItemName%&type=Gem&lvl=%ItemLevel%&qual=%Quality1%
- } else {
- FetchURL = %URL%%ItemName%&type=Gem
- }
- FunctionFetchURL(FetchURL,oo)
- } else IfInString, data2, Map
- {
- ; Make another copy of clipboard data to manipulate, then remove spaces from it
- StringReplace,MyClipBoardData,ClipBoardData,%A_Space%,,All
- ; Loop through clipboard data to find the level of the map, this is required
- ; because it can be on different lines
- Loop,Parse,MyClipBoardData, `n, `r
- {
- ; Split each line into data based on :
- StringSplit, ThisField, A_LoopField,:
- ; If we find the MapLevel let's track it!
- IfInString, ThisField1, MapLevel
- {
- ; oh shit son it's a map! with a level! let's show prices for those level maps
- FetchURL = %URL%%data2%&type=Map&lvl=%ThisField2%
- FunctionFetchURL(FetchURL,oo)
- ; stop processing
- break
- }
- }
- }
- ; If the first line contains "Rarity: Currency" then we might try to do a currency lookup, but this
- ; is really inconsistent and doesn't seem to work often. So I'm disabling this for now. Sorry.
- ;} else IfInString, data1, Rarity: Currency
- ;{
- ; ItemName = %data2%
- ; FetchURL = %URL%%ItemName%
- ; FunctionFetchURL(FetchURL,oo)
- ;}
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment