Get location of Downloads folder Topic is solved

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
ThePeter
Posts: 49
Joined: 25 Oct 2022, 05:57

Get location of Downloads folder

Post by ThePeter » 27 Mar 2023, 04:27

viewtopic.php?f=76&t=66133

I would like to retrieve the full path for the Downloads folder. I am aware of the linked solutions having been posted, but I am having a hard time translating this into v2 with all the DLL stuff... Can anybody help me out?

User avatar
mikeyww
Posts: 26754
Joined: 09 Sep 2014, 18:38

Re: Get location of Downloads folder  Topic is solved

Post by mikeyww » 27 Mar 2023, 07:40

Code: Select all

; This script gets the user's Downloads directory
#Requires AutoHotkey v2.0

downloads := downloadsDir()
MsgBox downloads, 'Downloads directory', 64

downloadsDir() {
 ; Adapted from teadrinker: https://www.autohotkey.com/boards/viewtopic.php?p=284248#p284248
 ; https://learn.microsoft.com/en-us/windows/win32/shell/csidl
 ; https://learn.microsoft.com/en-us/windows/win32/shell/knownfolderid
 Static FOLDERID_Downloads := '{374DE290-123F-4565-9164-39C4925E467B}'
      , keyName            := 'HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders'
      , valueName          := FOLDERID_Downloads
 VarSetStrCapacity(&downloads, 261 << 1)
 DllCall('ExpandEnvironmentStrings', 'Str', RegRead(keyName, valueName), 'Str', downloads, 'UInt', 260)
 Return downloads
}

ThePeter
Posts: 49
Joined: 25 Oct 2022, 05:57

Re: Get location of Downloads folder

Post by ThePeter » 27 Mar 2023, 07:57

Awesome, thank you!

Post Reply

Return to “Ask for Help (v2)”