|
我改了改,速度提高了
- #NoEnv
- #NoTrayIcon
- #SingleInstance Force
- #include JSON.ahk
- ;#include GetWidthUnitCount.ahk 字符串表 显示优化 未完成
- SetWorkingDir %A_ScriptDir%
- CoordMode, ToolTip, Screen
- CoordMode, mouse, Screen
- global Version
- global Ready := false
- global CheckBoard := ""
- global WebRequest := ComObjCreate("WinHttp.WinHttpRequest.5.1")
- ;global League := "S9赛季"
- Gui Add, Text, x16 y16 w40 h23 +0x200, 赛季
- Gui Add, ComboBox,vLeague x64 y16 w100, S9赛季
- GuiControl,Choose,League,1
- Gui Add, Button,gStart x16 y48 w149 h39, OK
- Gui Show, w175 h97, ToolTip
- Return
- ^space::
- GuiEscape:
- GuiClose:
- ExitApp
- ; End of the GUI section
- #if Ready
- #IfWinActive Path of Exile
- ~^C::
- if Clipboard != CheckBoard
- settimer,Main,100
- Tooltip, Loading
- return
- #IfWinActive
- #if
- Main:
- FindTradeInfo(Clipboard)
- settimer,Main,off
- return
- ~Space::
- RemoveToolTip:
- ToolTip
- settimer,RemoveToolTip,off
- return
- Start()
- {
- if CheckLeague()
- {
- Ready := false
- MsgBox,版本号错误
- return
- }
- Ready := true
- Clipboard := ""
- Gui,hide
- return
- }
- ;版本检测,懒得写-----
- CheckLeague()
- {
- return false
- }
- ;获取name和type
- GetNameAndType(Clip)
- {
- if InStr(Clip, "稀 有 度:") != 1
- {
- mItem := {ItemName:false,ItemType:false}
- return mItem
- }
- ClipArray := StrSplit(Clip, "`n", "`r")
- try:
- if RegExMatch(ClipArray[3],"---")
- mItem := {ItemName:false,ItemType:ClipArray[2]}
- else
- mItem := {ItemName:ClipArray[2],ItemType:ClipArray[3]}
- return mItem
- catch: ;return bugmsg懒得写------
- return
- }
- print(str)
- {
- global h_stdout
- DebugConsoleInitialize() ; start console window if not yet started
- str .= "`n" ; add line feed
- DllCall("WriteFile", "uint", h_Stdout, "uint", &str, "uint", StrLen(str), "uint*", BytesWritten, "uint", NULL) ; write into the console
- WinSet, Bottom,, ahk_id %h_stout% ; keep console on bottom
- }
- DebugConsoleInitialize()
- {
- global h_Stdout ; Handle for console
- static is_open = 0 ; toogle whether opened before
- if (is_open = 1) ; yes, so don't open again
- return
-
- is_open := 1
- ; two calls to open, no error check (it's debug, so you know what you are doing)
- DllCall("AttachConsole", int, -1, int)
- DllCall("AllocConsole", int)
- dllcall("SetConsoleTitle", "str","Paddy Debug Console") ; Set the name. Example. Probably could use a_scriptname here
- h_Stdout := DllCall("GetStdHandle", "int", -11) ; get the handle
- WinSet, Bottom,, ahk_id %h_stout% ; make sure it's on the bottom
- WinActivate,Lightroom ; Application specific; I need to make sure this application is running in the foreground. YMMV
- return
- }
- ;抓取Trade信息
- FindTradeInfo(Clip)
- {
- GuiControlGet, League
- mItem := GetNameAndType(clip)
- MouseGetPos, Px,Py
-
-
- if mItem.ItemType = false
- {
- msgbox, 复制错误
- return
- }
- data := {"query":{"status":{"option":"any"} ,"stats":[{"type":"and","filters":[]}]},"filters":{"trade_filters":{"filters":{"indexed":{"option":"1day"}},"disabled":False}},"sort":{"price":"asc"}}
- if mItem.ItemName != false
- data.query.name := mItem.ItemName
- data.query.type := mItem.ItemType
-
- body := JSON.dump(data)
- url = https://poe.game.qq.com/api/trade/search/%League%
- WebRequest.Open("POST", url)
- WebRequest.SetRequestHeader("Content-Type", "application/json")
- WebRequest.Send(body)
- result := JSON.Load(WebRequest.responsetext)
- itemid := result.id
- itemlist := result.result
- url := "https://poe.game.qq.com/api/trade/fetch/"
- maxCount := 10
- step := floor(itemlist.length()/maxCount) + 1
- maxcount := maxCount -1
- loop , %maxCount%
- {
- index := A_index * step
- listtemp := itemlist[index]
- url= %url%%listtemp%,
- }
- url := Rtrim(url, ",")
- url = %url%?query=%itemid%
- WebRequest.Open("GET",url)
- WebRequest.Send()
- RTresult := JSON.Load(WebRequest.responsetext)
- infolist := RTresult.result
- tmpString := ""
- MaxWidth := 0
- tmpString = 装备名称:
- if mItem.ItemName != false
- {
- ItemName := mItem.ItemName
- tmpString= %tmpString%%ItemName%-
- }
- ItemType := mItem.ItemType
- tmpString= %tmpString%%ItemType%`n
- ItemUnit := result.total
- tmpString = %tmpString%装备总数: %ItemUnit%`n
-
-
- for info in infolist
- {
- idmsg := infolist[A_index].listing.account.lastCharacterName
- pricemsg := process_dict(infolist[A_index].listing)
- Ttip =ID: %idmsg%|| 价格: %pricemsg%
- tmpString = %tmpString%`n%Ttip%
- }
- tooltip,%tmpString%,%px%,%py%
- settimer, RemoveToolTip, 15000
- return
- }
- Process_dict(s)
- {
- if s.price != "null"
- {
- single_price := s.price.amount
- unit := s.price.currency
- price_info = %single_price% %unit%
- return price_info
- }
- return "Noprice"
- }
复制代码 |
|