redirect in chrome? Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
joshatt
Posts: 151
Joined: 07 Dec 2014, 08:41

redirect in chrome?

22 May 2018, 18:23

Hi all,

I'm working on a code to download file, within Chrome, it will get me the save-file popup.
The final line is :

Code: Select all

run D:\other\cent23750\chrome.exe %f1s%
f1s is the file's link.
Sometimes this link will just redirect to a different domain, and will visit as a page, instead of save-file popup. (And the new page url is VALID, no 404 etc.)

How to code: if redirect happens, then...... ?

Thanks.
tmplinshi
Posts: 1604
Joined: 01 Oct 2013, 14:57

Re: redirect in chrome?  Topic is solved

24 May 2018, 02:21

Code: Select all

url := "https://autohotkey.com/download/ahk.zip"

furl := GetFinalUrl(url)
if (furl != url)
{
	MsgBox, % furl
}
else
{
	run D:\other\cent23750\chrome.exe %url%
}

GetFinalUrl(url) {
	whr := ComObjCreate("WinHttp.WinHttpRequest.5.1")
	whr.Open("HEAD", url)
	whr.Send()
	return whr.Option(1)
}

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot] and 126 guests