Jump to content

Notification when Download is finished


 Share

Recommended Posts

So i have been making a little program that helps my mom with copying mp3 files onto her mp3-player-usb-stick-thingy.

i already did the part with the copying onto the mp3-player but now i have to get the file that she downloaded. It seems to be pretty hard for her to find the file she just downloaded thats why i wanted to find it and automatically copy it over to the mp3-player. i've already thought about getting the amount of files in the download directory and then comparing it against the amount after the download and spotting the file like that but its very complicated and maybe there is some function in an UDF i dont know about that would help me with this problem.

she is using firefox.

thanks, Oracle  :sweating:

Link to comment
Share on other sites

Try doing a search for "synchronize directories" and/or "synchronize folders". There are multiple examples. If you run into specific challenges, be sure to raise a more specific question here on the forum. Good luck!

Roses are FF0000, violets are 0000FF... All my base are belong to you.

Link to comment
Share on other sites

Try doing a search for "synchronize directories" and/or "synchronize folders". There are multiple examples. If you run into specific challenges, be sure to raise a more specific question here on the forum. Good luck!

To form my question again (it was a bit late yesterday and i was in quite a hurry)

I want my script to wait until a certain download is finished.

thats all. But quite complicated nonetheless...

Link to comment
Share on other sites

  • Moderators

ImOracle,

I have used seangriffin's FileSystemMonitor UDF very successfully to detect new files being created. Give it a go and come back if you run into problems. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

yea okay i dont get it.

i dont know anything about COM objects neither do i understand the example he has provided in his thread...

i know that at some point the _FileSysMonDirEventHandler() calls _FileSysMonActionEvent() but i dont know when and what to do with the parameters  :sweating:

im quite new to autoit...

as you can tell  :sweating:

Link to comment
Share on other sites

  • Moderators

ImOracle,

Try reading this thread and running the code in post #2 - that might make it a bit clearer. ;)

If you still have problems let me know and I will try and explain (as much as I can) when I next have some free time - probably tomorrow afternoon. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

i think i understood it, mostly.

whats the $event_type parameter for? or what does it mean?

$event_id can contain certain hex values that define certain events that have happened to the drive (like file/folder added or folder removed)

$event_value contains the name of the folder or file...

yea i only need $event_type now...

thanks in advance youre really helping me! :D

Link to comment
Share on other sites

Okay i have kind of threw together a prototype that will just pop up a msgbox when a file has been added to C:Users@UserNameDownloads and a msgbox when the file is a *.mp3 file.

the last part with the mp3 doesnt quite work because the file that the UDF returns, is a .tmp file with a random name.  >_<

#include <FileSystemMonitor.au3>
_FileSysMonSetup(3, "C:\Users\"&@UserName&"\Downloads", "")
While 1
    Sleep(250)
    ToolTip("waiting");just a little tooltip to see if we're still in the while-loop
    _FileSysMonDirEventHandler()
WEnd
Func _FileSysMonActionEvent($event_type, $event_id, $event_value)

    If $event_type = 0 Then

        If $event_id=0x00000001 Then

            MsgBox(0, 0, $event_value);more or less a debugging msgbox to get the file that had been located

            If StringInStr($event_value, ".mp3") > 0 Then
                MsgBox(0, 0, "mp3 file added to downloads")
            EndIf

        EndIf

    EndIf

EndFunc

it doesnt seems to care about the .mp3 file at all.

I will keep searching and maybe i will find a solution myself

as i said above, thanks again :D

EDIT:

okay i have read through the whole thread you provided and found your modded version of the UDF

i wanted to test it but failed because of my limited knowledge about COM...  :sweating:

 

$fs_event.item(Hex(0x00000001)) = "file added to the directory|FILE_ACTION_ADDED"

$fs_event.item(Hex(0x00000002)) = "Non-folder item created|SHCNE_CREATE"

those values seem like they could help me but i have no idea how to use them...  >_<

maybe there is actually no way to determine if the file downloaded is an mp3

but i could manually delete every mp3 file in the download folder (i dont think she will download music that she doesnt want on her mp3 player) and whenever a file has been added to the download folder i could search the whole folder for a mp3 file. if there is one copy it over to the usb, and delete the mp3 in the downloads folder. if the usb isnt connected wait until it has, copy all mp3s over and delete them on the pc.

maybe i will do that...

Or i might have to show her how to find the files in browser. but that would be more complicated than reprogramming the whole OS just for the sake of that function xD

didnt know that this could be so complicated. thanks anyways :D

Edited by ImOracle
Link to comment
Share on other sites

  • Moderators

ImOracle,

 

the file that the UDF returns, is a .tmp file with a random name

I wonder if that is the downloader creating a temporary file during the download process which will be renamed after the download finishes. Perhaps you need to look for a file rename event which follows the file creation. :huh:

 

didnt know that this could be so complicated

Alas, in computing things which to us humans appear simple are often thus. :(>

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

 

I wonder if that is the downloader creating a temporary file during the download process which will be renamed after the download finishes. Perhaps you need to look for a file rename event which follows the file creation. 

Might actually be the case...

Im tired now, on my end of the world its about 11 pm and i have been looking at code the whole day.

Im gonna bring up a new Edit tomorrow

Link to comment
Share on other sites

UPDATE: finally got it. Minor tweaks did it for some reason

i dont know wether the .tmp file created is actually the file im looking for but somewhen a file (<filename>.mp3.crdownload) is created and when the file has finished downloading its renamed to the actual <filename>.mp3 (the one im looking for)

for some reason the msgbox pops up twice but thats no big deal

#include <FileSystemMonitor.au3>

_FileSysMonSetup(3, "C:\Users\"&@UserName&"\Downloads", "")
While 1
    Sleep(250)
    ToolTip("waiting");just a little tooltip to see if we're still in the while-loop
    _FileSysMonDirEventHandler()
WEnd
Func _FileSysMonActionEvent($event_type, $event_id, $event_value)
    If $event_type = 0 Then

        ;If $event_id=0x00000005 Then

            If StringInStr($event_value, ".mp3") > 0 And StringInStr($event_value, "crdownload") = 0 Then
                MsgBox(0, "Success", "mp3 file ("&$event_value&") added to downloads")
            EndIf

        ;EndIf

    EndIf

EndFunc
Link to comment
Share on other sites

  • Moderators

ImOracle,

 

finally got it

Delighted - perseverance paying off is always nice to see. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...