Ctrl+W Hotkey to close current tab even if its only tab

Hi - I am looking for a solution for the behavior of having "Ctrl+W" or "Ctrl+F4" hotkey to close the current tab always - even if it is the only/last tab in the window.
Currently - "Go tabclose" works -- but when the last tab is remaining - it stops working. I am looking for the behavior of that the hotkey would close the entire window if there is only one last tab remaining.

I'm also interested in a solution to this - I just tried out Directory Opus and this is my main frustration with it. It's handy to be able to quickly close tabs in a program with Ctrl+W, and the last tab shouldn't be any different. It's also a very familiar habit for anyone who is used to WIndows Explorer, to be able to close a window with Ctrl+W.

Alt+F4 closes the window, or you can bind a hotkey to the Close command.

Whether you should be able to close the window by closing the last tab is a matter of debate. Some people dislike it, and how it works in different programs varies as a result.

The problem with Alt+F4 is that as I progressively close a bunch of tabs with Ctrl+W, when I get to the last tab it requires me to use a different shortcut, and looking at it from that perspective, it's kind of arbitrary that one tab should require a different shortcut to close than all the others. I do get the logic of course, but it slows me down, Alt+F4 being a less ergonomic way of closing a tab than just leaving my hand hovering above Ctrl+W which works on the other tabs. I realise it's subjective, but that's why it would be nice as a setting that could be toggled in preferences, e.g. "Folder Tabs/Options/Closing last tab closes lister". :slight_smile:

If you want to close all the tabs you can just push Alt+F4 once, which is more ergonomic than pushing Ctrl+W lots of times. I guess it depends on if you want to look at each tab before deciding whether or not to close it.

I always find it surprising & unwanted when I close a tab I no longer want, to tidy up a window I still want to then use for something else, and the whole window vanishes underneath me because I happened to not have any other tabs open.

In Directory Opus 11, the functionality you desire can be implemented with scripting. Just overwrite the default "Go TABCLOSE" functionality for CTRL+W with the following script (under Customize -> Keys -> CTRL+W).

function OnClick(clickData) {
	if (DOpus.listers.lastactive.tabs.count > 1) {
		clickData.func.command.RunCommand("Go TABCLOSE")
	} else {
		clickData.func.command.RunCommand("Close")
	}
}

When I close the last tab, I prefer it to go to my default location, so I have mine set up similarly to this:

function OnClick(clickData) {
	if (DOpus.listers.lastactive.tabs.count > 1) {
		clickData.func.command.RunCommand("Go TABCLOSE")
	} else {
		clickData.func.command.RunCommand("Go ComputerName")
	}
}

Thanks for sharing your solution and perhaps it will help someone else but I'm still using v10 for now so not an option. I ended up solving it (as with so many things in Windows :wink:) with an autohotkey script.

Hello all!

Reviving this thread, as I was looking for this function! :slight_smile:
I've try to copy/paste the 1st script given by soja, but it doesn't seem to work on Opus 12 :frowning:
Although there's no error message while running it, it just doing nothing.

I must say that, as coming from Clover, I'm now use to browse by tabs, and Clover actually exits when the last tab is closed.
Now I've just switched to Opus (and love it so far!), and I'd really like to see that feature working.

Any idea?

Cheers!

The script above still works in Opus 12.

You'll need Opus Pro to run scripts in buttons/hotkeys so this won't work if you're using the Light version.

It should look like the screenshot below:


If you see a single-line command editor, click Advanced first, then click to the Script Code tab.

Note that the way the script language is specified is slightly different in 12 vs 11; it's via a drop-down now instead of seeing @language xyz at the top. Other than that first line, I just pasted the script as-is.

Thanks a lot for your answer!
I do have the pro version, and I've made some changes and followed your instructions.

So I've opened a couple of tabs, and closed them with CTRL-W hotkey. When I wanna close the last one, now I've got this message:


(2nd line means: "The specified pathname was not found")

Here's my script window so you can check if anything is wrong:


Any idea? :slight_smile:

Thanks!

Woops ... sorry, my bad; I've copied the wrong script :slight_smile:

With the line ("Go ComputerName")
instead of ("Close")

Now it works like a charm!
Sorry for spamming! :slight_smile:

https://www.gpsoft.com.au/help/opus12/index.html#!Documents/Changes/123.htm

  • Added Preferences / Folder Tabs / Options / Lister closes when last tab closes option.
2 Likes