get redirected url (handle file links and focus loss)

Get help with using AutoHotkey and its commands and hotkeys
User avatar
jeeswg
Posts: 6904
Joined: 19 Dec 2016, 01:58
Location: UK

get redirected url (handle file links and focus loss)

19 Apr 2017, 19:19

I've written a function which aims to get the redirected (current) version of a url.

There are two problems with it:
- The View Downloads window appears if the url is a file link. I could check if the url ends in a common file extension, however, this does not always work. E.g.: https://github.com/maul-esel/FormsFrame ... all/master
- The active window loses focus every so often.

In case anyone has any ideas to solve these problems, or perhaps offer a quite different approach. Cheers.

Code: Select all

JEE_UrlGetRedirected(vUrl, ByRef vTitle="")
{
	if !InStr(vUrl, "://")
		return "[ERROR]" vUrl
	vUrl2 := "[ERROR]" vUrl, vTitle := "[ERROR]"
	oWB := ComObjCreate("InternetExplorer.Application")
	oWB.Navigate(vUrl)
	Loop, % 6000 ;6000*10 = 1 minute
		if oWB.busy || !(oWB.ReadyState = 4)
			Sleep, 10
		else
		{
			vUrl2 := oWB.document.url
			vTitle := oWB.document.title
			break
		}
	oWB.quit
	oWB := ""
	if (vUrl2 = "")
		return "[ERROR]" vUrl
	return vUrl2
}
[My 700th post. Lucky Number Slevin-hundred.]
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 “Ask For Help”

Who is online

Users browsing this forum: au6, BushMange, howardb1, MannyKSoSo, w0z and 189 guests