Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
IntGetFile Multiple File Progress
#1
What would need to be done to show a master progress status for multiple files from a website using IntGetFile?
#2
Function dialog_download_multiple_progress
Code:
Copy      Help
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages

str controls = "5 3"
str e5 lb3
e5="www.quickmacros.com"
lb3=
;images/ss/qm.png
;images/ss/debug.png
;com/winapi2.zip
str-- t_files; t_files=lb3

if(!ShowDialog("dialog_download_multiple_progress" &dialog_download_multiple_progress &controls)) ret

;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 223 135 "Dialog"
;6 Static 0x54000000 0x0 2 6 18 12 "Site"
;5 Edit 0x5C030080 0x200 22 4 196 14 ""
;7 Static 0x54000000 0x0 2 24 18 12 "Files"
;3 ListBox 0x5C230101 0x200 22 22 198 74 ""
;4 msctls_progress32 0x54030000 0x0 42 100 178 13 ""
;2 Button 0x54030000 0x4 170 116 48 14 "Cancel"
;8 Static 0x54000000 0x0 2 100 36 13 ""
;END DIALOG
;DIALOG EDITOR: "" 0x2030300 "*" "" ""

ret
;messages
sel message
,case WM_INITDIALOG
,PostMessage hDlg WM_APP 0 0
,case WM_APP goto g1
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
ret 1
;g1
Http http.Connect(_s.getwintext(id(5 hDlg)))
http.SetProgressCallback(&DDMP_Callback hDlg)
str sf sd; int i hlb(id(3 hDlg))
foreach sf t_files
,LB_SelectItem(hlb i) ; i+1
,if !http.Get(sf sd 32)
,,if(http.lasterror~"cancel") ret
,,sel(mes(F"Failed to download '{sf}'. Error:  {http.lasterror}[][]Continue?" "" "YN")) case 'Y' continue; case else break
,;out sd.len
opt waitmsg 1; 0.5; clo hDlg

Function DDMP_Callback
Code:
Copy      Help
;/
function# nbAll nbRead str&s hDlg
;out nbRead
if(!IsWindowVisible(hDlg)) ret 1 ;;Cancel
if(nbRead=0) _s.format("%i KB" nbAll/1024); _s.setwintext(id(8 hDlg))
SendMessage id(4 hDlg) PBM_SETPOS MulDiv(nbRead 100 nbAll) 0
#3
This code is way out of my comfort zone of understanding.

But I see that I would send to the dialog the list of files in the lb3 variable and the host website on the e5 variable.

So I could set the list of files into a variable. Then call the dialog through a mac command sending the variable as a cl.
Then receive it through lb3=_command?

Or do you know a better way to pass the list of files from the script to the dialog for the progress bar?

The Http stuff is the same as IntGetFile?

Thanks,
Jim
#4
Yes. I used it to avoid connect/disconnect when all files are from same server. But instead can be used IntGetFile.

This is not finished but works.

[DELETED]
#5
This is great. Anyway to show to total size of all the files and the progress based on that?

The array does not output when the macro finishes and where do the files go? These are probably parts of the "not finished"

-jim
#6
After IntGetFile, add sd to p.a as new element.
p.a[]=sd
#7
Quote:Anyway to show to total size of all the files and the progress based on that?

It will take some time before downloading files, because for each file need to send request to the server and receive headers that contain file size. Assume it will be 0.5 s. Multiply to the number of files. Is it OK?
#8
Yes. Usually there are only like 10 files. Perhaps a dialog saying..."Preparing for download" so the program doesn't just look hung.

Thanks bunches for all of your work!
#9
Finished, with total progress.


Attached Files
.qml   Dialog download multiple files withs progress dialog.qml (Size: 4.5 KB / Downloads: 306)
#10
Wow. That's exactly it. Thank you so much!!
#11
I was able to tweak the main macro to fit exactly what I need to save the files with specified names. It's a little gritty, but does the trick Wink

Function IngGetCSV
Code:
Copy      Help
function ~CSV

;EXAMPLE
;str CSV=
;;http://www.quickmacros.com/images/ss/qm.png,$desktop$\qm.png
;;http://www.quickmacros.com/images/ss/debug.png,$desktop$\debug.png
;IngGetCSV CSV

ICsv v=CreateCsv()
v.FromString(CSV)
for int'r 0 v.RowCount
,str s.addline(v.Cell(r 0))
str saveFolder="$temp$\temp download"
del- saveFolder;err
ARRAY(str) a
IntGetFileMultiProgress s saveFolder a 0x10000

Dir d
foreach(d F"{saveFolder}\*" FE_Dir)
,str sPath=d.FileName(1)
,str fName=d.FileName
,for r 0 v.RowCount
,,str uName.getfilename(v.Cell(r 0) 1)
,,if fName=uName
,,,cop sPath v.Cell(r 1)
del- saveFolder


Forum Jump:


Users browsing this thread: 1 Guest(s)