Easy Access to Currently Opened Folders

Post your working scripts, libraries and tools
User avatar
davebrny
Posts: 83
Joined: 05 Dec 2016, 06:26

Re: Easy Access to Currently Opened Folders

22 Dec 2016, 18:54

this has been one of my pet peeves since forever. all the way back to windows xp when i got my first computer. its even more frustrating when the folder is open right there beside the "save as" window. its strange to think there is still no official solution after all this time but maybe none of the great people at microsoft are as bothered by this

anyway, just in case you dont know about it .document.folder.self.path stores the exact path to a folder so you might be able to skip the PathCreateFromUrl() function that youre using. (unless there is some other reason for doing it that way.... i just had a quick scan through your script so i could be missing something else)

Code: Select all

For pwb in ComObjCreate("Shell.Application").Windows
	Menu, CurrentLocations, Add, % pwb.document.folder.self.path, f_Navigate
ive also got away without using any sleep or controlGetFocus commands but maybe you have run into problems yourself

Code: Select all

winActivate, ahk_class #32770
send ^{l}
controlSetText, edit2, % a_thisMenuItem, ahk_class #32770
send {enter}
thats a great idea using this for the command line though, and sending the focus back to edit1 is a nice touch so im gonna have to rob that on you as well :D
leeroy
Posts: 5
Joined: 22 Dec 2016, 13:59
GitHub: akaleeroy

Re: Easy Access to Currently Opened Folders

23 Dec 2016, 07:55

I suspected there would be a function to get the path in a clean format! Thanks for that one, saves a DllCall! :clap:
ive also got away without using any sleep or controlGetFocus commands but maybe you have run into problems yourself
The problems here are that
1) Edit2 doesn't exist when the dialog inits. There's only the breadcrumb controls, like ToolbarWindow322, which the user clicks to turn into an edit box.
2) On custom dialogs (such as MPC-HC's Save Image dialog) the address bar editbox is bumped to Edit3! In that dialog Edit2 is actually the JPEG Quality input. Go figure! Why this is allowed I do not know, maybe there are good reasons, who knows. :wtf:

So I have to grab the address bar by ID because its class sits on shifting sands. Also want to make sure I target the right dialog in case several are open, dunnow... And Sleep 50 has also proven necessary on my machine.

Again, see the discussion on Reddit
User avatar
davebrny
Posts: 83
Joined: 05 Dec 2016, 06:26

Re: Easy Access to Currently Opened Folders

23 Dec 2016, 17:26

leeroy wrote:the address bar editbox is bumped to Edit3!
ha what a mess. its like the search box in the autohotkey .chm help file. it changes to a different edit number depending on what tabs youve clicked on which means there is no predictable way to know which it is :headwall:
Acecool
Posts: 37
Joined: 10 Jan 2016, 18:25
Facebook: Acecool
Google: Acecool
GitHub: Acecool
Contact:

Re: Easy Access to Currently Opened Folders

25 Dec 2016, 19:10

Going to try it out and see if it works with Directory Opus or see about getting it to work for DOpus... If so I'll be adding this to my personal framework addons_run folder to have it run every time I launch my framework ( which holds all of my scripts / hotkeys / classes / etc.. and dynamically creates the inclusion lists https://bitbucket.org/Acecool/acecoolah ... k/overview ) but I wouldn't release it with your script without your consent, naturally..

Edit: Found a bug - I'll post on github too..

If you only have one folder open and you middle click > release middle click > left-click only folder > release left-click - it will save to the currently opened folder instead of switching to the selected folder... I just saved the web-page and wanted to save to downloads and thought it worked when it automatically closed the SaveAs window after selecting the downloads folder... But, then I opened folder location and it was the previous folder in SaveAs... When 2 folders are open, clicking on 1 actually switches the folder.
-Josh 'Acecool' Moser
I teach various programming languages, game programming, etc... I am also taking on programming jobs as my health allows.
User avatar
davebrny
Posts: 83
Joined: 05 Dec 2016, 06:26

Re: Easy Access to Currently Opened Folders

29 Dec 2016, 09:34

i was messing around with the old/classic save dialog in photoshop today and realised that you can enter a folder path into edit1 and it will go to the folder. it works for the new save dialogs as well. no hotkeys needed!

Code: Select all

controlSetText, edit1, % folder_path, ahk_class #32770
sleep 50
controlSend, edit1, {enter}, ahk_class #32770

edit: ok i lied. the newer dialogs need a "sleep 50" in between those two lines
leeroy
Posts: 5
Joined: 22 Dec 2016, 13:59
GitHub: akaleeroy

Re: Easy Access to Currently Opened Folders

30 Dec 2016, 19:15

davebrny wrote:realised that you can enter a folder path into edit1 and it will go to the folder.
I know but I avoid using Edit1 because that's for filenames... If a Save dialog pre-fills the filename and I write over it to navigate to a path... basically I'm too lazy to properly handle that situation. And I don't see a reason to do so, what with Send !{d} and all. Using the address bar for addresses seems more appropriate.

An improvement would be to dispense with the whole mechanism altogether and navigate independent of the dialog's controls. Using some Windows API. No more Sleep 50 and no more occasional quirks. That's why I posted it everywhere, in case someone can point out how that can be done. It's proven hard to Google. :D
User avatar
davebrny
Posts: 83
Joined: 05 Dec 2016, 06:26

Re: Easy Access to Currently Opened Folders

31 Dec 2016, 14:15

leeroy wrote:If a Save dialog pre-fills the filename and I write over it to navigate to a path

it actually puts the name back in after you enter the path. but if you enter the path half way through typing a new name then you would lose it though.

i just went with this method in the end since the !d hotkey doesnt work with the older dialogs. if you dont have to deal with any of them then lucky you!
leeroy
Posts: 5
Joined: 22 Dec 2016, 13:59
GitHub: akaleeroy

Re: Easy Access to Currently Opened Folders

03 Jan 2017, 13:15

Oooh, I get it now. I'd like to support older dialogs too, so I'll look into it. It's true, I haven't had to deal with them in a while.

EDIT: Regedit Export dialog is one of these old ones.

I remember I could get one of these old dialogs with PowerShell:

Code: Select all

# Show a legacy Common Open File Dialog, the one with the Places bar on the left
Function Get-FileName($initialDirectory, $Title) {
  [void][System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")

  $OpenFileDialog = New-Object System.Windows.Forms.OpenFileDialog
  $OpenFileDialog.Title = $Title
  $OpenFileDialog.initialDirectory = $initialDirectory
  $OpenFileDialog.filter = "Executable Files(*.exe;*.bat;*.cmd)|*.exe;*.bat;*.cmd|All files (*.*)|*.*"
  $OpenFileDialog.ShowHelp = $true # Without ShowHelp set to true the dialog doesn't display!
  $OpenFileDialog.ShowDialog() | Out-Null
  $OpenFileDialog.filename
}

$dialogtest = Get-FileName -initialDirectory "D:\Demo" -Title "Select whatever, this is a drill..."
They look like this
Image
(screen recording from another useful gist, Conjoined Twins - IFTTT-style application actions using auditing and scheduled tasks)

Return to “Scripts and Functions”

Who is online

Users browsing this forum: Bing [Bot] and 55 guests