Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #NoEnv
- SetBatchLines, -1
- #SingleInstance force
- StringCaseSense, Locale
- #IfWinActive, (*_*)
- Array_id := {"career-splits" :"career-splits-chall", "last52-splits":"last52-splits-chall"}
- Gui, +ToolWindow +AlwaysOnTop
- Gui,Font, s15 normal
- Gui, Add, Edit, r1 x20 w150 vSearch gValidCheck Number, № позиции
- Gui, Add, Button, x20 y+10 w150 h20 Disabled vnext gOK, % Chr(0x2192)
- Gui,Font, s12 normal
- Gui, Add, Text, x20 y+10 w200 vName gname,
- Gui, Font, s10 normal
- Gui, Add, ListView, x10 y+15 r9 w304 NoSort vLV +ReadOnly , Split|M|W|L|Win
- loop % LV_GetCount("col")
- LV_ModifyCol(A_index,"60 Center")
- Gui, Add, Picture, x180 y5 w130 h100 vImages gImages +0x1000,
- LV_Modify(2, "NewCol1")
- Gui, Show, w320, (*_*)
- hCurs:=DllCall("LoadCursor","UInt",NULL,"Int",32649,"UInt") ;IDC_HAND
- OnMessage(0x200,"WM_MOUSEMOVE")
- GuiControl, Focus, Search
- return
- GuiClose:
- ExitApp
- ValidCheck:
- GuiControlGet, Search
- If (isNumberInRange(Search,0))
- GuiControl, Enable, next
- else
- GuiControl, Disable, next
- return
- Images:
- ;~ if (capture)
- ;~ {
- ;~ Gui, -AlwaysOnTop
- ;~ run, % capture
- ;~ sleep 300
- ;~ WinGet, Pid, PID, A
- ;~ while, WinExist("ahk_pid " . Pid)
- ;~ {
- ;~ Sleep 1000
- ;~ Process, close, % PID
- ;~ Gui, +AlwaysOnTop
- ;~ }
- ;~ }
- return
- name:
- run, % link_gui
- return
- $Enter::
- $NumpadEnter::
- Ok:
- Gui, Submit, NoHide
- gosub label_none
- ToolTip, Loading!!
- url := "https://tennisabstract.com/reports/wtaRankings.html"
- loop 3
- {
- html := WebRequest(url,,,, error)
- if error
- throw error
- document := DocumentFromHtml(html)
- if(A_index = 1)
- {
- links := document.getElementsByTagName("tbody")[3].getElementsByTagName("tr")
- loop, % links.length
- {
- if(search = links[A_index - 1].getElementsByTagName("td")[0].innerText)
- {
- url := link_gui:= links[A_index - 1].getElementsByTagName("td")[1].getElementsByTagName("a")[0].getAttribute("href")
- fullname := links[A_index - 1].getElementsByTagName("td")[1].getElementsByTagName("a")[0].innerText
- break
- }
- }
- }
- if(A_index = 2)
- {
- links := document.getElementsByTagName("head")[0].getElementsByTagName("script")
- loop, % links.length
- {
- if Instr(links[A_index - 1].getAttribute("src"), RegExReplace(fullname, "\s"))
- url:= links[A_index - 1].getAttribute("src")
- }
- }
- if(A_index = 3)
- {
- for key, var in Array_id
- {
- chek_tag := Instr(html, var) ? var : key
- a := 0
- loop 3
- {
- b := 1
- qq .= document.getElementById(chek_tag).getElementsByTagName("tbody")[0].getElementsByTagName("tr")[a].getElementsByTagName("td")[0].innerText "|"
- loop 4
- {
- qq2 .= document.getElementById(chek_tag).getElementsByTagName("tbody")[0].getElementsByTagName("tr")[a].getElementsByTagName("td")[b].innerText "|"
- b++
- }
- a++
- }
- }
- }
- }
- GuiControl, Text, Name, % fullname
- Loop, parse, qq, |
- {
- if(A_index = 1 || A_index = 4)
- LV_Add(, "")
- LV_Add(, A_loopfield)
- }
- i := 1
- col := 2
- Loop, parse, qq2, |
- {
- if(A_index = "5" || A_index = "9" || A_index = "13" || A_index = "17" || A_index = "21") ;(A_index = 4 * i + 1)
- {
- i++
- col := 2
- }
- if(A_index = "13")
- i := i+1
- LV_Modify(i+1, "Col" . col, A_LoopField)
- col++
- }
- UrlDownloadToFile, % Format("{:L}", "https://www.tennisabstract.com/photos/" RegExReplace(fullname, " ", "_") "-sirobi.jpg"), % capture := A_Temp "\capture_tennis.jpg"
- FileGetSize, OutputVar_size, % capture , K
- if (OutputVar_size < 3)
- {
- if !FileExist(A_Temp "\capture_tennis_none.jpg")
- UrlDownloadToFile, https://t3.ftcdn.net/jpg/02/15/15/46/240_F_215154625_hJg9QkfWH9Cu6LCTUc8TiuV6jQSI0C5X.jpg, % capture := A_Temp "\capture_tennis_none.jpg"
- else
- capture := A_Temp "\capture_tennis_none.jpg"
- }
- GuiControl,, Images, *w130 *h100 %capture%
- GuiControl, Text, Search,
- ToolTip
- return
- WebRequest(url, method := "GET", HeadersArray := "", body := "", ByRef error := "") {
- Whr := ComObjCreate("WinHttp.WinHttpRequest.5.1")
- Whr.Open(method, url, true)
- for name, value in HeadersArray
- Whr.SetRequestHeader(name, value)
- Whr.Send(body)
- Whr.WaitForResponse()
- status := Whr.status
- if (status != 200)
- error := "HttpRequest error, status: " . status
- Arr := Whr.responseBody
- pData := NumGet(ComObjValue(Arr) + 8 + A_PtrSize)
- length := Arr.MaxIndex() + 1
- Return StrGet(pData, length, "UTF-8")
- }
- DocumentFromHtml(html, mode := 9) {
- document := ComObjCreate("HTMLFILE")
- document.write("<meta http-equiv=""X-UA-Compatible"" content=""IE=" . mode . """>")
- document.write(html)
- Return document
- }
- WM_MOUSEMOVE(wParam,lParam)
- {
- If (A_GuiControl = "Search")
- {
- GuiControlGet, OutputVar,, Search
- if ( OutputVar = "№ позиции")
- GuiControl, Text, Search,
- }
- Global hCurs
- MouseGetPos,,,,ctrl
- IfInString ctrl, Static1
- DllCall("SetCursor","UInt",hCurs)
- Return
- }
- IsNumberInRange(var,low)
- {
- If (StrLen(var) > low)
- Return 1
- }
- label_none:
- chek_tag :=
- qq :=
- qq2 :=
- LV_Delete()
- GuiControl, Text, Name,
- GuiControl,, Images,
- fullname := ""
- return
- ^esc::ExitApp
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement