redirect in chrome?

Get help with using AutoHotkey and its commands and hotkeys
joshatt
Posts: 58
Joined: 07 Dec 2014, 08:41
Facebook: joshatt
Google: joshatt

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: 1269
Joined: 01 Oct 2013, 14:57

Re: redirect in chrome?

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”

Who is online

Users browsing this forum: Bing [Bot], MadAsKiwi, Sweetins, Wanion and 30 guests