AHK forum scripts

Post your working scripts, libraries and tools
User avatar
jeeswg
Posts: 6638
Joined: 19 Dec 2016, 01:58
Location: UK

AHK forum scripts

12 Feb 2017, 07:34

Apply 'find next' when editing a post.

Code: Select all

;[WBGet function]
;Basic Webpage Controls with JavaScript / COM - Tutorial - Tutorials - AutoHotkey Community
;https://autohotkey.com/board/topic/47052-basic-webpage-controls-with-javascript-com-tutorial/

#IfWinActive, AutoHotkey Community - Post a reply ahk_class IEFrame
;autohotkey forum - apply 'F3' to message, find text
^f::
^#f::
^j::
^#j::
F3::
F4::
^F4::
WinGet, hWnd, ID, A
oWB := WBGet("ahk_id " hWnd)
;vUrl := oWB.document.url
;vTitle := oWB.document.title
oElt := oWB.document.getElementById("message")
vPos1 := oElt.selectionStart
vPos2 := oElt.selectionEnd
vText := oElt.innerText
vText := StrReplace(vText, "`r`n", "`n")
if InStr(A_ThisHotkey, "^") || (vNeedleAHkForum = "")
;JEE_InputBoxVPD(vNeedleAhkForum, "Find what:", vNeedleAhkForum)
InputBox, vNeedleAhkForum,, % "Find what:",,,,,,,, % vNeedleAhkForum
if (vPos := InStr(vText, vNeedleAhkForum, 0, vPos1+2))
{
	oElt.selectionStart := vPos-1
	oElt.selectionEnd := vPos-1+StrLen(vNeedleAhkForum)
	oWB.document.selection.createRange().scrollIntoView()
}
else
	MsgBox % "Cannot find """ vNeedleAhkForum """"
oWB := oElt := ""
return
#IfWinActive
Btw have many scripts been made regarding this forum?
Last edited by jeeswg on 19 Sep 2017, 09:31, edited 1 time in total.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
User avatar
jeeswg
Posts: 6638
Joined: 19 Dec 2016, 01:58
Location: UK

Re: AHK forum scripts

19 Sep 2017, 09:04

Convert urls to a standard format.

Code: Select all

;e.g.:
;https://autohotkey.com/boards/viewtopic.php?t=28149
;to:
;https://autohotkey.com/boards/viewtopic.php?f=7&t=28149

;https://autohotkey.com/boards/viewtopic.php?p=132016#p132016
;to:
;https://autohotkey.com/boards/viewtopic.php?f=7&t=28149&p=132016#p132016

JEE_AhkForumTidyUrl(vUrl)
{
	if RegExMatch(vUrl, "^\Qhttps://autohotkey.com/boards/viewtopic.php?\Ef=\d{1,2}&t=\d{1,5}$")
	|| RegExMatch(vUrl, "^\Qhttps://autohotkey.com/boards/viewtopic.php?\Ef=\d{1,2}&t=\d{1,5}&p=\d{1,6}#p\d{1,6}$")
		return vUrl
	vPost := RegExReplace(vUrl, ".*(p=\d{1,6}#p\d{1,6}).*|.*", "$1")
	SplitPath, vUrl,, vDir
	oHTML := ComObjCreate("HTMLFile")
	vHtml = <meta http-equiv="X-UA-Compatible" content="IE=edge">
	oHTML.write(vHtml)
	;===============
	;JEE_UrlDownloadToVar(vUrl, vData, vSize)
	oHTTP := ComObjCreate("WinHttp.WinHttpRequest.5.1")
	oHTTP.Open("GET", vUrl)
	oHTTP.Send()
	oHTTP.WaitForResponse()
	vSize := oHTTP.ResponseBody.MaxIndex()
	VarSetCapacity(vData, vSize, 0)
	VarSetCapacity(vIndex, 4, 0)
	if !DllCall("oleaut32\SafeArrayPtrOfIndex", Ptr,ComObjValue(oHTTP.ResponseBody), Ptr,&vIndex, PtrP,vPtrOfIndex)
		DllCall("kernel32\RtlMoveMemory", Ptr,&vData, Ptr,vPtrOfIndex, UPtr,vSize)
	oHTTP := ""
	;===============
	vHtml := StrGet(&vData, vSize, "CP0")
	oHTML.write(vHtml)
	vUrl2 := oHTML.getElementsByClassName("topic-title").item[0].childNodes.item[0].href
	if (SubStr(vUrl2, 1, 8) = "about:./")
		vUrl2 := vDir SubStr(vUrl2, 8)
	vUrl2 := RegExReplace(vUrl2, "&sid=.*")
	vUrl2 := RegExReplace(vUrl2, "&start=.*")
	if !(vPost = "")
		vUrl2 .= "&" vPost
	return vUrl2
}
Last edited by jeeswg on 19 Sep 2017, 09:43, edited 1 time in total.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
User avatar
Delta Pythagorean
Posts: 473
Joined: 13 Feb 2017, 13:44
GitHub: DelPyth
Location: Somewhere in the US

Re: AHK forum scripts

19 Sep 2017, 09:09

Where's the WBGet function?
User avatar
jeeswg
Posts: 6638
Joined: 19 Dec 2016, 01:58
Location: UK

Re: AHK forum scripts

19 Sep 2017, 09:30

Thread: get view count.

Code: Select all

;e.g.
;MsgBox, % JEE_AhkForumGetViewCount(74796, 34838)

JEE_AhkForumGetViewCount(vAuthorID, vThread)
{
	static vPfx := RegExMatch("","",o)*IsObject(o) ? "" : "O)" ;AHK v1/v2 two-way compatibility
	oHTTP := ComObjCreate("WinHttp.WinHttpRequest.5.1")
	oHTTP.Open("GET", "https://autohotkey.com/boards/search.php?author_id=" vAuthorID "&t=" vThread "&sf=titleonly&ch=0", True)
	oHTTP.Send()
	oHTTP.WaitForResponse()
	RegExMatch(oHTTP.ResponseText, vPfx "<dd>Views: <strong>(.*?)<\/strong><\/dd>", o)
	;return o.Value(1)
	return o.1
}
Discussion:
get view count for current thread - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=3&t=34838

@Delta Pythagorean: I've added a link.
Last edited by jeeswg on 08 Apr 2018, 18:03, edited 1 time in total.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
User avatar
jeeswg
Posts: 6638
Joined: 19 Dec 2016, 01:58
Location: UK

Re: AHK forum scripts

25 Nov 2017, 12:29

Get the urls for threads with unread posts.

Code: Select all

;WBGet function - AutoHotkey Community
;https://autohotkey.com/boards/viewtopic.php?f=6&t=39869

;e.g. for this url, get a list of all the urls for posts that have an orange button
;AutoHotkey Community - New posts
;https://autohotkey.com/boards/search.php?search_id=newposts&sid=0200e7d6e0fe4446853baf8f6253bb41

q:: ;internet explorer - autohotkey - list unread threads
WinGet, hWnd, ID, ahk_class IEFrame
oWB := WBGet("ahk_id " hWnd)
vOutput := ""
oElts := oWB.document.getElementsByClassName("icon-link")
Loop, % oElts.length
{
	oElt := oElts[A_Index-1]
	vOutput .= oElt.href "`r`n"
}
oWB := oElts := oElt := ""
Clipboard := vOutput
MsgBox, % "done"
return
Last edited by jeeswg on 09 Dec 2018, 20:22, edited 2 times in total.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
User avatar
jeeswg
Posts: 6638
Joined: 19 Dec 2016, 01:58
Location: UK

Re: AHK forum scripts

25 Nov 2017, 12:36

Further links to other threads.

Internet Explorer: resize elements to fit window (e.g. AutoHotkey archived forum) - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=36560

webpages: get table text - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=39131
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA

Return to “Scripts and Functions”

Who is online

Users browsing this forum: Frosti, swagfag and 44 guests