Here are two scripts for your request.
Read the Help file for each command and try to understand what the commands are doing. I couldn't write a script without looking in the help file.
Something you can try: If the download is OK, check the size of the downloaded file. If smaller than let's say 50 kb, read the file in a variable and check for a "not found" string. (If the file is not found, AHK will save the 404 error page.)
msgbox, 36, This box has a title, This is a message
IfMsgBox, Yes
run,http://www.autohotkey.com/download/AutoHotkeyInstall.exe
or
msgbox, 36, This box has a title, This is a message
IfMsgBox, Yes
{
ToolTip, Downloading...
UrlDownloadToFile, http://www.autohotkey.com/download/AutoHotkeyInstall.exe, %A_scriptdir%\AutoHotkeyInstall.exe
Tooltip
if errorlevel = 1
msgbox, 16, This is another title, Download failed
else
msgbox, 64, This is another title, Download OK`n`(but can't be 100`% sure`, check AHK help file`)
}