简体   繁体   English

自动热键脚本可在 Math stackexchange 上打开所有问题形式的链接

[英]Auto hotkey script to open all the links of the questions form up to down on Math stackexchange

I'm trying to write an Auto hotkey script in order to open all the questions of a specific page of the Mathematics Stack Exchange site.我正在尝试编写一个自动热键脚本,以打开数学堆栈交换网站特定页面的所有问题。 It seems easy at first but I have some problems with doing that:一开始似乎很容易,但我这样做有一些问题:

First I wanted to go on the upmost of the page by clicking on the up arrow:首先,我想通过单击向上箭头在页面最上方的 go :

^q::
click,1444,85,80
return

After this I planned to move the mouse by same distance then after clicking by middle button of the mouse it opens all the links on new tab, but the problem is that the distance between links of each question is not the same Hence I can't write the script that moves the mouse with the same distance (or scrolling with the same amount) vertically and click the middle button.在此之后,我计划将鼠标移动相同的距离,然后单击鼠标中键后,它会打开新选项卡上的所有链接,但问题是每个问题的链接之间的距离不一样因此我不能编写使鼠标垂直移动相同距离(或滚动相同量)的脚本,然后单击中间按钮。

Also I tried to move between the links of questions by Tab button and open the links in new tabs by pressing Ctrl + Enter .我还尝试通过Tab按钮在问题链接之间移动,并通过按Ctrl + Enter打开新选项卡中的链接。 but it also fails because by pressing the Tab it moves between all the links (containing Tags of each question) and because any question can have different number of Tags my scripts will fail with this method too.但它也失败了,因为通过按Tab ,它会在所有链接(包含每个问题的标签)之间移动,并且因为任何问题都可以有不同数量的标签,所以我的脚本也会使用这种方法失败。

So can you please help me to do that.所以你能帮我做到这一点吗? Thanks in advance!提前致谢!


I forgot to mention that I chose lots of ignored tags on the site.我忘了提到我在网站上选择了很多被忽略的标签。 (I hide the questions with those tags but if we want to get all the links of the questions on a page it may get the links of those questions too). (我用这些标签隐藏了问题,但如果我们想在页面上获取所有问题的链接,它也可能会获取这些问题的链接)。

It is a huge list of those tags, Just in case if you need the list, ask me to add them in my post.这是这些标签的巨大列表,以防万一您需要该列表,请让我将它们添加到我的帖子中。

I asked my question on AutoHotkey site Here .我在 AutoHotkey 网站Here上问了我的问题。 And user @teadrinker wrote a perfect script that solved my problem:用户@teadrinker 写了一个完美的脚本来解决我的问题:

^q::
ignored =
(
;Here is big list of my ignored tag
)
objIgnored := {}
Loop, parse, ignored, `n, `r
   objIgnored[A_LoopField] := ""

url := "https://math.stackexchange.com/questions"

Whr := ComObjCreate("WinHttp.WinHttpRequest.5.1")
Whr.Open("GET", url, false)
Whr.Send()
status := Whr.status
if (status != 200)
   throw "HttpRequest error, status: " . status

Arr := Whr.responseBody
pData := NumGet(ComObjValue(arr) + 8 + A_PtrSize)
length := arr.MaxIndex() + 1
html := StrGet(pData, length, "UTF-8")

Doc := ComObjCreate("htmlfile")
Doc.write("<meta http-equiv=""X-UA-Compatible"" content=""IE=9"">")
Doc.write(html)

summary := Doc.querySelectorAll("div.summary")
links := ""
Loop % summary.length {
   tags := summary[A_Index - 1].querySelectorAll("div.tags > a.post-tag")
   Loop % tags.length
      if objIgnored.HasKey( tags[A_Index - 1].innerText )
         continue 2
   Run, % link := StrReplace(summary[A_Index - 1].querySelector("a.question-hyperlink").href, "about:", "https://math.stackexchange.com",, 1)
   links .= link . "`n"
}
MsgBox, 4096,, % links ; this line to check which links were found and opened
Return

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM