A_Downloads might be a nice thing to have at some point.

Propose new features and changes
User avatar
RaptorX
Posts: 388
Joined: 06 Dec 2014, 14:27
Contact:

A_Downloads might be a nice thing to have at some point.

19 Apr 2024, 17:08

I think we have a nice set of built-in variables that are flexible enough to do a lot of interesting things, but I keep thinking we are missing the A_Downloads variable that would point to the default location the downloads folder at in a similar fashion to A_MyDocuments!

Unless there is a technical reason preventing this, it sounds a bit better than EnvGet('SystemDrive') '\Users\' A_UserName '\Downloads' :D
Projects:
AHK-ToolKit
User avatar
TheDewd
Posts: 1513
Joined: 19 Dec 2013, 11:16
Location: USA

Re: A_Downloads might be a nice thing to have at some point.

19 Apr 2024, 20:58

Code: Select all

; V1
RegRead, A_Downloads, HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders, {374DE290-123F-4565-9164-39C4925E467B}

; V2
A_Downloads := RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders", "{374DE290-123F-4565-9164-39C4925E467B}")
autoexec
Posts: 24
Joined: 20 Feb 2023, 22:38

Re: A_Downloads might be a nice thing to have at some point.

20 Apr 2024, 02:43

or

Code: Select all

A_Downloads := ComObject('Shell.Application').NameSpace('Shell:Downloads').Self.Path
User avatar
RaptorX
Posts: 388
Joined: 06 Dec 2014, 14:27
Contact:

Re: A_Downloads might be a nice thing to have at some point.

20 Apr 2024, 06:25

yeah! those are great! i have used the one @autoexec posted before...

but hear me out: how about just A_Downloads?? :D

That way you don't have to find those in the forums every time you need it? just type A_Downloads and you are good to go. xD
Projects:
AHK-ToolKit
User avatar
Animan8000
Posts: 58
Joined: 11 May 2022, 05:00
Contact:

Re: A_Downloads might be a nice thing to have at some point.

24 Apr 2024, 07:22

RaptorX wrote:
19 Apr 2024, 17:08
I think we have a nice set of built-in variables that are flexible enough to do a lot of interesting things, but I keep thinking we are missing the A_Downloads variable that would point to the default location the downloads folder at in a similar fashion to A_MyDocuments!

Unless there is a technical reason preventing this, it sounds a bit better than EnvGet('SystemDrive') '\Users\' A_UserName '\Downloads' :D
A little unrelated, but I generally don't recommend using "A_UserName" for trying to find subfolders (downloads, pictures, etc.) of a user folder. Because A_UserName contains only the username, and not necessarily the user folder name. Depending on how Windows is installed, the script can break, if the user folder is for example shortened by Windows automatically. For example fully reinstalling Windows locally without an external drive (USB for example) did typically shorten the user folder name to only 5 characters, effectively making A_UserName pointless in this situation, and I used A_AppData instead, and went to the folder above, to avoid that inconsistency
User avatar
RaptorX
Posts: 388
Joined: 06 Dec 2014, 14:27
Contact:

Re: A_Downloads might be a nice thing to have at some point.

24 Apr 2024, 10:37

Animan8000 wrote:
24 Apr 2024, 07:22
RaptorX wrote:
19 Apr 2024, 17:08
I think we have a nice set of built-in variables that are flexible enough to do a lot of interesting things, but I keep thinking we are missing the A_Downloads variable that would point to the default location the downloads folder at in a similar fashion to A_MyDocuments!

Unless there is a technical reason preventing this, it sounds a bit better than EnvGet('SystemDrive') '\Users\' A_UserName '\Downloads' :D
A little unrelated, but I generally don't recommend using "A_UserName" for trying to find subfolders (downloads, pictures, etc.) of a user folder. Because A_UserName contains only the username, and not necessarily the user folder name. Depending on how Windows is installed, the script can break, if the user folder is for example shortened by Windows automatically. For example fully reinstalling Windows locally without an external drive (USB for example) did typically shorten the user folder name to only 5 characters, effectively making A_UserName pointless in this situation, and I used A_AppData instead, and went to the folder above, to avoid that inconsistency
Totally correct, I usually use the above code only on my machine for quick scripts but I totally forgot that installing the "offline" version of windows messes with the User folder for whatever reason.

But basically that is part of my argument, instead of having to rely on workarounds to find that folder I think it would be a nice addition to have it behave as the builtin variables for "A_AppData" or "A_MyDocuments".

The reason why I think this might not get implemented is that people can change the location of the Downloads folder (which is something I do) by going to the preferences and setting the downloads location to a new place like this:
image.png
(20.11 KiB) Downloaded 33 times
But I would say you can do the same with "My Documents" but I am not sure how "A_MyDocuments" react to that... does it point to the new location, if it does, then I would have the same expectation for the proposed "A_Downloads".
Projects:
AHK-ToolKit
User avatar
xMaxrayx
Posts: 201
Joined: 06 Dec 2022, 02:56
Contact:

Re: A_Downloads might be a nice thing to have at some point.

15 May 2024, 13:08

agree, wish other folders like A_picture A_video exited.
-----------------------ヾ(•ω•`)o------------------------------
https://github.com/xmaxrayx/
just me
Posts: 9514
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: A_Downloads might be a nice thing to have at some point.

Today, 05:22

Code: Select all

#Requires Autohotkey v2.0
; ----------------------------------------------------------------------------------------------------------------------
KF := GetKnownFoldersPaths()
; ----------------------------------------------------------------------------------------------------------------------
GetKnownFoldersPaths() {
   Local KnownFolders := {}
   ; ===================================================================================================================
   ; IKnownFoldersManager interface
   ; https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/nn-shobjidl_core-iknownfoldermanager
   ; CLSID_KnownFoldersManager = "{4DF0C730-DF9D-4AE3-9153-AA6B82E9795A}"
   ; IID_IKnownFoldersManager  = "{8BE2D872-86AA-4d47-B776-32CCA40C7018}"
   ; ===================================================================================================================
   Local IKFM := ComObject("{4DF0C730-DF9D-4AE3-9153-AA6B82E9795A}", "{8BE2D872-86AA-4d47-B776-32CCA40C7018}")
   ; Gets an array of all registered known folder IDs. This can be used in enumerating all known folders.
   ; https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-iknownfoldermanager-getfolderids
   Local KFID := 0
   Local CID := 0
   ComCall(5, IKFM, "PtrP", &KFID, "IntP", &CID)
   ; Loop thru all returned folder IDs.
   Local IKF := 0
   Local StrPtr := 0
   Local KFP := 0
   Local Alias := ""
   Local Path := ""
   Local PKFID := KFID ; pointer to the current KNOWNFOLDERID
   Loop CID {
      ; Gets an object that represents a known folder identified by its KNOWNFOLDERID.
      ; https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-iknownfoldermanager-getfolder
      ComCall(6, IKFM, "Ptr", PKFID, "PtrP", &IKF)
      ; Retrieves a structure that contains the defining elements of a known folder,
      ; which includes the folder's category, name, path, description, tooltip, icon, and other properties.
      ; https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-iknownfolder-getfolderdefinition
      Local KFD := Buffer(40 + (A_PtrSize * 9), 0)
      ComCall(11, IKF, "Ptr", KFD.Ptr)
      ; Get the Name field of the structure
      Alias := StrReplace(StrGet(NumGet(KFD, A_PtrSize, "UPtr")), " ")
      ; Free the strings pointed to by structure fields
      FreeKnownFolderDefinitionFields(KFD)
      ; Retrieve the path of the known folder as a string.
      ; https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-iknownfolder-getpath
      Path := ""
      If !ComCall(6, IKF, "UInt", 0, "PtrP", &KFP, "UInt") {
         Path := ExpandEnvironmentStrings(StrGet(KFP))
         DllCall("Ole32.dll\CoTaskMemFree", "Ptr", KFP)
      }
      ; Release the IKnownFolder interface
      IKF := 0
      ; Add the name and path to the object, if a path was retrieved
      If !(Path = "")
         KnownFolders.%Alias% := Path
      ; Switch to the next KNOWNFOLDERID
      PKFID += 16
   }
   ; Free the KnownFolderID object
   DllCall("Ole32.dll\CoTaskMemFree", "Ptr", KFID)
   ; Release the IKnownFolderManager interface
   IKFM := 0
   ; Return the folder object
   Return KnownFolders
   ; -------------------------------------------------------------------------------------------------------------------
   FreeKnownFolderDefinitionFields(KFD) {
      Static OffSets := [A_PtrSize, A_PtrSize, A_PtrSize + 16, A_PtrSize, A_PtrSize, A_PtrSize, A_PtrSize, A_PtrSize]
      Local Offset := 0
      For O In Offsets {
         Offset += O
         DllCall("Ole32.dll\CoTaskMemFree", "Ptr", NumGet(KFD.Ptr + OffSet, "UPtr"))
      }
   }
   ; -------------------------------------------------------------------------------------------------------------------
   ExpandEnvironmentStrings(Str) {
      Local Chars := 0
      Local Expanded := ""
      If (Chars := DllCall("ExpandEnvironmentStringsW", "Str", Str, "Ptr", 0, "UInt", 0, "Int")) {
         VarSetStrCapacity(&Expanded, ++Chars)
         DllCall("ExpandEnvironmentStringsW", "Str", Str, "Str", &Expanded, "UInt", Chars, "Int")
      }
      Return (Chars ? Expanded : Str)
   }
}
; ======================================================================================================================
Main := Gui( , "KnownFolders")
Main.OnEvent("Close", (*) => ExitApp())
Main.SetFont("s10", "Lucida Console")
MainLV := Main.AddListView("w1200 r30 Grid", ["Index", "Alias", "Path"])
For K In KF.OwnProps()
   MainLV.Add("", A_Index, K, KF.%K%)
Loop MainLV.GetCount("Column")
   MainLV.ModifyCol(A_Index, "AutoHdr")
Main.Show()
User avatar
andymbody
Posts: 934
Joined: 02 Jul 2017, 23:47

Re: A_Downloads might be a nice thing to have at some point.

Today, 12:15

just me wrote:
Today, 05:22
Excellent! Thank you!
geek
Posts: 1053
Joined: 02 Oct 2013, 22:13
Location: GeekDude
Contact:

Re: A_Downloads might be a nice thing to have at some point.

Today, 12:31

Surprised to see it hasn't been mentioned, as it's the strategy I use exclusively: A_Desktop "\..\Downloads"

Almost everything accepts these kinds of paths, and it's dead simple to write. Granted, it is less simple than having A_Downloads would be.

Return to “Wish List”

Who is online

Users browsing this forum: No registered users and 7 guests