;=============================================================================== ; ; Function Name: _DownloadAndInstall ; Description:: Downloads your program and opens it (For when you have exceeded your upload limit but still want to know how many downloads you have). ; Parameter(s): $ProgramLocation - The location of the install file (on the internet, i.e. <a href='http://www.yadayadayada.com/program.exe' class='bbc_url' title='External link' rel='nofollow external'>http://www.yadayadayada.com/program.exe</a>) ; $ProgramName - The name of your program ; Requirement(s): an Internet connection and a place to put a file online. ; ; Author(s): SleepyXtreme ; ;=============================================================================== ; _DownloadAndInstall("AAST", "<a href='http://www.andrewshangout.com/aast/AASTInstall.exe' class='bbc_url' title='External link' rel='nofollow external'>http://www.andrewshangout.com/aast/AASTInstall.exe"</a>) Func _DownloadAndInstall($ProgramName, $ProgramLocation) $question = MsgBox(4, $ProgramName, "Would you like to download " &$ProgramName) if $question = 7 then Exit $ping = Ping("www.google.com") $retry = 0 While 1 If $ping = 0 Then $retry = MsgBox(5, $ProgramName, "Error! Please connect to the Internet and try again! ") EndIf If $retry = 4 Then Local $ping = Ping("www.google.com") EndIf If $retry = 2 Then Exit EndIf If $ping <> 0 Then ExitLoop WEnd If $ping <> 0 Then FileDelete(@TempDir & "/"& $ProgramName & ".exe") $size = InetGetSize($ProgramLocation) If $size = 0 Then MsgBox(0, $ProgramName, "The update server is temporarily unavailable. Please try again later.") Exit EndIf InetGet($ProgramLocation, @TempDir & "/"& $ProgramName & ".exe", 1, 1) While @InetGetActive TrayTip($ProgramName, "Downloading " &$ProgramName & ": Program: Bytes = " & @InetGetBytesRead, 10, 16) Sleep(50) WEnd TrayTip("", "", 0) TrayTip($ProgramName, "Downloading Complete", 10, 16) $question2 = MsgBox(4, $ProgramName, "Would you like to install " &$ProgramName) if $question2 = 7 then Exit sleep(2000) Run(@TempDir & "/"& $ProgramName & ".exe") Exit EndIf EndFunc ;==>_DownloadandInstall
I assumed this could be very useful for those who create many programs but still want to know how many people have downloaded their program.
Maybe a sticky ?
Also, I'm not sure if this is a UDF since you would want to create an .exe with just this stuff
credits: Sleepyxtreme and RazerM(I used the pinging method in the beginning from one of his posts)
Edited by SleepyXtreme, 05 June 2007 - 04:52 PM.