Jump to content
Sign in to follow this  
TheAutomator

Downloads folder macro?

Recommended Posts

How can you get the downloads folder in AutoIT?

As far as i know there isn't a macro for it right? like @Downloads or something?

The ugly solution would be typing in the whole path but what if the user has chosen another location?

Need to clear that folder regularly on my work and on different accounts..

regards, TheAutomator

Share this post


Link to post
Share on other sites

Like so:

ShellExecute(@UserProfileDir & "\Downloads")

edit, I missed your "User has chosen another location". Typically I would say look at EnvGet, but don't think the Downloads folder is set as a typical environment variable. There is DEFAULT_DOWNLOADS, but that is for the default profile.

Edited by JLogan3o13

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Share this post


Link to post
Share on other sites

I know that if you change the path (and only if you change the path) it will show up in HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders, but it shows up as a GUID, like so:

Downloads.PNG

You could search for that, but would have to either load the user's registry hive or run it as them (startup script). And I believe several other folders, when changed, produce a similarly encoded name, so not sure how you would distinguish that {374DE290-...} is the new target for the Downloads folder and not something else. If the user goes so far as to redirect one folder, they may do so for others.

Edited by JLogan3o13

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Share this post


Link to post
Share on other sites

Yes, it could be ugly either way. You could do a fileExists, but unfortunately it won't tell you where the folder has been redirected. You would have to do something like this (pseudo):

If Not (FileExists(@UserProfileDir & "\Downloads")) Then
    For $a = 1 To 100
        $sVal = RegEnumVal("HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders", $a)
        If @error Then
            ExitLoop
        Else
            If StringInStr($sVal, "{374DE290-") Then
                ;further processing
            EndIf
        EndIf
    Next
EndIf

Even if you stick with the "ugly" C:\Users\TheAutomator\Downloads, if the user has moved the target you're sunk. Good luck with your project.


"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Share this post


Link to post
Share on other sites

This link has a lot of information about special folders, their GUIDs and default locations etc.

https://msdn.microsoft.com/en-us/library/windows/desktop/dd378457(v=vs.85).aspx


"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook

Share this post


Link to post
Share on other sites

So according to that page the GUID is static, after all. That should make things slightly easier for you, should you go that route, @TheAutomator


"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Share this post


Link to post
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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By TheSaint
      I like and have been using TeraCopy, a third party program, for many years. Mostly it is a great program, but it does have some issues. On Windows XP for instance, Thumbs.db files could often hold up a copy or move process until the user manually responded to the error prompt. Some other issues I discuss below.
      PLEASE NOTE - I am not related to or affiliated in any way with the 3rd party TeraCopy program developers.
      ALSO NOTE - I myself have only tested TeraCopy Cure at this point, on Windows 7 (32 bit), and only with the free version of TeraCopy 2.27.
      This program, TeraCopy Cure, is related to another one of my TeraCopy assistant programs, TeraCopy Timer, but aims at being simpler and quicker to use ... if lacking its more advanced features.
      TeraCopy Cure is a frontend for TeraCopy and sets out to make up for its flaws and limitations.
      One of those flaws is queuing order, and the limitation relates to a same destination issue.
      You would think that queue order would be the same as add order, but that is not the case, and if you are doing a mix of COPY and MOVE then the COPY process could easily fail. It could fail with some source items, even if the  COPY process has already started before the same source MOVE process begins ... especially if the destination folder is on the source drive ... only the currently copying file is locked to that process.
      If you drag and drop another source for a same destination as an existing or impending COPY or MOVE process, then usually TeraCopy nicely adds it for you to that existing job. However, you might wish to avoid that, or it might occur during the testing phase of that active process, and then not be properly processed etc. But you are not given a choice and it just gets added.
       
           
      HOW TO USE
      See the right-click menu of the 'Batch List' (lowest field) and the right-click menu of the Tree field, for some useful options.
      (1) If desired, enable 'Auto Start'. NOTE - Even if enabled, this can be bypassed.
      (2) Set the destination folder, either by browsing on the tree or by dragging a folder to the Destination input field or label. Right-clicking on a folder in Explorer will also work, if enabled. The destination folder path will also show in the Tree if that right-click option is enabled.
      (3) Then drag & drop source file or folder onto one of three five areas - Folder (Drive) Tree field, or COPY or MOVE buttons ... this now also includes the source input and label.
      NOTE - If the Folder (Drive) Tree field is used, then you will additionally need to click either the COPY or MOVE button, to have that job added to the Batch List ... but this avoids 'Auto Start' if it is enabled. Drag & dropping to the buttons instead, saves on clicking, but starts the first job etc immediately if 'Auto Start' is enabled.
      (4) If needed and ready, click the START button to run the first job and those that follow.
      More information is included in program and in the NOTES etc sections below.
         
      WARNING - Depending on the amount of content on your destination drive, and folder level depth, and the speed of your PC, display of the full path in the Folder (Drive) Tree can take a while to show ... if you have that (right-click) option enabled ... it isn't by default. I found this feature quite tricky to get right, and I'm still not 100% sure it is now full-proof.
      TeraCopy Cure v1.5.zip  (source is included)
      TeraCopy Cure v1.6.zip  (source is included)
      NOTES
      UPDATES INFORMATION
      OLDER DOWNLOADS
       
    • By TheSaint
      Some of you might find this little program I whipped up yesterday, to be useful. I had a need and it was filled.
      It is pretty basic and I admit was pretty much slapped together speedily and then fine tuned some time later, and could certainly do with more improving, if you care to do so.
      Thanks to Jefrey for his 'parse.au3' for the PHP elements. Source found here. I also used my Dropbox code, found here.

      Gutenberg Project page I used for the screenshot - http://www.gutenberg.org/ebooks/1965
      One of their links looks like - http://www.gutenberg.org/ebooks/1965.epub.images?session_id=5932cd1d25afee6150a958323abd8a32d68249a7
      V1.3   v1.6     v2.0 
      Basically, the Download Dropbox program aims to simplify and speed up downloading of files, with Batch and easy sub-folder creation.
      Everything in the program is done by either Drag & Drop or clicking a button. Window floats on top of others, naturally.
      1. Drag a folder to the Destination input field to set the destination path.
      2. Highlight some text, then drag that text to the drop zone (top edit field), to create the first sub-folder (if you want one). Click the SUB FOLDER button to assign it.
      3. Do the same for the next sub-folder (if you want one or instead of the other sub folder). Click the TITLE button to assign it.
      4. Select and drag a link (URL) to the drop zone. Click the ADD button to have it added to the Download list (last field).
      5. Repeat for more files, that you wish to send to the same destination.
      6. Click the DOWNLOAD button to have them start downloading.
      If size of each download can be determined, you will see the Progress bar working.
      All the buttons & List have a CTRL key feature, some also have a SHIFT key one. See the Program Information dialog for details.
      Drop zone and other inputs, can also be typed or pasted into.
      Some settings are saved to INI file and recalled on subsequent executions or the click of a button with CTRL held down.
      NOTE - I particularly like the Text Drag ability, as that simplifies things when doing lots of sub-folders. No browsing required.
      ADVICE - Clicking an entry in the list field, will momentarily display its full link text in the drop zone. Entries on the List are not sorted, so they appear in the order added. Obviously I wanted the program to take up as least desktop space as feasible, so that means truncated list entries etc.
      WARNING - Before doing a bunch of links from a site, where the links are not straight forward, do a test run of one. Especially as there is currently no STOP button.
      Downloads Dropbox v2.1.zip  (see Post #11 for detail) (see Post #7 for a GOG example)
      OLDER DOWNLOADS
      IMPROVEMENTS & LIMITATIONS
      I have tailored certain elements for Gutenberg Project downloads and another site or two, so things will not work out-of-the-box for all possible download sites. That means you will have to tweak the code for some sites. Straight forward download links (no tricky php) seem to work fine. In particular, while what you might want to get downloads fine, it may be missing the file extension and not have the desired name.
      Sometimes, if you drag & drop an image onto the drop zone, the image will display there, and you cannot grab its URL. In those cases, I just right click the original image, grab its URL and paste that into the drop zone. You can clear the displayed image (and any other entry in the drop zone) by holding down CTRL while clicking the DOWNLOAD button.
      At this stage, you can only batch download files that you want, to the same destination. I am considering adding a multiple destination ability.
      Need to add a STOP button.
      P.S. This is my first second full program with the latest AutoIt.
    • By vin1
      i have a script that selects  a text file and deletes a line (text input required) in the text file selected
      i have to make it remove all lines found on a file i name, toRemoveLines.txt
      it has to remove lines from all text files found in a folder
      this is the script that has to be modified
      where it says "select file" it has to be "select folder"
      where it says "line text input" it has to be all lines from a text file
      #Include <File.au3> Global $success = False $file_name = FileOpenDialog("Select file", @ScriptDir, "All files (*.*)", 1+4) $line_text_input = InputBox("Line's text", "Line must contain following text:", "line contains this text") $file_count_lines = _FileCountLines($file_name) for $i = 0 to $file_count_lines $Lines_text_output = FileReadLine($file_name, $i) if StringInStr($Lines_text_output, $line_text_input) then _FileWriteToLine($file_name, $i, "", 1) $success = True ExitLoop EndIf Next if $success = True Then MsgBox(0, "Success", "Line has been deleted") Else MsgBox(0, "Failure", "Line wasn't found") EndIf  
    • By Tersion
      Why I can't get more than two simultaneously background downloads?
      Simultaneously background downloads with InetGet() works! It was just server limitation from which I downloaded files.
    • By nacerbaaziz
      Hello
      I have a query please
      It is about windows file explorer
      If i design a tool in autoit language to delete files for example
      and i  added it in the context menu in File Explorer
      If i right-click on any file And you choose the tool, it will be get the path of the selected file or folder
      The problem here is
      If i select a set of files or folders
      it only detect the first one
      The code that i  used is
      if $CMDLine[0] = 0 then
      msgBox(16, "error", "you don't selecte any files")
      exit
      else
      for $i = 1 to $CMDLine[0]
      msgBox(0, "files", $CMDLine[$i]
      next
      endIf
      exit
×
×
  • Create New...