Open folder in new window using mouse middle click

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Johncoool
Posts: 20
Joined: 18 Jul 2018, 17:15

Open folder in new window using mouse middle click

Post by Johncoool » 25 Jan 2022, 14:28

I found this already solved in the below link but it did not work for me.

I tried several of the codes in that thread but none of them worked.

Can someone recheck them and post the correct one here?

viewtopic.php?t=9832

I am trying it on Windows 8.1.

User avatar
mikeyww
Posts: 26848
Joined: 09 Sep 2014, 18:38

Re: Open folder in new window using mouse middle click

Post by mikeyww » 25 Jan 2022, 15:19

Code: Select all

#IfWinActive ahk_class CabinetWClass
MButton::
For each, file in getSelected()
 Run, explorer.exe "%file%"
Return
#IfWinActive

getSelected() { ; https://www.autohotkey.com/boards/viewtopic.php?style=17&t=60403#p255256 by teadrinker
 hwnd := WinExist("A"), selection := []
 WinGetClass, class
 If (class ~= "(Cabinet|Explore)WClass")
  For window in ComObjCreate("Shell.Application").Windows
   If (window.hwnd = hwnd)
    For item in window.document.SelectedItems
     selection.Push(item.Path)
 Return selection
}

Johncoool
Posts: 20
Joined: 18 Jul 2018, 17:15

Re: Open folder in new window using mouse middle click

Post by Johncoool » 25 Jan 2022, 16:32

Thanks because the script did work.

Can it be improved even further.

It is a bit slow. I have to select the folder before I use the middle button to launch it.

I would also like it to launch folders from the navigation pane of the file explorer.

User avatar
mikeyww
Posts: 26848
Joined: 09 Sep 2014, 18:38

Re: Open folder in new window using mouse middle click

Post by mikeyww » 25 Jan 2022, 17:35

As long as File Explorer is active, you could issue Click as the first action of the hotkey routine. That would select the file under the mouse. Regarding the nav bar, I think that there are some other posts about how to get those selections; I do not recall the details. Others here may know.

Post Reply

Return to “Ask for Help (v1)”