I have a special lister for a large task. I need to keep it open, while I work in many other listers on regular stuff. Occasionally when I hit Alt-F4 to close the program on top of the screen, the lister closes, presumably because it was still in focus rather than being on top. Regardless, I dont want to close that particular lister. Is there a way to disable Alt-F4 for a single lister? or, plan B disable Alt-F4 for all listers and only use the top right x box insted (not as neat, but workable).
Longer story: that special lister opens two tabs in extremely large folders, with with 8,000 subfolders on the left and 2 x 32,000 on the right, each with 2-100 files in them. I have a 5 year project going on, to transfer files from one to the other. Sadly for me, one folder at a time, and after I check the contents for possible updates. The only problem part of this scenario is that DOPUS takes a long time (20-30 min in total) to 'read' the subfolders, numbers of files, names of subfolders etc, and then focus on the subfolder I want. (A bit slow on 8,000, very slow on 32,000). This is required because of the workflow which involves constantly switching back and forth between parent and subfolders. So I have to 'preload' these folders simply by waiting and waiting. If I dont 'preload' them even dealing with one folder is a pain in terms of waiting. So if I was in the middle of a job later, its annoying to have to start again to re-load the lister and all those folders. Please dont suggest splitting them in to smaller subfolders - I have done so as far as I can (2 x 32,000), but an further than this will wreck the overall work flow (too long for details here).
Another thing that might help would be the ability to 'save' this particular lister with all of its folder and file information that it previously read from these subfolders. I wonder if thats possible?? Then open later, ready-to-go? But of course, it still needs to detect changes in the directories...
A script can use the OnCloseLister event to be told when a lister is closing, and can keep it open (unless Opus or Windows are shutting down).
So if you have a way to tell that window from others you want to act normally (e.g. by the paths in each side), the script should be able to do what you need.
It could also show a confirmation prompt so that you can still close it when you actually want to.
The script won't be able to react to Alt-F4 on its own without also affecting the window's close button. They are both the same to the script, so anything it does will apply to both.
In Opus 12 (but I don't think in Opus 11, unless my memory is wrong), you can use the Close NOSCRIPT command to close a window while bypassing script events, which would be another way to close the protected window, if you didn't want to go with a confirmation prompt.
Thanks Leo.
I am not sure if I have a way to tell that window from others I want to act normally other than the parents of the paths in each side. (There is one common parent folder on both sides of my special lister, and this parent is never open in any other lister).
I will research and give this a try. (Not good with scripting here...takes me a while).
Thanks for the offer. I am already stuck at the point of how to find an .osp file for this function (OnCloseLister). All I can work out so far is how to have it true or false, assuming I can find it. I know how to install the script, just not sure how to make and edit one. So alredy missing something key here..
At its very simplest, dont close a lister where a) I am in dual vertical mode (which I rarely use for anything else) and b) where the parent folder is "D:\Kindle eBooks" for both sides of the dual lister (but any subfolder can be open, at any depth under that parent).
An "are you sure you want to close this lister" would likely be sufficient as long as I can say no...
In Opus 12, use the first icon above the list of scripts.
Here's a sample script which I think does everything you want.
It also only does it if the Alt key is held down, so it's better than I thought earlier. Clicking the close button with the mouse will still behave normally (unless you hold the Alt key down for some reason). Alt-F4 will trigger the script but most other ways of closing it won't.
I've only tested the script with Opus 12 so it may need some small changes for Opus 11, but I don't think I've used anything that is new. Apologies if I have.
When creating the script, choose JScript as the language, then paste this over the file it creates when the editor opens, and save it. That should be all you need to do.
// Called by Directory Opus to initialize the script
function OnInit(initData)
{
initData.name = "ProtectedLister";
initData.version = "1.0";
initData.copyright = "(c) 2017 Leo Davidson";
initData.url = "https://resource.dopus.com/t/prevent-a-lister-from-closing-with-alt-f4/24582";
initData.desc = "Protect a lister from closing";
initData.default_enable = true;
initData.min_version = "11.0";
}
// Called when a Lister is closed
function OnCloseLister(closeListerData)
{
var ALLOW_CLOSE = false;
var PREVENT_CLOSE = true;
var parentPathCheck = "D:\\Kindle eBooks";
// If Opus/Windows are shutting down, can't stop it.
// If Alt key is not down, don't stop it; only want to modify Alt-F4.
if (closeListerData.shutdown
|| closeListerData.qualifiers != "alt")
{
return ALLOW_CLOSE;
}
var lister = closeListerData.lister;
// If not in dual vertical mode, allow closure.
if (lister.dual != 1)
{
return ALLOW_CLOSE;
}
var pathC = DOpus.FSUtil.Resolve(parentPathCheck);
var path1 = DOpus.FSUtil.Resolve(lister.activetab.path);
var path2 = DOpus.FSUtil.Resolve(lister.desttab.path);
// Check that both paths are children of (or equal to)
// parentPathCheck defined at the top of the function.
if (!DOpus.FSUtil.ComparePath(path1, pathC, "p")
|| !DOpus.FSUtil.ComparePath(path2, pathC, "p"))
{
return ALLOW_CLOSE;
}
var dlg = lister.Dlg();
var choice = dlg.Request("Close this window?", "Close|Leave Open");
if (choice == 1)
{
return ALLOW_CLOSE;
}
return PREVENT_CLOSE;
}
Holey Cow! Thanks! Works on first attempt here (Opus v11)! I tried it out on various other listers, and they are all unaffected so far, I have tried any single lister in the target folder or subfolder, and they are all unaffected. Only any combination of subfolders I have tried so far within a dual lister situation. Then I get an option to close or not - ideal, because I can say no. Its perfect out of the box. Thanks!
Any one else using this just needs to edit the parent folder location and know that this works only in a dual vertical mode lister.