mdduru Posted December 6, 2015 Share Posted December 6, 2015 (edited) Arkadaşlar ben bir dosya indirme programı hazırlıyorum ama şöyle bir kaç sorunum var 1. Sorunum: İptal butonuna bastığımda downloadı kesmek istiyorum ama olmuyor 2. Sorunum: 2 link seçtiğimde birinci linki indirdikten sonra ikinci linke geçmesini istiyorum Kullandığım Kodlar: Page1 On Show TreeList.AddColumn("Plugin1", "",70) TreeList.AddColumn("Plugin1", "Oyun Dosyası", 470) tSections = INIFile.GetSectionNames("AutoPlay\\Docs\\liste.ini") -- programlari al if Table.Count(tSections) ~= 0 then -- liste boş değilse for i,v in pairs(tSections) do sira = v; -- ini sirasi isim = INIFile.GetValue("AutoPlay\\Docs\\liste.ini", v, "isim"); TreeList.AddRow("Plugin1","".."|".. isim.."|", nil, 0, String.ToNumber(sira)) end end Dialog On Show count = TreeList.CountRows("Plugin1", false) -- listeyi say if count ~= 0 then -- lşste boş değilse for i=0,count-1 do if TreeList.GetRowChecked("Plugin1", i) then -- eğer sıradaki satır seçili ise data = TreeList.GetRowData("Plugin1", i) link = INIFile.GetValue("AutoPlay\\Docs\\liste.ini", data, "link"); count = TreeList.CountRows("Plugin1", false) -- listeyi say if count ~= 0 then -- lşste boş değilse for i=0,count-1 do if TreeList.GetRowChecked("Plugin1", i) then -- eğer sıradaki satır seçili ise data = TreeList.GetRowData("Plugin1", i) link = INIFile.GetValue("AutoPlay\\Docs\\liste.ini", data, "link"); HTTP.Download(link, _SourceFolder .. "\\AutoPlay\\OyunDosyaları\\" .. String.SplitPath(link).Filename .. String.SplitPath(link).Extension, MODE_BINARY, 20, 80, nil, nil,DownloadCallback); inendosya = _SourceFolder .. "\\AutoPlay\\OyunDosyaları\\" .. String.SplitPath(link).Filename .. String.SplitPath(link).Extension; end end end end end end Program.indir() Global Secili = 0 bos = 0 inendosya = ""; Program = {} Program.indir = function() if Secili ~= 0 then tamami = TreeList.CountRows("Plugin1", false); toplam = 0; for i=1,tamami do secilimi = TreeList.GetRowChecked("Plugin1", i-1); if(secilimi) then toplam = toplam+1; end end Say = TreeList.CountRows("Plugin1", false); for i=1, Say do Bak = TreeList.GetRowChecked("Plugin1", i-1); if Bak then Programs = TreeList.GetCellText("Plugin1", i-1, 1); end end Dialog.Message("Counter Strike", Secili.." Adet Oyun Dosyasının İndirilme İşlemi Tamamlandı !", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1); result = DialogEx.Close(0); for i=0, Say do TreeList.SetRowChecked("Plugin1", i, false); end end end function DownloadCallback (Downloaded, Total, TransferRate, SecondLeft, SecondsLeftFormat, Message) hiz= Math.Floor(TransferRate); sDownloaded = String.GetFormattedSize(Downloaded, FMTSIZE_AUTOMATIC, true); sTotal = String.GetFormattedSize(Total, FMTSIZE_AUTOMATIC, true); Label.SetText("indirilen", "İndirilen: "..sDownloaded.." / "..sTotal); Label.SetText("zaman", "Kalan Zaman: "..SecondsLeftFormat); Label.SetText("hiz", "İndirme Hızı: ".. hiz .. " kb/sn"); Progress.SetCurrentPos("Progress1", (Downloaded / Total) * 100); Label.SetText("Label1", "%" .. Math.Floor((Downloaded / Total) * 100)); end Edited December 7, 2015 by mdduru Quote Link to comment Share on other sites More sharing options...
milano88 Posted December 7, 2015 Share Posted December 7, 2015 (edited) DownloadCallback en sonuna: if (gCancel_Download) then return false; else return true; end Download İptal butonuna: gCancel_Download = true; eklersen download işlemini iptal edebilirsin, sırasıyla indirme zaten otomatik olarak oluyor misal bir httpdownload(aaa.zip) dersin onun altına httpdownload(bbb.zip) dersin sırayla iner zaten Örnek: HTTP.Download("http://www.mydomain.com/myfile.exe", "C:\\Downloads\\myfile.exe", MODE_BINARY, 20, 80, nil, nil, DownloadCallback); if ( Application.GetLastError() == 0 ) then --- 2'nci url buraya else --- dosya indirilemiyor hata var end Edited December 7, 2015 by milano88 Quote Link to comment Share on other sites More sharing options...
mdduru Posted December 7, 2015 Author Share Posted December 7, 2015 DownloadCallback en sonuna: if (gCancel_Download) then return false; else return true; end Download İptal butonuna: gCancel_Download = true; eklersen download işlemini iptal edebilirsin, sırasıyla indirme zaten otomatik olarak oluyor misal bir httpdownload(aaa.zip) dersin onun altına httpdownload(bbb.zip) dersin sırayla iner zaten Örnek: HTTP.Download("http://www.mydomain.com/myfile.exe", "C:\\Downloads\\myfile.exe", MODE_BINARY, 20, 80, nil, nil, DownloadCallback); if ( Application.GetLastError() == 0 ) then --- 2'nci url buraya else --- dosya indirilemiyor hata var end ben proje dosyasını koyayım isterseniz siz bakın :) iptal işlemini yapmıyor devam ediyor :( birde eksikliğim varsa kodlarda onu da kontrol edermisiniz? http://s3.dosya.tc/server6/aaj2ag/Winrardeneme.rar.html Quote Link to comment Share on other sites More sharing options...
milano88 Posted December 7, 2015 Share Posted December 7, 2015 (edited) Ben fuction'un en altına dedim sen gidip function dışına yazmışsın :) DownloadCallback bu şekilde olucak: function DownloadCallback (nDownloaded, nTotal, TransferRate, SecondLeft, SecondsLeftFormat, Message) if (nTotal ~= 0) then local hiz = string.format("%.0f", TransferRate) .. "KB/S"; local percent = string.format("%d", ((nDownloaded/nTotal) * 100)); local sDownloaded = String.GetFormattedSize(nDownloaded, FMTSIZE_AUTOMATIC, true); local sTotal = String.GetFormattedSize(nTotal, FMTSIZE_AUTOMATIC, true); Label.SetText("indirilen", "İndirilen: "..sDownloaded.." / "..sTotal); Label.SetText("zaman", "Kalan Zaman: "..SecondsLeftFormat); Label.SetText("hiz", "İndirme Hızı: " .. hiz); Progress.SetCurrentPos("Progress1", percent); Label.SetText("Label1", "%" .. percent); else Label.SetText("indirilen", "İndirilen: "); Label.SetText("zaman", "Kalan Zaman: "); Label.SetText("hiz", "İndirme Hızı: "); Progress.SetCurrentPos("Progress1", 0); Label.SetText("Label1", "Bağlanılıyor ..."); end if (gCancel_Download) then return false; else return true; end end İndirmeyi durdur butonu bu şekilde: gCancel_Download = true; Dialog.Message("Counter Strike", "İndirme İptal Edilmiştir.", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1); NOT: Global ve Local değişken kullanmasını öğrenmelisin , bütün değişkenleri global olarak tanımlamışsın, eğer bir değişkeni sadece function içerisinde kullanacaksan local olarak kullanmalısın , yok eğer bana bu başka yerdede lazım diyorsan , o zaman değişken önüne local yazmazsın global değişken olur. Bu şekilde yaparsan daha stabil çalışır bir yazılım olur yoksa değişkenler hep hafızada durur ve kullanıcının bilgisayarını yavaşlatır. Bu ufak bir proje ama büyük projeler'de bu başına bela olur. Edited December 7, 2015 by milano88 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.