[Script] PersistentSaveFolder

Post your working scripts, libraries and tools
burque505
Posts: 684
Joined: 22 Jan 2017, 19:37

[Script] PersistentSaveFolder

12 Dec 2017, 15:06

Hi all.

This script is to combat the frustration of navigating all over the place when opening, saving, or changing Explorer folders when most of what you want to do is in ONE FOLDER.
But you have to jump back and forth between apps - say Excel, Outlook, Acrobat, Word - and each has its own idea as to where you should be saving things.
Other people have posted similar scripts, I'm sure. I think Quick Access Popup has a similar feature, but I haven't checked it out.
Nothing fancy:

Ctrl+Win+S: From most open/save dialogs or an open Explorer window, save a folder path.
Ctrl+Win+C: Clear that folder path.
Ctrl+Win+J: Jump to that folder.
Ctrl+Win+Q: Ask the script what folder you have set.
Shift+Escape: Bail out.

Tested so far on Win7, 64-bit, AHK_H 64-bit, 1.1.26.01, 1.1.28.00 (AHK_H and AHK_L). Works with:
[Update 12/16/17] Word, Excel, Powerpoint, Acrobat, Explorer, Thunderbird,Scite4AutoHotkey, Outlook, Notepad, Firefox 57, IE 11, Pale Moon 27 (32-bit), Chrome (from Ctrl+S)
I'm sure many progs will choke on it (Edit March 27, 2018 - chokes less)
[Update March 27, 2018 - chokes less on Thunderbird and Office Open/Save/Attach dialogs]
[Update March 28, 2018 - can now set the persistent folder from T-bird Save As and Attach dialogs]
*Still to do: Fix intermittent Acrobat bugs.

Though it's called PersistentSaveFolder, that isn't a complete description - you can jump to the Save folder in Explorer also.
Spoiler
Regards,
burque505
Last edited by burque505 on 28 Mar 2018, 17:40, edited 7 times in total.
ldub

Re: [Script] PersistentSaveFolder

13 Dec 2017, 05:49

I do like your script burque505, there is a real need on this side.
I hope you could refine it!
burque505
Posts: 684
Joined: 22 Jan 2017, 19:37

Re: [Script] PersistentSaveFolder

13 Dec 2017, 11:47

Thanks, ldub. I do have some work to do on it. For one thing, saving from Word to a PDF (i.e. "printing" a PDF from the print dialog), doesn't work, because the edit control changes to Edit2 instead of Edit3. I'll post an update as soon as I fix that.

EDIT: Code updated in OP: At the expense of using ControlSetText, which seems more solid, I've used the clipboard to paste in Edit2, Edit3, etc. This fixes the problem above. I'm a little leary about leaving it that way, since a person might have a really full clipboard when saving. The script saves and restores the clipboard, but the delays might not handle a really stuffed clipboard.

If I can figure out a one-size-fits-all way to go back to ControlSetText, I'm going to do that.

I am, however, using it as is and it's saving me about ten minutes a day by my reckoning.

Regards,
burque505
User avatar
Relayer
Posts: 121
Joined: 30 Sep 2013, 13:09
Location: Delaware, USA

Re: [Script] PersistentSaveFolder

14 Dec 2017, 16:00

I love this idea. Here is my take on this. It simply maintains the current and previous titles of the windows that have focus. Upon changing and the current window title having the word "Save" in it, the script reads a section from an ini file and if the ini key is contained in the previous window title, the ini value is jammed into the save dialog as the folder path. Just maintain the ini and you have specified paths for any application or web page.

I'm sure it can be polished.
Relayer

Code: Select all

#SingleInstance Force
#NoEnv

SetTimer, CheckFocus, 250
Return

checkFocus:
	WinGetTitle, title, A
	if (title != hasFocus)
	{
		hadFocus := hasfocus
		if (InStr(hasFocus := title, "Save") = 1)
		{
			iniRead, context, % A_ScriptDir . "\ContextPaths.ini", ContextPaths
			Loop, Parse, context, % "`n"
				if (InStr(hadFocus, SubStr(A_LoopField, 1, (tmp := InStr(A_LoopField, "=")) - 1)))
				{
					path := SubStr(A_LoopField, tmp + 1)
					Send !d
					Sleep, 250
					SendInput, {Raw}%Path%
					SendInput, {Enter}
					Break
				}
		}
	}
Return

Escape::ExitApp
The ini section

Code: Select all

[ContextPaths]
Airliners=d:\junk
ebay=C:\temp
User avatar
jeeswg
Posts: 5435
Joined: 19 Dec 2016, 01:58
Location: UK

Re: [Script] PersistentSaveFolder

15 Dec 2017, 01:30

I have some scripts that may be useful:

[See CFD/CID functions (old-style Common File Dialog, new-style Common Item Dialog).]
GUIs via DllCall: get/set internal/external control text - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=40514

[JEE_DlgInvokeBtn: for CFDs/CIDs: invoke an item (folder) in the side toolbar.]
jeeswg's Notepad tutorial - AutoHotkey Community
https://autohotkey.com/boards/viewtopic ... 59#p148159

Explorer window interaction (folder windows/Desktop, file/folder enumeration/selection/navigation/creation) - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=35041

#3000thPost #HashTag
User avatar
Drugwash
Posts: 642
Joined: 29 May 2014, 21:07
Location: Ploieşti, Romania

Re: [Script] PersistentSaveFolder

15 Dec 2017, 03:18

Years ago I've been using DM2 on 98SE. Reports say it's been working in Win7 x64 too (see the SourceForge page while it's still there).
Project recently moved to GitHub but it's no longer maintained.
It'd be nice if someone picked it up - some things need fixed, some improved, some added.

As far as I can remember it added a couple extra icons to any open/save dialog where favorite folders could be picked. May be of help.
I've deleted my CloudMe account because of GDPR - the now legal base for privacy invasion and data theft.
burque505
Posts: 684
Joined: 22 Jan 2017, 19:37

Re: [Script] PersistentSaveFolder

15 Dec 2017, 14:48

Relayer, thanks for the script, I'm going to experiment with it.
jeeswg, thanks for all those links! I really need to work on the get/set control text part.
Drugwash, thanks for pointing me to DM2, I didn't know it existed. I'll look for features that might be good to add.
Regards,
burque505
burque505
Posts: 684
Joined: 22 Jan 2017, 19:37

Re: [Script] PersistentSaveFolder

16 Dec 2017, 11:05

Minor edits - no more clipboard for 'saveHere()' function - using 'SendInput, {Raw}%saveFolder%' (thanks, Relayer!).
Code updated in original post.
EDIT: updates on March 27 and March 28, 2018. Latest is in OP.
Regards,
burque505

Return to “Scripts and Functions”

Who is online

Users browsing this forum: No registered users and 24 guests