Middle Mouse Button Close Tab

I'm trying to get the middle mouse button click on top of a tab to duplicate it instead of close it, but I can't find that option anywhere.

I have middle mouse button set to open folders in a new tab, but can't find the tab itself.

1 Like

To duplicate a tab, I usually go with Ctrl-T : opens a new tab "as a duplicate" (e.g. in the same folder). Associated command if GO CURRENT NEWTAB.
My tabs are configured to act as the folder they hold. So every action (right click for instance) is behaving as if I was acting on the folder itself. If you were to configure that, middle mouse click would probably do what you want.

1 Like

If I can just disable middle mouse button deletes tab, I would be happy with that.
You know how many times I deleted a tab because of muscle memory.
But oddly, there doesn't seem to be a way of adding middle mouse button click actions to tabs.
The "Ctrl + Click = double mm press, then the file types, make double mm press = a custom action" trick works for files and folders, but not tabs.

1 Like

It seems like standard, non configurable, setting (as Preferences/Tabs/Options says under the "Double Click on a tab to close it").
If you close a tab my mistake, Ctrl+Shift+T (which executes Go TABUNDOCLOSE) will make it come back.

1 Like

You could use an AutoHotkey script to basically rebind the middle mouse key while Directory Opus is active like this, which I tried and works:

#Requires AutoHotkey v2.0
; Only if DOpus is active
#HotIf WinActive("ahk_exe DOpus.exe")
{
    ; Middle mouse press --> Ctrl + T
    MButton:: Send("^t")
}
#HotIf

That would make the middle mouse button always duplicate the tab though, not just when clicking it on the tab itself. You could instead make it do nothing instead by replacing the one line of code with:
MButton:: Return

1 Like

Oh wow, today I watched your "Hidden File Extensions" video that references hiding some extensions with "A program called Directory Opus" and I'm like, "I do that too!" :grinning:
Oh Look

I should really bite the bullet and finally dive into Auto Hotkey. Everyone should learn a baseline level of coding acumen now adays.

Even Corsair's iCue doesn't handle specific middle mouse button rebinds for some reason.
The problem with your idea is it has to be context aware, or else other mm button tasks would be overridden by this, like holding it down for smooth scroll. And it would have to be aware of the focused application, but I'm sure AHK could handle that.

Thanks for all the helpful videos over the years. :hugs:

Another option:

Reopen multiple closed tabs via GUI or a command

1 Like

Actually the bit I posted does only take effect if directory opus is the focused window. I should have clarified what I meant by 'active'. There might be ways with AHK to add further conditions but I'm not familiar enough with it to know.

1 Like

I think you can make AHK look at the (child) window under the mouse pointer, so it can check if it's the folder tab bar (window class = dopus.tabctrl) or another part of the lister.

My knowledge of AHK is quite basic, so I couldn't tell you the syntax for doing this, but I think I've seen it done in AHK scripts.

1 Like

There are other ways of doing this. The easiest for me is right under the tab is the breadcrumb path. I have it set to open in new tab on mm button press. And Ctrl + mm button opens in new tab on the destination lister.

Breadcrumbs

But being able to duplicate a tab is handy. I can mm button press on the parent folder in the breadcrumb path, which is the same thing.

I just accidently closed this chrome tab, testing it out here, and it's the same thing. Mm button press closes the tab. So I guess I'm asking for something that isn't common.

I have the new tab button > duplicate, so that's close enough. First world problems amiright.
New Tab

But I'm for sure getting on AHK when I have the time.

Found a way here, it would look like this:

#Requires AutoHotkey v2.0

; Rebind MButton to Ctrl + T if mouse is over Directory Opus tab bar
#HotIf mouseOver("ahk_exe dopus.exe", "dopus.tabctrl1") or mouseOver("ahk_exe dopus.exe", "dopus.tabctrl2")
{
    ; Middle mouse press --> Ctrl + T
    MButton:: Send("^t")

    ; Effectively disable MButton
    ; MButton:: Return
}
#HotIf

; Function to check if mouse is over a specific window and control
mouseOver(winTitle, ctl := '') {
    MouseGetPos ,, &hWnd, &classNN
    Return WinExist(winTitle ' ahk_id' hWnd) && classNN = (ctl || classNN)
}

You can use the Window Spy feature in AHK to see what name it sees for each control under "ClassNN":
image

1 Like