Help with getting current path of 'Save As' dialog please Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Mika_erdo
Posts: 41
Joined: 30 Jul 2020, 17:23

Help with getting current path of 'Save As' dialog please

Post by Mika_erdo » 26 Mar 2021, 22:47

I have so far written

Code: Select all

2::
ControlGetText, ThisPath, Edit2, ahk_class #32770
tooltip, %ThisPath%
Return
But it only seems to work if the edit2 (address bar field) control has focus. Is there a way to just get the save as windows current path without it even having focus?
Thanks allot for your help.

User avatar
boiler
Posts: 17224
Joined: 21 Dec 2014, 02:44

Re: Help with getting current path of save as dialog please  Topic is solved

Post by boiler » 26 Mar 2021, 23:58

Try this:

Code: Select all

ControlGetText, ThisPath, ToolbarWindow324, ahk_class #32770

Mika_erdo
Posts: 41
Joined: 30 Jul 2020, 17:23

Re: Help with getting current path of save as dialog please

Post by Mika_erdo » 27 Mar 2021, 07:06

boiler wrote: Try this:

Code: Select all

ControlGetText, ThisPath, ToolbarWindow324, ahk_class #32770
Thank you so much man, it works just like how I needed it to work.
if I may ask, how did you know where to get this ToolbarWindow324 control name? Using the spy window I did not come across it, just curious.

User avatar
boiler
Posts: 17224
Joined: 21 Dec 2014, 02:44

Re: Help with getting current path of save as dialog please

Post by boiler » 27 Mar 2021, 08:47

It’s the name of the control before you click on it. You can find it by selecting the “Follow Mouse” option in the Window Spy tool and hovering over the address bar when it’s in its other state before you click on it.

User avatar
DataLife
Posts: 460
Joined: 29 Sep 2013, 19:52

Re: Help with getting current path of save as dialog please

Post by DataLife » 28 Nov 2023, 18:10

boiler wrote:
26 Mar 2021, 23:58
Try this:

Code: Select all

ControlGetText, ThisPath, ToolbarWindow324, ahk_class #32770
This works great except when "This PC > Downloads" or "This PC > Documents" or "This PC > Pictures" and similar "This PC" locations are in the control, then it only retrieves "Downloads", "Documents", "Pictures" ETC...

Any ideas on a workaround?
Check out my scripts. (MyIpChanger) (ClipBoard Manager) (SavePictureAs)
All my scripts are tested on Windows 10, AutoHotkey 32 bit Ansi unless otherwise stated.

User avatar
boiler
Posts: 17224
Joined: 21 Dec 2014, 02:44

Re: Help with getting current path of 'Save As' dialog please

Post by boiler » 28 Nov 2023, 19:21

One thing you could do is check the result, and when it retrieves one of those, then you can use the contents of the associated built-in variable, such as A_Documents, A_MyDesktop, etc. And for the ones that don’t have built-in variables, they can typically be constructed from the ones that do, such as:

Code: Select all

MyPictures := StrReplace(A_Desktop, "Desktop", "Pictures")

There may be more elegant ways others could suggest.

User avatar
DataLife
Posts: 460
Joined: 29 Sep 2013, 19:52

Re: Help with getting current path of 'Save As' dialog please

Post by DataLife » 28 Nov 2023, 20:09

boiler wrote:
28 Nov 2023, 19:21
One thing you could do is check the result, and when it retrieves one of those, then you can use the contents of the associated built-in variable, such as A_Documents, A_MyDesktop, etc. And for the ones that don’t have built-in variables, they can typically be constructed from the ones that do, such as:

Code: Select all

MyPictures := StrReplace(A_Desktop, "Desktop", "Pictures")

There may be more elegant ways others could suggest.
This is a creative solution, but does not work for me.

My A_desktop is on C:\Users\DataLife\OneDrive\Desktop and my documents, downloads, music, videos and pictures are on C:\Users\UserName. for example C:\Users\DataLife\Pictures
Check out my scripts. (MyIpChanger) (ClipBoard Manager) (SavePictureAs)
All my scripts are tested on Windows 10, AutoHotkey 32 bit Ansi unless otherwise stated.

User avatar
boiler
Posts: 17224
Joined: 21 Dec 2014, 02:44

Re: Help with getting current path of 'Save As' dialog please

Post by boiler » 28 Nov 2023, 20:35

It seems like all of them can be built off of one of the built-in variables, and if not, you could hard-code in the paths for all the outliers, assuming it’s just for you.

(btw, I left off the “My” in some of the variable names in my prior post)

User avatar
DataLife
Posts: 460
Joined: 29 Sep 2013, 19:52

Re: Help with getting current path of 'Save As' dialog please

Post by DataLife » 28 Nov 2023, 21:03

boiler wrote:
28 Nov 2023, 20:35
It seems like all of them can be built off of one of the built-in variables, and if not, you could hard-code in the paths for all the outliers, assuming it’s just for you.

(btw, I left off the “My” in some of the variable names in my prior post)
Not just for me. For anyone that uses my SavePictureAs program.

Any user can move anyone of those folders, Documents, Music, Downloads, Desktop, Pictures using the folder properties and Location tab.
Check out my scripts. (MyIpChanger) (ClipBoard Manager) (SavePictureAs)
All my scripts are tested on Windows 10, AutoHotkey 32 bit Ansi unless otherwise stated.

User avatar
DataLife
Posts: 460
Joined: 29 Sep 2013, 19:52

Re: Help with getting current path of 'Save As' dialog please

Post by DataLife » 03 Dec 2023, 14:32

No need to guess at the location of Downloads, Music, Pictures and Videos.
Skan created a function to get these locations and many more. viewtopic.php?t=75602

Code: Select all

FOLDERID_Downloads := "{374DE290-123F-4565-9164-39C4925E467B}"
MsgBox % SHGetKnownFolderPath(FOLDERID_Downloads)
FOLDERID_Music := "{4BD8D571-6D19-48D3-BE97-422220080E43}"
MsgBox % SHGetKnownFolderPath(FOLDERID_Music)
FOLDERID_Pictures := "{33E28130-4E1E-4676-835A-98395C3BC3BB}"
MsgBox % SHGetKnownFolderPath(FOLDERID_Pictures)
FOLDERID_Videos := "{18989B1D-99B5-455B-841C-AB7C74E4DDFC}"
MsgBox % SHGetKnownFolderPath(FOLDERID_Videos)
FOLDERID_Desktop := "{B4BFCC3A-DB2C-424C-B029-7FE99A87C641}"
MsgBox % SHGetKnownFolderPath(FOLDERID_Desktop)
FOLDERID_Documents := "{FDD39AD0-238F-46AF-ADB4-6C85480369C7}"
MsgBox % SHGetKnownFolderPath(FOLDERID_Documents)
Return

SHGetKnownFolderPath(FOLDERID, KF_FLAG:=0) {                  ;   By SKAN on D356 @ tiny.cc/t-75602
Local CLSID, pPath:=""                                        ; Thanks teadrinker @ tiny.cc/p286094
Return Format("{4:}", VarSetCapacity(CLSID, 16, 0)
     , DllCall("ole32\CLSIDFromString", "Str",FOLDERID, "Ptr",&CLSID)
     , DllCall("shell32\SHGetKnownFolderPath", "Ptr",&CLSID, "UInt",KF_FLAG, "Ptr",0, "PtrP",pPath)
     , StrGet(pPath, "utf-16")
     , DllCall("ole32\CoTaskMemFree", "Ptr",pPath))
}
Check out my scripts. (MyIpChanger) (ClipBoard Manager) (SavePictureAs)
All my scripts are tested on Windows 10, AutoHotkey 32 bit Ansi unless otherwise stated.

Post Reply

Return to “Ask for Help (v1)”