guclusat

Tanınmış Üye
Süper Moderatör
PHP:
-- Callback function for HTTP.Download
function DownloadCallback (nDownloaded, nTotal, TransferRate, SecondLeft, SecondsLeftFormat, Message)
    -- Convert total and downloaded bytes into formatted strings
    sDownloaded = String.GetFormattedSize(nDownloaded, FMTSIZE_AUTOMATIC, true);
    sTotal = String.GetFormattedSize(nTotal, FMTSIZE_AUTOMATIC, true);

    -- Output time left, formatted.
    StatusDlg.SetMessage("Currently downloading file . . . Time Left: " .. SecondsLeftFormat);
    
    -- Output formatted sizes to user through statusdlg status text
    StatusDlg.SetStatusText("Downloaded: " .. sDownloaded .. " / " .. sTotal);

    -- Set meter position (fraction downloaded * max meter range)
    StatusDlg.SetMeterPos((nDownloaded / nTotal) * 65534);
end



-- Show the StatusDlg
StatusDlg.Show(0, false);

-- Set statusdlg title and message
StatusDlg.SetTitle("Downloading . . . ");

-- Set meter range (max range = 65534)
StatusDlg.SetMeterRange(0, 65534);

-- Download a file from the internet to the user's computer
-- Uses DownloadCallback() as the callback function
HTTP.Download("http://www.uydudoktoru.com/dosyalar/Ali3329B1/YazilimKey/Yazilim.zip", _DesktopFolder.."\\Yazilim.zip", MODE_BINARY, 20, 80, nil, nil, DownloadCallback);

-- Hide the StatusDlg
StatusDlg.Hide();
gerekli örnek kodlar yukarda olup kafanıza göre değiştirebilirsiniz.

PHP:
-- Callback function for HTTP.Download
function DownloadCallback (nDownloaded, nTotal, TransferRate, SecondLeft, SecondsLeftFormat, Message)
    -- Convert total and downloaded bytes into formatted strings
    sDownloaded = String.GetFormattedSize(nDownloaded, FMTSIZE_AUTOMATIC, true);
    sTotal = String.GetFormattedSize(nTotal, FMTSIZE_AUTOMATIC, true);

    -- Output time left, formatted.
    StatusDlg.SetMessage("Şu anda dosya indiriliyor. . . Time Left: " .. SecondsLeftFormat);
    
    -- Output formatted sizes to user through statusdlg status text
    StatusDlg.SetStatusText("Downloaded: " .. sDownloaded .. " / " .. sTotal);

    -- Set meter position (fraction downloaded * max meter range)
    StatusDlg.SetMeterPos((nDownloaded / nTotal) * 65534);
end



-- Show the StatusDlg
StatusDlg.Show(0, false);

-- Set statusdlg title and message
StatusDlg.SetTitle("Dosya İndiriliyor . . . ");

-- Set meter range (max range = 65534)
StatusDlg.SetMeterRange(0, 65534);

-- Download a file from the internet to the user's computer
-- Uses DownloadCallback() as the callback function
HTTP.Download("http://www.uydudoktoru.com/dosyalar/Ali3329B1/YazilimKey/Yazilim.zip", _DesktopFolder.."\\Yazilim.zip", MODE_BINARY, 20, 80, nil, nil, DownloadCallback);

-- Hide the StatusDlg
StatusDlg.Hide();
 

Eklentiler

AMS yad AİO Diyalog mesajı nasıl eklenir (Bilgi mesajı) sadece kodu veriyorum kodların sonuna diyalog mesajı eklerseniz dosya indirildikten sonra bilgi mesajı ekrana çıkacaktır ben gerekli apz dosyasını hazırlayıp ekleyeceğim.

PHP:
-- Callback function for HTTP.Download
function DownloadCallback (nDownloaded, nTotal, TransferRate, SecondLeft, SecondsLeftFormat, Message)
    -- Convert total and downloaded bytes into formatted strings
    sDownloaded = String.GetFormattedSize(nDownloaded, FMTSIZE_AUTOMATIC, true);
    sTotal = String.GetFormattedSize(nTotal, FMTSIZE_AUTOMATIC, true);

    -- Output time left, formatted.
    StatusDlg.SetMessage("Şu anda dosya indiriliyor. . . Kalan Süre: " .. SecondsLeftFormat);
    
    -- Output formatted sizes to user through statusdlg status text
    StatusDlg.SetStatusText("İndirilen: " .. sDownloaded .. " / " .. sTotal);

    -- Set meter position (fraction downloaded * max meter range)
    StatusDlg.SetMeterPos((nDownloaded / nTotal) * 65534);
end



-- Show the StatusDlg
StatusDlg.Show(0, false);

-- Set statusdlg title and message
StatusDlg.SetTitle("Dosya İndiriliyor . . . ");

-- Set meter range (max range = 65534)
StatusDlg.SetMeterRange(0, 65534);

-- Download a file from the internet to the user's computer
-- Uses DownloadCallback() as the callback function
HTTP.Download("http://www.uydudoktoru.com/dosyalar/Ali3329B1/YazilimKey/Yazilim.zip", _DesktopFolder.."\\Yazilim.zip", MODE_BINARY, 20, 80, nil, nil, DownloadCallback);

-- Hide the StatusDlg
StatusDlg.Hide();

result = Dialog.Message("Uydudoktoru Diyor Ki?", "Dosya Masa Üstüne İndirildi. Daha geniş Açıklama ve bilgiler için\r\n\r\nwww.uydudoktoru.com Adresini ziyaret ediniz.\r\n", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
Eklediğimiz kod

PHP:
result = Dialog.Message("Uydudoktoru Diyor Ki?", "Dosya Masa Üstüne İndirildi. Daha geniş Açıklama ve bilgiler için\r\n\r\nwww.uydudoktoru.com Adresini ziyaret ediniz.\r\n", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);

yukardaki kodlarda ingilizce olan yerleri türkçeye çevirdim arkadaşlar bu kodlar geliştirilmeye açık olup internet bağlantısında sorun çıkarsa uyarı verebilir.server test edilip sorun yoksa indirme başlatılabilir gibi .

APZ Dosyası Ektedir.
 

Eklentiler

REHBER: AMS ile İnternetten Masaüstüne Dosya İndirme

Bu işlem için AMS'nin yerleşik HTTP.Download fonksiyonunu kullanacağız. Bu fonksiyon, dosyayı arka planda indirirken size işlemin durumu hakkında bilgi de verebilir.

1. Temel İndirme Kodu

En basit haliyle, bir butona tıklandığında dosyayı masaüstüne indirmek için şu kodu kullanırız:
Kod:
-- Masaüstü yolunu otomatik alalım
sMasaustuYolu = Shell.GetFolder(SHF_DESKTOP);
-- İndirilecek dosyanın tam yolu
sHedefDosya = sMasaustuYolu .. "\\uydudoktoru_arac.zip";

-- İndirme işlemini başlat
HTTP.Download("https://uydudoktoru.com/indir/dosya.zip", sHedefDosya, MODE_BINARY, 20, 80, nil, nil, nil);

-- Hata kontrolü yapalım
nError = Application.GetLastError();
if (nError == 0) then
    Dialog.Message("Başarılı", "Dosya masaüstüne indirildi!", MB_OK, MB_ICONINFORMATION);
else
    Dialog.Message("Hata", "Dosya indirilemedi. Hata Kodu: " .. nError, MB_OK, MB_ICONSTOP);
end

2. İndirme Durumunu Takip Etmek (Callback Function)

Kullanıcıya "dosya iniyor mu?" diye düşündürmemek için bir Status Dialog açmak en iyisidir. HTTP.Download fonksiyonunun içine bir "Callback" fonksiyonu ekleyerek ilerlemeyi (yüzdeyi) anlık gösterebiliriz.
Kod:
-- İlerleme takibi yapan fonksiyon
function OnDownloadProgress(BytesRead, TotalBytes, TransferRate)
    nPercent = Math.Floor((BytesRead / TotalBytes) * 100);
    StatusDummy.SetStatusText("İndiriliyor: %" .. nPercent .. " (" .. TransferRate .. " kb/s)");
    return true; -- İndirmeye devam et
end

-- İndirmeyi başlatırken fonksiyonu çağır
StatusDummy.Show(true, "Dosya Alınıyor...", "Lütfen bekleyin.");
HTTP.Download("https://site.com/dosya.exe", sHedefDosya, MODE_BINARY, 20, 80, nil, nil, OnDownloadProgress);
StatusDummy.Show(false);

Teknik İpucu (Usta Notu)

Usta, dükkanda müşterilerin cihazlarına yazılım atarken (örneğin bir uydu alıcısı veya CCTV yazılımı), en güncel dosyayı her seferinde manuel aramak yerine bu indirme sistemini kullanabilirsin. Kendi web alanına (uydudoktoru.com/indir/ gibi) dosyaları güncel halleriyle yüklersin, AMS ile hazırladığın araç her seferinde o sabit linkten en son sürümü çeker. Böylece "eski versiyon mu yükledim?" derdinden kurtulursun.

Ayrıca, Shell.GetFolder(SHF_DESKTOP) komutu çok kritiktir; çünkü her kullanıcının bilgisayarındaki masaüstü yolu (Kullanıcı adı farklı olduğu için) değişir. Bu komut, yolu otomatik bulur ve hatayı önler.
 
Geri
Yukarı